MCPcopy Index your code
hub / github.com/darkreader/darkreader / bundleAPIModule

Function bundleAPIModule

tasks/bundle-api.js:25–73  ·  view source on GitHub ↗
({debug, watch}, moduleType, dest)

Source from the content-addressed store, hash-verified

23let watchFiles = [];
24
25async function bundleAPIModule({debug, watch}, moduleType, dest) {
26 const src = absolutePath('src/api/index.ts');
27 const bundle = await rollup.rollup({
28 input: src,
29 onwarn: (error) => {
30 throw error;
31 },
32 plugins: [
33 // @ts-expect-error This expression is not callable
34 rollupPluginTypescript({
35 rootDir: absolutePath('.'),
36 typescript,
37 tsconfig: absolutePath('src/api/tsconfig.json'),
38 noImplicitAny: debug ? false : true,
39 noUnusedLocals: debug ? false : true,
40 strictNullChecks: debug ? false : true,
41 strictPropertyInitialization: false,
42 removeComments: debug ? false : true,
43 sourceMap: debug ? true : false,
44 inlineSources: debug ? true : false,
45 noEmitOnError: watch ? false : true,
46 outDir: absolutePath('.'),
47 cacheDir: debug ? `${fs.realpathSync(os.tmpdir())}/darkreader_api_typescript_cache` : undefined,
48 }),
49 // @ts-expect-error This expression is not callable
50 rollupPluginReplace({
51 preventAssignment: true,
52 __DEBUG__: false,
53 __CHROMIUM_MV2__: false,
54 __CHROMIUM_MV3__: false,
55 __FIREFOX_MV2__: false,
56 __THUNDERBIRD__: false,
57 __TEST__: false,
58 __PLUS__: false,
59 }),
60 ].filter(Boolean),
61 });
62 watchFiles = bundle.watchFiles;
63 await bundle.write({
64 banner: `/**\n * Dark Reader v${await getVersion()}\n * https://darkreader.org/\n */\n`,
65 // TODO: Consider removing next line
66 esModule: true,
67 file: dest,
68 strict: true,
69 format: moduleType,
70 name: 'DarkReader',
71 sourcemap: debug ? 'inline' : false,
72 });
73}
74
75async function bundleAPI({debug, watch}) {
76 await bundleAPIModule({debug, watch}, 'umd', 'darkreader.js');

Callers 1

bundleAPIFunction · 0.85

Calls 2

absolutePathFunction · 0.90
getVersionFunction · 0.70

Tested by

no test coverage detected