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

Function bundleDevModule

src/compiler/bundle/dev-module.ts:83–126  ·  view source on GitHub ↗
(
  config: d.ValidatedConfig,
  compilerCtx: d.CompilerCtx,
  parsedUrl: ParsedDevModuleUrl,
  results: d.CompilerRequestResponse,
)

Source from the content-addressed store, hash-verified

81};
82
83const bundleDevModule = async (
84 config: d.ValidatedConfig,
85 compilerCtx: d.CompilerCtx,
86 parsedUrl: ParsedDevModuleUrl,
87 results: d.CompilerRequestResponse,
88) => {
89 const buildCtx = new BuildContext(config, compilerCtx);
90
91 try {
92 const inputOpts = getRollupOptions(config, compilerCtx, buildCtx, {
93 id: parsedUrl.nodeModuleId,
94 platform: 'client',
95 inputs: {
96 index: parsedUrl.nodeResolvedPath,
97 },
98 });
99 const rollupBuild = await rollup(inputOpts);
100
101 const outputOpts: OutputOptions = {
102 banner: generatePreamble(config),
103 format: 'es',
104 };
105
106 if (parsedUrl.nodeModuleId) {
107 const commentPath = relative(config.rootDir, parsedUrl.nodeResolvedPath);
108 outputOpts.intro = `/**\n * Dev Node Module: ${parsedUrl.nodeModuleId}, v${parsedUrl.nodeModuleVersion}\n * Entry: ${commentPath}\n * DEVELOPMENT PURPOSES ONLY!!\n */`;
109 inputOpts.input = parsedUrl.nodeResolvedPath;
110 }
111
112 const r = await rollupBuild.generate(outputOpts);
113
114 if (buildCtx.hasError) {
115 results.status = 500;
116 results.content = `console.error(${JSON.stringify(buildCtx.diagnostics)})`;
117 } else if (r && r.output && r.output.length > 0) {
118 results.content = r.output[0].code;
119 results.status = 200;
120 }
121 } catch (e) {
122 results.status = 500;
123 const errorMsg = e instanceof Error ? e.stack : e + '';
124 results.content = `console.error(${JSON.stringify(errorMsg)})`;
125 }
126};
127
128const useDevModuleCache = async (config: d.ValidatedConfig, p: string) => {
129 if (config.enableCache) {

Callers 1

compilerRequestFunction · 0.85

Calls 3

getRollupOptionsFunction · 0.90
generatePreambleFunction · 0.85
relativeFunction · 0.85

Tested by

no test coverage detected