MCPcopy Create free account
hub / github.com/stenciljs/core / buildSysNode

Function buildSysNode

scripts/esbuild/sys-node.ts:12–86  ·  view source on GitHub ↗
(opts: BuildOptions)

Source from the content-addressed store, hash-verified

10import { externalAlias, externalNodeModules, getBaseEsbuildOptions, getEsbuildAliases, runBuilds } from './utils';
11
12export async function buildSysNode(opts: BuildOptions) {
13 const inputDir = path.join(opts.buildDir, 'sys', 'node');
14 const srcDir = path.join(opts.srcDir, 'sys', 'node');
15 const inputFile = path.join(srcDir, 'index.ts');
16 const outputFile = path.join(opts.output.sysNodeDir, 'index.js');
17
18 // clear out rollup stuff and ensure directory exists
19 await fs.emptyDir(opts.output.sysNodeDir);
20
21 // create public d.ts
22 let dts = await fs.readFile(path.join(inputDir, 'public.d.ts'), 'utf8');
23 dts = dts.replace('@stencil/core/internal', '../../internal/index');
24 await fs.writeFile(path.join(opts.output.sysNodeDir, 'index.d.ts'), dts);
25
26 // write @stencil/core/sys/node/package.json
27 writePkgJson(opts, opts.output.sysNodeDir, {
28 name: '@stencil/core/sys/node',
29 description: 'Stencil Node System.',
30 main: 'index.js',
31 types: 'index.d.ts',
32 });
33
34 const external = [
35 ...externalNodeModules,
36 // normally you wouldn't externalize your "own" directory here, but since
37 // we build multiple things within `opts.output.sysNodeDir` which should
38 // externalize each other we need to do so
39 '../../compiler/stencil.js',
40 '../../sys/node/index.js',
41 './glob.js',
42 ];
43
44 const sysNodeAliases = {
45 ...getEsbuildAliases(),
46 '@stencil/core/compiler': '../../compiler/stencil.js',
47 '@sys-api-node': '../../sys/node/index.js',
48 };
49
50 const sysNodeOptions: ESBuildOptions = {
51 ...getBaseEsbuildOptions(),
52 entryPoints: [inputFile],
53 bundle: true,
54 format: 'cjs',
55 outfile: outputFile,
56 platform: 'node',
57 logLevel: 'info',
58 external,
59 minify: true,
60 alias: sysNodeAliases,
61 banner: { js: getBanner(opts, `Stencil Node System`, true) },
62 plugins: [externalAlias('graceful-fs', './graceful-fs.js')],
63 };
64
65 // sys/node/worker.js bundle
66 const inputWorkerFile = path.join(srcDir, 'worker.ts');
67 const outputWorkerFile = path.join(opts.output.sysNodeDir, 'worker.js');
68
69 const workerOptions: ESBuildOptions = {

Callers 1

buildAllFunction · 0.90

Calls 11

writePkgJsonFunction · 0.90
getEsbuildAliasesFunction · 0.90
getBaseEsbuildOptionsFunction · 0.90
getBannerFunction · 0.90
externalAliasFunction · 0.90
runBuildsFunction · 0.90
sysNodeExternalBundlesFunction · 0.85
joinMethod · 0.80
readFileMethod · 0.80
writeFileMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected