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

Function getInternalTestingBundle

scripts/esbuild/internal-platform-testing.ts:17–60  ·  view source on GitHub ↗
(opts: BuildOptions)

Source from the content-addressed store, hash-verified

15 * @returns a promise wrapping an object holding options for ESBuild
16 */
17export async function getInternalTestingBundle(opts: BuildOptions): Promise<ESBuildOptions> {
18 const inputTestingPlatform = join(opts.srcDir, 'testing', 'platform', 'index.ts');
19 const outputTestingPlatformDir = join(opts.output.internalDir, 'testing');
20
21 await fs.emptyDir(outputTestingPlatformDir);
22
23 // write @stencil/core/internal/testing/package.json
24 writePkgJson(opts, outputTestingPlatformDir, {
25 name: '@stencil/core/internal/testing',
26 description:
27 'Stencil internal testing platform to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.',
28 main: 'index.js',
29 });
30
31 // Copy JSX runtime files for automatic JSX transform support
32 const srcJsxDir = join(opts.srcDir, 'internal', 'testing');
33 const jsxFiles = ['jsx-runtime.js', 'jsx-runtime.d.ts', 'jsx-dev-runtime.js', 'jsx-dev-runtime.d.ts'];
34 await Promise.all(jsxFiles.map((file) => fs.copyFile(join(srcJsxDir, file), join(outputTestingPlatformDir, file))));
35
36 const internalTestingAliases = {
37 ...getEsbuildAliases(),
38 '@platform': inputTestingPlatform,
39 '@stencil/core/mock-doc': '../../mock-doc/index.cjs',
40 };
41
42 const external: string[] = [...externalNodeModules, '../../mock-doc/index.cjs'];
43
44 const internalTestingBuildOptions: ESBuildOptions = {
45 ...getBaseEsbuildOptions(),
46 entryPoints: [inputTestingPlatform],
47 bundle: true,
48 format: 'cjs',
49 outfile: join(outputTestingPlatformDir, 'index.js'),
50 platform: 'node',
51 logLevel: 'info',
52 external,
53 alias: internalTestingAliases,
54 plugins: [
55 externalAlias('@app-data', '@stencil/core/internal/app-data'),
56 externalAlias('@utils/shadow-css', '../client/shadow-css.js'),
57 ],
58 };
59 return internalTestingBuildOptions;
60}

Callers 1

buildInternalFunction · 0.90

Calls 6

joinFunction · 0.90
writePkgJsonFunction · 0.90
getEsbuildAliasesFunction · 0.90
getBaseEsbuildOptionsFunction · 0.90
externalAliasFunction · 0.90
copyFileMethod · 0.80

Tested by

no test coverage detected