generate "use strict" only when really needed

This commit is contained in:
Tobias Koppers 2021-07-22 16:09:09 +02:00
parent a32b0fd041
commit 0bd1e789d4
6 changed files with 214 additions and 157 deletions

View File

@ -350,7 +350,7 @@ class Template {
/**
* @param {RuntimeModule[]} runtimeModules array of runtime modules in order
* @param {RenderContext & { codeGenerationResults?: CodeGenerationResults, useStrict?: boolean }} renderContext render context
* @param {RenderContext & { codeGenerationResults?: CodeGenerationResults }} renderContext render context
* @returns {Source} rendered runtime modules in a Source object
*/
static renderRuntimeModules(runtimeModules, renderContext) {
@ -382,12 +382,10 @@ class Template {
source.add("\n\n");
} else if (renderContext.runtimeTemplate.supportsArrowFunction()) {
source.add("(() => {\n");
if (renderContext.useStrict) source.add('\t"use strict";\n');
source.add(new PrefixSource("\t", runtimeSource));
source.add("\n})();\n\n");
} else {
source.add("!function() {\n");
if (renderContext.useStrict) source.add('\t"use strict";\n');
source.add(new PrefixSource("\t", runtimeSource));
source.add("\n}();\n\n");
}
@ -406,7 +404,6 @@ class Template {
"/******/ ",
new ConcatSource(
"function(__webpack_require__) { // webpackRuntimeModules\n",
'"use strict";\n\n',
this.renderRuntimeModules(runtimeModules, renderContext),
"}\n"
)

View File

@ -82,23 +82,17 @@ class ArrayPushCallbackChunkFormatPlugin {
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
);
if (runtimeModules.length > 0 || entries.length > 0) {
const strictBailout =
hooks.strictRuntimeBailout.call(renderContext);
const runtime = new ConcatSource(
(runtimeTemplate.supportsArrowFunction()
? "__webpack_require__ =>"
: "function(__webpack_require__)") +
" { // webpackRuntimeModules\n",
strictBailout
? `// runtime can't be in strict mode because ${strictBailout}.\n\n`
: '"use strict";\n\n'
" { // webpackRuntimeModules\n"
);
if (runtimeModules.length > 0) {
runtime.add(
Template.renderRuntimeModules(runtimeModules, {
...renderContext,
codeGenerationResults: compilation.codeGenerationResults,
useStrict: !!strictBailout
codeGenerationResults: compilation.codeGenerationResults
})
);
}

View File

@ -72,6 +72,7 @@ const printGeneratedCodeForStack = (module, code) => {
* @property {ModuleGraph} moduleGraph the module graph
* @property {ChunkGraph} chunkGraph the chunk graph
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {boolean} strictMode rendering in strict context
*/
/**
@ -83,6 +84,7 @@ const printGeneratedCodeForStack = (module, code) => {
* @property {ChunkGraph} chunkGraph the chunk graph
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {string} hash hash to be used for render call
* @property {boolean} strictMode rendering in strict context
*/
/**
@ -94,6 +96,7 @@ const printGeneratedCodeForStack = (module, code) => {
* @property {ChunkGraph} chunkGraph the chunk graph
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {InitFragment<ChunkRenderContext>[]} chunkInitFragments init fragments for the chunk
* @property {boolean} strictMode rendering in strict context
*/
/**
@ -256,7 +259,8 @@ class JavascriptModulesPlugin {
runtimeTemplate,
moduleGraph,
chunkGraph,
codeGenerationResults
codeGenerationResults,
strictMode: runtimeTemplate.isModule()
},
hooks
);
@ -270,7 +274,8 @@ class JavascriptModulesPlugin {
runtimeTemplate,
moduleGraph,
chunkGraph,
codeGenerationResults
codeGenerationResults,
strictMode: runtimeTemplate.isModule()
},
hooks,
compilation
@ -288,7 +293,8 @@ class JavascriptModulesPlugin {
runtimeTemplate,
moduleGraph,
chunkGraph,
codeGenerationResults
codeGenerationResults,
strictMode: runtimeTemplate.isModule()
},
hooks
);
@ -478,12 +484,17 @@ class JavascriptModulesPlugin {
* @param {Module} module the rendered module
* @param {ChunkRenderContext} renderContext options object
* @param {CompilationHooks} hooks hooks
* @param {boolean | "strict"} factory true: renders as factory method, "strict": renders as factory method already in strict scope, false: pure module content
* @param {boolean} factory true: renders as factory method, false: pure module content
* @returns {Source} the newly generated source from rendering
*/
renderModule(module, renderContext, hooks, factory) {
const { chunk, chunkGraph, runtimeTemplate, codeGenerationResults } =
renderContext;
const {
chunk,
chunkGraph,
runtimeTemplate,
codeGenerationResults,
strictMode
} = renderContext;
try {
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
const moduleSource = codeGenResult.sources.get("javascript");
@ -514,7 +525,7 @@ class JavascriptModulesPlugin {
const needThisAsExports = runtimeRequirements.has(
RuntimeGlobals.thisAsExports
);
const needStrict = module.buildInfo.strict && factory !== "strict";
const needStrict = module.buildInfo.strict && !strictMode;
const cacheEntry = this._moduleFactoryCache.get(
moduleSourcePostContent
);
@ -598,16 +609,25 @@ class JavascriptModulesPlugin {
"javascript",
compareModulesByIdentifier
);
const allModules = modules ? Array.from(modules) : [];
let strictHeader;
let allStrict = renderContext.strictMode;
if (!allStrict && allModules.every(m => m.buildInfo.strict)) {
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
strictHeader = strictBailout
? `// runtime can't be in strict mode because ${strictBailout}.\n`
: '"use strict";\n';
if (!strictBailout) allStrict = true;
}
/** @type {ChunkRenderContext} */
const chunkRenderContext = {
...renderContext,
chunkInitFragments: []
chunkInitFragments: [],
strictMode: allStrict
};
const moduleSources =
Template.renderChunkModules(
chunkRenderContext,
modules ? Array.from(modules) : [],
module => this.renderModule(module, chunkRenderContext, hooks, true)
Template.renderChunkModules(chunkRenderContext, allModules, module =>
this.renderModule(module, chunkRenderContext, hooks, true)
) || new RawSource("{}");
let source = tryRunOrWebpackError(
() => hooks.renderChunk.call(moduleSources, chunkRenderContext),
@ -637,7 +657,11 @@ class JavascriptModulesPlugin {
);
}
chunk.rendered = true;
return new ConcatSource(source, ";");
return strictHeader
? new ConcatSource(strictHeader, source, ";")
: renderContext.runtimeTemplate.isModule()
? source
: new ConcatSource(source, ";");
}
/**
@ -649,12 +673,6 @@ class JavascriptModulesPlugin {
renderMain(renderContext, hooks, compilation) {
const { chunk, chunkGraph, runtimeTemplate } = renderContext;
/** @type {ChunkRenderContext} */
const chunkRenderContext = {
...renderContext,
chunkInitFragments: []
};
const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);
const iife = runtimeTemplate.isIIFE();
@ -687,8 +705,8 @@ class JavascriptModulesPlugin {
} else {
prefix = "/******/ ";
}
let allStrict = false;
if (allModules.every(m => m.buildInfo.strict)) {
let allStrict = renderContext.strictMode;
if (!allStrict && allModules.every(m => m.buildInfo.strict)) {
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
if (strictBailout) {
source.add(
@ -701,18 +719,19 @@ class JavascriptModulesPlugin {
}
}
/** @type {ChunkRenderContext} */
const chunkRenderContext = {
...renderContext,
chunkInitFragments: [],
strictMode: allStrict
};
const chunkModules = Template.renderChunkModules(
chunkRenderContext,
inlinedModules
? allModules.filter(m => !inlinedModules.has(m))
: allModules,
module =>
this.renderModule(
module,
chunkRenderContext,
hooks,
allStrict ? "strict" : true
),
module => this.renderModule(module, chunkRenderContext, hooks, true),
prefix
);
if (
@ -751,7 +770,7 @@ class JavascriptModulesPlugin {
source.add(
new PrefixSource(
prefix,
Template.renderRuntimeModules(runtimeModules, renderContext)
Template.renderRuntimeModules(runtimeModules, chunkRenderContext)
)
);
source.add(

View File

@ -36,7 +36,7 @@ const getAsyncWebAssemblyParser = memoize(() =>
);
/**
* @typedef {Object} RenderContext
* @typedef {Object} WebAssemblyRenderContext
* @property {Chunk} chunk the chunk
* @property {DependencyTemplates} dependencyTemplates the dependency templates
* @property {RuntimeTemplate} runtimeTemplate the runtime template
@ -47,7 +47,7 @@ const getAsyncWebAssemblyParser = memoize(() =>
/**
* @typedef {Object} CompilationHooks
* @property {SyncWaterfallHook<[Source, Module, RenderContext]>} renderModuleContent
* @property {SyncWaterfallHook<[Source, Module, WebAssemblyRenderContext]>} renderModuleContent
*/
/** @type {WeakMap<Compilation, CompilationHooks>} */

View File

@ -253,9 +253,9 @@ default:
vendors:
Entrypoint main 11 KiB = vendors/main.js
Entrypoint a 14.4 KiB = vendors/vendors.js 1.08 KiB vendors/a.js 13.3 KiB
Entrypoint b 8.11 KiB = vendors/vendors.js 1.08 KiB vendors/b.js 7.04 KiB
Entrypoint c 8.11 KiB = vendors/vendors.js 1.08 KiB vendors/c.js 7.04 KiB
Entrypoint a 14.4 KiB = vendors/vendors.js 1.05 KiB vendors/a.js 13.3 KiB
Entrypoint b 8.09 KiB = vendors/vendors.js 1.05 KiB vendors/b.js 7.04 KiB
Entrypoint c 8.09 KiB = vendors/vendors.js 1.05 KiB vendors/c.js 7.04 KiB
chunk (runtime: b) vendors/b.js (b) 156 bytes (javascript) 2.69 KiB (runtime) [entry] [rendered]
> ./b b
runtime modules 2.69 KiB 4 modules
@ -1118,18 +1118,18 @@ webpack x.x.x compiled with 3 warnings"
exports[`StatsTestCases should print correct stats for issue-7577 1`] = `
"asset a-runtime~main-dbc517c94acb2382d133.js 4.84 KiB [emitted] [immutable] (name: runtime~main)
asset a-main-ef61ff9b5cacf52087be.js 424 bytes [emitted] [immutable] (name: main)
asset a-main-ef61ff9b5cacf52087be.js 405 bytes [emitted] [immutable] (name: main)
asset a-all-a_js-5af81d3b60f9e87be69d.js 140 bytes [emitted] [immutable] (id hint: all)
Entrypoint main 5.39 KiB = a-runtime~main-dbc517c94acb2382d133.js 4.84 KiB a-all-a_js-5af81d3b60f9e87be69d.js 140 bytes a-main-ef61ff9b5cacf52087be.js 424 bytes
Entrypoint main 5.37 KiB = a-runtime~main-dbc517c94acb2382d133.js 4.84 KiB a-all-a_js-5af81d3b60f9e87be69d.js 140 bytes a-main-ef61ff9b5cacf52087be.js 405 bytes
runtime modules 2.4 KiB 3 modules
./a.js 18 bytes [built] [code generated]
webpack x.x.x compiled successfully in X ms
asset b-runtime~main-b148542c99d37389019e.js 5.77 KiB [emitted] [immutable] (name: runtime~main)
asset b-all-b_js-d09f99e25781be397e6c.js 475 bytes [emitted] [immutable] (id hint: all)
asset b-main-132fd6da6e6e6728c990.js 457 bytes [emitted] [immutable] (name: main)
asset b-main-132fd6da6e6e6728c990.js 438 bytes [emitted] [immutable] (name: main)
asset b-vendors-node_modules_vendor_js-499179597d8c965dd5e0.js 185 bytes [emitted] [immutable] (id hint: vendors)
Entrypoint main 6.87 KiB = b-runtime~main-b148542c99d37389019e.js 5.77 KiB b-vendors-node_modules_vendor_js-499179597d8c965dd5e0.js 185 bytes b-all-b_js-d09f99e25781be397e6c.js 475 bytes b-main-132fd6da6e6e6728c990.js 457 bytes
Entrypoint main 6.85 KiB = b-runtime~main-b148542c99d37389019e.js 5.77 KiB b-vendors-node_modules_vendor_js-499179597d8c965dd5e0.js 185 bytes b-all-b_js-d09f99e25781be397e6c.js 475 bytes b-main-132fd6da6e6e6728c990.js 438 bytes
runtime modules 2.96 KiB 5 modules
cacheable modules 40 bytes
./b.js 17 bytes [built] [code generated]
@ -1140,9 +1140,9 @@ assets by chunk 895 bytes (id hint: all)
asset c-all-b_js-3c3d3ae5b364fadfafb2.js 502 bytes [emitted] [immutable] (id hint: all)
asset c-all-c_js-5a3e032792662f68ffa4.js 393 bytes [emitted] [immutable] (id hint: all)
asset c-runtime~main-1f593c8c161a0c169b9b.js 13.5 KiB [emitted] [immutable] (name: runtime~main)
asset c-main-67570433584a09b646bc.js 699 bytes [emitted] [immutable] (name: main)
asset c-main-67570433584a09b646bc.js 680 bytes [emitted] [immutable] (name: main)
asset c-vendors-node_modules_vendor_js-499179597d8c965dd5e0.js 185 bytes [emitted] [immutable] (id hint: vendors)
Entrypoint main 14.5 KiB = c-runtime~main-1f593c8c161a0c169b9b.js 13.5 KiB c-all-c_js-5a3e032792662f68ffa4.js 393 bytes c-main-67570433584a09b646bc.js 699 bytes
Entrypoint main 14.5 KiB = c-runtime~main-1f593c8c161a0c169b9b.js 13.5 KiB c-all-c_js-5a3e032792662f68ffa4.js 393 bytes c-main-67570433584a09b646bc.js 680 bytes
runtime modules 8.6 KiB 13 modules
cacheable modules 101 bytes
./c.js 61 bytes [built] [code generated]
@ -1321,14 +1321,14 @@ webpack x.x.x compiled successfully in X ms"
exports[`StatsTestCases should print correct stats for module-assets 1`] = `
"assets by path *.js 11.6 KiB
asset main.js 10.3 KiB [emitted] (name: main)
asset a.js 746 bytes [emitted] (name: a)
asset b.js 563 bytes [emitted] (name: b)
asset a.js 732 bytes [emitted] (name: a)
asset b.js 549 bytes [emitted] (name: b)
assets by path *.png 42 KiB
asset 1.png 21 KiB [emitted] [from: node_modules/a/1.png] (auxiliary name: a)
asset 2.png 21 KiB [emitted] [from: node_modules/a/2.png] (auxiliary name: a, b)
Entrypoint main 10.3 KiB = main.js
Chunk Group a 746 bytes (42 KiB) = a.js 746 bytes (1.png 21 KiB 2.png 21 KiB)
Chunk Group b 563 bytes (21 KiB) = b.js 563 bytes (2.png 21 KiB)
Chunk Group a 732 bytes (42 KiB) = a.js 732 bytes (1.png 21 KiB 2.png 21 KiB)
Chunk Group b 549 bytes (21 KiB) = b.js 549 bytes (2.png 21 KiB)
chunk (runtime: main) b.js (b) 67 bytes [rendered]
./node_modules/a/2.png 49 bytes [dependent] [built] [code generated] [1 asset]
./node_modules/b/index.js 18 bytes [built] [code generated]
@ -1353,9 +1353,9 @@ exports[`StatsTestCases should print correct stats for module-deduplication 1`]
"asset e1.js 12.1 KiB [emitted] (name: e1)
asset e2.js 12.1 KiB [emitted] (name: e2)
asset e3.js 12.1 KiB [emitted] (name: e3)
asset 172.js 866 bytes [emitted]
asset 326.js 866 bytes [emitted]
asset 923.js 866 bytes [emitted]
asset 172.js 852 bytes [emitted]
asset 326.js 852 bytes [emitted]
asset 923.js 852 bytes [emitted]
asset 114.js 518 bytes [emitted]
asset 593.js 518 bytes [emitted]
asset 716.js 518 bytes [emitted]
@ -1399,9 +1399,9 @@ exports[`StatsTestCases should print correct stats for module-deduplication-name
"asset e1.js 11.9 KiB [emitted] (name: e1)
asset e2.js 11.9 KiB [emitted] (name: e2)
asset e3.js 11.9 KiB [emitted] (name: e3)
asset async1.js 972 bytes [emitted] (name: async1)
asset async2.js 972 bytes [emitted] (name: async2)
asset async3.js 972 bytes [emitted] (name: async3)
asset async1.js 958 bytes [emitted] (name: async1)
asset async2.js 958 bytes [emitted] (name: async2)
asset async3.js 958 bytes [emitted] (name: async3)
chunk (runtime: e3) e3.js (e3) 242 bytes (javascript) 6.55 KiB (runtime) [entry] [rendered]
runtime modules 6.55 KiB 9 modules
cacheable modules 242 bytes
@ -1536,7 +1536,7 @@ exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] =
"Chunk Group main 11.6 KiB = a-main.js
Chunk Group async-a 1.07 KiB = a-52.js 257 bytes a-async-a.js 836 bytes
Chunk Group async-b 1.07 KiB = a-52.js 257 bytes a-async-b.js 836 bytes
Chunk Group async-c 1.46 KiB = a-vendors.js 758 bytes a-async-c.js 735 bytes
Chunk Group async-c 1.44 KiB = a-vendors.js 744 bytes a-async-c.js 735 bytes
chunk (runtime: main) a-52.js 149 bytes [rendered] split chunk (cache group: default)
> ./a ./index.js 1:0-47
> ./b ./index.js 2:0-47
@ -1563,7 +1563,7 @@ webpack x.x.x compiled successfully
Entrypoint main 11.6 KiB = b-main.js
Chunk Group async-a 1.07 KiB = b-52.js 257 bytes b-async-a.js 836 bytes
Chunk Group async-b 1.07 KiB = b-52.js 257 bytes b-async-b.js 836 bytes
Chunk Group async-c 1.46 KiB = b-vendors.js 758 bytes b-async-c.js 735 bytes
Chunk Group async-c 1.44 KiB = b-vendors.js 744 bytes b-async-c.js 735 bytes
chunk (runtime: main) b-52.js 149 bytes [rendered] split chunk (cache group: default)
> ./a ./index.js 1:0-47
> ./b ./index.js 2:0-47
@ -1673,8 +1673,8 @@ webpack x.x.x compiled successfully in X ms"
`;
exports[`StatsTestCases should print correct stats for output-module 1`] = `
"asset main.mjs 9.95 KiB [emitted] [javascript module] (name: main)
asset 52.mjs 417 bytes [emitted] [javascript module]
"asset main.mjs 9.93 KiB [emitted] [javascript module] (name: main)
asset 52.mjs 402 bytes [emitted] [javascript module]
runtime modules 6.01 KiB 8 modules
orphan modules 38 bytes [orphan] 1 module
cacheable modules 263 bytes
@ -2440,16 +2440,16 @@ LOG from webpack.FileSystemInfo
exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
"a-normal:
assets by path *.js 3.25 KiB
asset 7fed0aeb8386f923f54d-7fed0a.js 2.73 KiB [emitted] [immutable] [minimized] (name: runtime)
asset a639a9edc4557744bf94-a639a9.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset e00b58ce2785691cd374-e00b58.js 225 bytes [emitted] [immutable] [minimized] (name: index)
assets by path *.js 3.21 KiB
asset 09917ee8890023caf0f5-09917e.js 2.73 KiB [emitted] [immutable] [minimized] (name: runtime)
asset bcfa5bfc8402c0b00196-bcfa5b.js 262 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 48467594bc5513c4eedb-484675.js 212 bytes [emitted] [immutable] [minimized] (name: index)
asset 666f2b8847021ccc7608-666f2b.js 21 bytes [emitted] [immutable] [minimized] (name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.95 KiB (5.89 KiB) = 7fed0aeb8386f923f54d-7fed0a.js 2.73 KiB e00b58ce2785691cd374-e00b58.js 225 bytes 1 auxiliary asset
Entrypoint index 2.93 KiB (5.89 KiB) = 09917ee8890023caf0f5-09917e.js 2.73 KiB 48467594bc5513c4eedb-484675.js 212 bytes 1 auxiliary asset
Entrypoint a 21 bytes = 666f2b8847021ccc7608-666f2b.js
Entrypoint b 21 bytes = 666f2b8847021ccc7608-666f2b.js
runtime modules 7.22 KiB 9 modules
@ -2467,16 +2467,16 @@ exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
a-normal (webpack x.x.x) compiled successfully in X ms
b-normal:
assets by path *.js 3.25 KiB
asset e66bec9f6db9fd476b7e-e66bec.js 2.73 KiB [emitted] [immutable] [minimized] (name: runtime)
asset a639a9edc4557744bf94-a639a9.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset e00b58ce2785691cd374-e00b58.js 225 bytes [emitted] [immutable] [minimized] (name: index)
assets by path *.js 3.21 KiB
asset af8ab1beffb0b1746bc4-af8ab1.js 2.73 KiB [emitted] [immutable] [minimized] (name: runtime)
asset bcfa5bfc8402c0b00196-bcfa5b.js 262 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 48467594bc5513c4eedb-484675.js 212 bytes [emitted] [immutable] [minimized] (name: index)
asset 666f2b8847021ccc7608-666f2b.js 21 bytes [emitted] [immutable] [minimized] (name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.95 KiB (5.89 KiB) = e66bec9f6db9fd476b7e-e66bec.js 2.73 KiB e00b58ce2785691cd374-e00b58.js 225 bytes 1 auxiliary asset
Entrypoint index 2.93 KiB (5.89 KiB) = af8ab1beffb0b1746bc4-af8ab1.js 2.73 KiB 48467594bc5513c4eedb-484675.js 212 bytes 1 auxiliary asset
Entrypoint a 21 bytes = 666f2b8847021ccc7608-666f2b.js
Entrypoint b 21 bytes = 666f2b8847021ccc7608-666f2b.js
runtime modules 7.22 KiB 9 modules
@ -2494,20 +2494,20 @@ b-normal:
b-normal (webpack x.x.x) compiled successfully in X ms
a-source-map:
assets by path *.js 3.47 KiB
asset 6e9d99de9797b64aeabd-6e9d99.js 2.78 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 6e9d99de9797b64aeabd-6e9d99.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime)
asset 05c637d15dff2d0dc5fd-05c637.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 05c637d15dff2d0dc5fd-05c637.js.map 399 bytes [emitted] [dev] (auxiliary name: lazy)
asset c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap c41aff3dd03dbe1d8aa3-c41aff.js.map 366 bytes [emitted] [dev] (auxiliary name: index)
assets by path *.js 3.43 KiB
asset 52b51d8812dd875905ac-52b51d.js 2.78 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 52b51d8812dd875905ac-52b51d.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime)
asset ef42653d948f15f99d49-ef4265.js 318 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap ef42653d948f15f99d49-ef4265.js.map 399 bytes [emitted] [dev] (auxiliary name: lazy)
asset 131d4a1db3c1c310398f-131d4a.js 268 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap 131d4a1db3c1c310398f-131d4a.js.map 366 bytes [emitted] [dev] (auxiliary name: index)
asset 222c2acc68675174e6b2-222c2a.js 77 bytes [emitted] [immutable] [minimized] (name: a, b)
sourceMap 222c2acc68675174e6b2-222c2a.js.map 254 bytes [emitted] [dev] (auxiliary name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 3.05 KiB (20.6 KiB) = 6e9d99de9797b64aeabd-6e9d99.js 2.78 KiB c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes 3 auxiliary assets
Entrypoint index 3.04 KiB (20.6 KiB) = 52b51d8812dd875905ac-52b51d.js 2.78 KiB 131d4a1db3c1c310398f-131d4a.js 268 bytes 3 auxiliary assets
Entrypoint a 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
Entrypoint b 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
runtime modules 7.22 KiB 9 modules
@ -2525,20 +2525,20 @@ a-source-map:
a-source-map (webpack x.x.x) compiled successfully in X ms
b-source-map:
assets by path *.js 3.47 KiB
asset 6b51d6d97c29fa93a1f2-6b51d6.js 2.78 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 6b51d6d97c29fa93a1f2-6b51d6.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime)
asset 05c637d15dff2d0dc5fd-05c637.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 05c637d15dff2d0dc5fd-05c637.js.map 395 bytes [emitted] [dev] (auxiliary name: lazy)
asset c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap c41aff3dd03dbe1d8aa3-c41aff.js.map 323 bytes [emitted] [dev] (auxiliary name: index)
assets by path *.js 3.43 KiB
asset f9e1ed725383ba580c15-f9e1ed.js 2.78 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap f9e1ed725383ba580c15-f9e1ed.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime)
asset ef42653d948f15f99d49-ef4265.js 318 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap ef42653d948f15f99d49-ef4265.js.map 395 bytes [emitted] [dev] (auxiliary name: lazy)
asset 131d4a1db3c1c310398f-131d4a.js 268 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap 131d4a1db3c1c310398f-131d4a.js.map 323 bytes [emitted] [dev] (auxiliary name: index)
asset 222c2acc68675174e6b2-222c2a.js 77 bytes [emitted] [immutable] [minimized] (name: a, b)
sourceMap 222c2acc68675174e6b2-222c2a.js.map 254 bytes [emitted] [dev] (auxiliary name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 3.05 KiB (20.5 KiB) = 6b51d6d97c29fa93a1f2-6b51d6.js 2.78 KiB c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes 3 auxiliary assets
Entrypoint index 3.04 KiB (20.5 KiB) = f9e1ed725383ba580c15-f9e1ed.js 2.78 KiB 131d4a1db3c1c310398f-131d4a.js 268 bytes 3 auxiliary assets
Entrypoint a 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
Entrypoint b 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
runtime modules 7.22 KiB 9 modules
@ -2558,9 +2558,9 @@ b-source-map:
exports[`StatsTestCases should print correct stats for related-assets 1`] = `
"default:
assets by path *.js 15.2 KiB
assets by path *.js 15.1 KiB
asset default-main.js 14.4 KiB [emitted] (name: main) 3 related assets
asset default-chunk_js.js 817 bytes [emitted] 3 related assets
asset default-chunk_js.js 803 bytes [emitted] 3 related assets
assets by path *.css 142 bytes
asset default-chunk_js.css 73 bytes [emitted] 3 related assets
asset default-main.css 69 bytes [emitted] (name: main) 3 related assets
@ -2573,12 +2573,12 @@ relatedAssets:
sourceMap relatedAssets-main.js.map 12.4 KiB [emitted] [dev] (auxiliary name: main)
compressed relatedAssets-main.js.map.br 12.4 KiB [emitted]
compressed relatedAssets-main.js.map.gz 12.4 KiB [emitted]
asset relatedAssets-chunk_js.js 823 bytes [emitted]
compressed relatedAssets-chunk_js.js.br 823 bytes [emitted]
compressed relatedAssets-chunk_js.js.gz 823 bytes [emitted]
sourceMap relatedAssets-chunk_js.js.map 301 bytes [emitted] [dev]
compressed relatedAssets-chunk_js.js.map.br 301 bytes [emitted]
compressed relatedAssets-chunk_js.js.map.gz 301 bytes [emitted]
asset relatedAssets-chunk_js.js 809 bytes [emitted]
compressed relatedAssets-chunk_js.js.br 809 bytes [emitted]
compressed relatedAssets-chunk_js.js.gz 809 bytes [emitted]
sourceMap relatedAssets-chunk_js.js.map 300 bytes [emitted] [dev]
compressed relatedAssets-chunk_js.js.map.br 300 bytes [emitted]
compressed relatedAssets-chunk_js.js.map.gz 300 bytes [emitted]
assets by path *.css 154 bytes
asset relatedAssets-chunk_js.css 79 bytes [emitted]
sourceMap relatedAssets-chunk_js.css.map 202 bytes [emitted] [dev]
@ -2601,10 +2601,10 @@ exclude1:
hidden assets 24.8 KiB 2 assets
1 related asset
1 related asset
asset exclude1-chunk_js.js 818 bytes [emitted]
hidden assets 1.6 KiB 2 assets
sourceMap exclude1-chunk_js.js.map 296 bytes [emitted] [dev]
hidden assets 592 bytes 2 assets
asset exclude1-chunk_js.js 804 bytes [emitted]
hidden assets 1.57 KiB 2 assets
sourceMap exclude1-chunk_js.js.map 295 bytes [emitted] [dev]
hidden assets 590 bytes 2 assets
1 related asset
1 related asset
assets by path *.css 144 bytes
@ -2627,10 +2627,10 @@ exclude2:
hidden assets 12.4 KiB 1 asset
compressed exclude2-main.js.br 14.4 KiB [emitted]
compressed exclude2-main.js.gz 14.4 KiB [emitted]
asset exclude2-chunk_js.js 818 bytes [emitted]
hidden assets 296 bytes 1 asset
compressed exclude2-chunk_js.js.br 818 bytes [emitted]
compressed exclude2-chunk_js.js.gz 818 bytes [emitted]
asset exclude2-chunk_js.js 804 bytes [emitted]
hidden assets 295 bytes 1 asset
compressed exclude2-chunk_js.js.br 804 bytes [emitted]
compressed exclude2-chunk_js.js.gz 804 bytes [emitted]
assets by path *.css 144 bytes
asset exclude2-chunk_js.css 74 bytes [emitted]
hidden assets 197 bytes 1 asset
@ -2642,7 +2642,7 @@ exclude2:
compressed exclude2-main.css.gz 70 bytes [emitted]
exclude3:
hidden assets 892 bytes 2 assets
hidden assets 878 bytes 2 assets
assets by status 14.4 KiB [emitted]
asset exclude3-main.js 14.4 KiB [emitted] (name: main)
compressed exclude3-main.js.br 14.4 KiB [emitted]
@ -2706,17 +2706,17 @@ webpack x.x.x compiled successfully in X ms"
`;
exports[`StatsTestCases should print correct stats for runtime-chunk 1`] = `
"Entrypoint e1 6.46 KiB = runtime~e1.js 5.39 KiB e1.js 1.07 KiB
Entrypoint e2 6.46 KiB = runtime~e2.js 5.39 KiB e2.js 1.07 KiB
"Entrypoint e1 6.42 KiB = runtime~e1.js 5.39 KiB e1.js 1.04 KiB
Entrypoint e2 6.42 KiB = runtime~e2.js 5.39 KiB e2.js 1.04 KiB
webpack x.x.x compiled successfully"
`;
exports[`StatsTestCases should print correct stats for runtime-chunk-integration 1`] = `
"base:
asset without-runtime.js 12 KiB [emitted] (name: runtime)
asset without-505.js 1.22 KiB [emitted]
asset without-main1.js 848 bytes [emitted] (name: main1)
Entrypoint main1 12.8 KiB = without-runtime.js 12 KiB without-main1.js 848 bytes
asset without-505.js 1.2 KiB [emitted]
asset without-main1.js 815 bytes [emitted] (name: main1)
Entrypoint main1 12.8 KiB = without-runtime.js 12 KiB without-main1.js 815 bytes
runtime modules 7.45 KiB 10 modules
cacheable modules 126 bytes
./main1.js 66 bytes [built] [code generated]
@ -2727,13 +2727,13 @@ exports[`StatsTestCases should print correct stats for runtime-chunk-integration
static custom name:
asset with-manifest.js 12 KiB [emitted] (name: manifest)
asset with-505.js 1.22 KiB [emitted]
asset with-main1.js 848 bytes [emitted] (name: main1)
asset with-main2.js 467 bytes [emitted] (name: main2)
asset with-main3.js 467 bytes [emitted] (name: main3)
Entrypoint main1 12.8 KiB = with-manifest.js 12 KiB with-main1.js 848 bytes
Entrypoint main2 12.4 KiB = with-manifest.js 12 KiB with-main2.js 467 bytes
Entrypoint main3 12.4 KiB = with-manifest.js 12 KiB with-main3.js 467 bytes
asset with-505.js 1.2 KiB [emitted]
asset with-main1.js 815 bytes [emitted] (name: main1)
asset with-main2.js 434 bytes [emitted] (name: main2)
asset with-main3.js 434 bytes [emitted] (name: main3)
Entrypoint main1 12.8 KiB = with-manifest.js 12 KiB with-main1.js 815 bytes
Entrypoint main2 12.4 KiB = with-manifest.js 12 KiB with-main2.js 434 bytes
Entrypoint main3 12.4 KiB = with-manifest.js 12 KiB with-main3.js 434 bytes
runtime modules 7.45 KiB 10 modules
cacheable modules 166 bytes
./main1.js 66 bytes [built] [code generated]
@ -2747,13 +2747,13 @@ static custom name:
dynamic custom name:
asset func-b.js 12 KiB [emitted] (name: b)
asset func-a.js 4.83 KiB [emitted] (name: a)
asset func-505.js 1.22 KiB [emitted]
asset func-main1.js 848 bytes [emitted] (name: main1)
asset func-main2.js 467 bytes [emitted] (name: main2)
asset func-main3.js 467 bytes [emitted] (name: main3)
Entrypoint main1 12.8 KiB = func-b.js 12 KiB func-main1.js 848 bytes
Entrypoint main2 12.4 KiB = func-b.js 12 KiB func-main2.js 467 bytes
Entrypoint main3 5.28 KiB = func-a.js 4.83 KiB func-main3.js 467 bytes
asset func-505.js 1.2 KiB [emitted]
asset func-main1.js 815 bytes [emitted] (name: main1)
asset func-main2.js 434 bytes [emitted] (name: main2)
asset func-main3.js 434 bytes [emitted] (name: main3)
Entrypoint main1 12.8 KiB = func-b.js 12 KiB func-main1.js 815 bytes
Entrypoint main2 12.4 KiB = func-b.js 12 KiB func-main2.js 434 bytes
Entrypoint main3 5.25 KiB = func-a.js 4.83 KiB func-main3.js 434 bytes
runtime modules 9.84 KiB 13 modules
cacheable modules 166 bytes
./main1.js 66 bytes [built] [code generated]
@ -2766,14 +2766,14 @@ dynamic custom name:
`;
exports[`StatsTestCases should print correct stats for runtime-chunk-issue-7382 1`] = `
"Entrypoint e1 7.33 KiB = runtime.js 5.38 KiB all.js 1020 bytes e1.js 981 bytes
Entrypoint e2 7.33 KiB = runtime.js 5.38 KiB all.js 1020 bytes e2.js 981 bytes
"Entrypoint e1 7.31 KiB = runtime.js 5.38 KiB all.js 1020 bytes e1.js 962 bytes
Entrypoint e2 7.31 KiB = runtime.js 5.38 KiB all.js 1020 bytes e2.js 962 bytes
webpack x.x.x compiled successfully"
`;
exports[`StatsTestCases should print correct stats for runtime-chunk-single 1`] = `
"Entrypoint e1 6.45 KiB = runtime.js 5.38 KiB e1.js 1.07 KiB
Entrypoint e2 6.45 KiB = runtime.js 5.38 KiB e2.js 1.07 KiB
"Entrypoint e1 6.42 KiB = runtime.js 5.38 KiB e1.js 1.04 KiB
Entrypoint e2 6.42 KiB = runtime.js 5.38 KiB e2.js 1.04 KiB
webpack x.x.x compiled successfully"
`;
@ -2781,11 +2781,11 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp
"production:
asset production-a.js 13 KiB [emitted] (name: a)
asset production-b.js 13 KiB [emitted] (name: b)
asset production-dx_js.js 1.17 KiB [emitted]
asset production-dw_js-_a6170.js 1.17 KiB [emitted]
asset production-dw_js-_a6171.js 1.17 KiB [emitted]
asset production-dy_js.js 1.15 KiB [emitted]
asset production-dz_js.js 1.15 KiB [emitted]
asset production-dx_js.js 1.16 KiB [emitted]
asset production-dw_js-_a6170.js 1.16 KiB [emitted]
asset production-dw_js-_a6171.js 1.16 KiB [emitted]
asset production-dy_js.js 1.14 KiB [emitted]
asset production-dz_js.js 1.14 KiB [emitted]
asset production-c.js 93 bytes [emitted] (name: c)
chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 6.51 KiB (runtime) [entry] [rendered]
runtime modules 6.51 KiB 9 modules
@ -2863,10 +2863,10 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp
development:
asset development-a.js 15.8 KiB [emitted] (name: a)
asset development-b.js 15.8 KiB [emitted] (name: b)
asset development-dw_js.js 2.13 KiB [emitted]
asset development-dx_js.js 2.13 KiB [emitted]
asset development-dy_js.js 2.13 KiB [emitted]
asset development-dz_js.js 2.13 KiB [emitted]
asset development-dw_js.js 2.11 KiB [emitted]
asset development-dx_js.js 2.11 KiB [emitted]
asset development-dy_js.js 2.11 KiB [emitted]
asset development-dz_js.js 2.11 KiB [emitted]
asset development-c.js 1.13 KiB [emitted] (name: c)
chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 6.52 KiB (runtime) [entry] [rendered]
runtime modules 6.52 KiB 9 modules
@ -2948,10 +2948,10 @@ development:
global:
asset global-a.js 13.2 KiB [emitted] (name: a)
asset global-b.js 13.2 KiB [emitted] (name: b)
asset global-dw_js.js 1.17 KiB [emitted]
asset global-dx_js.js 1.17 KiB [emitted]
asset global-dy_js.js 1.17 KiB [emitted]
asset global-dz_js.js 1.17 KiB [emitted]
asset global-dw_js.js 1.16 KiB [emitted]
asset global-dx_js.js 1.16 KiB [emitted]
asset global-dy_js.js 1.16 KiB [emitted]
asset global-dz_js.js 1.16 KiB [emitted]
asset global-c.js 93 bytes [emitted] (name: c)
chunk (runtime: a) global-a.js (a) 605 bytes (javascript) 6.51 KiB (runtime) [entry] [rendered]
runtime modules 6.51 KiB 9 modules
@ -3398,9 +3398,9 @@ all-chunks:
manual:
Entrypoint main 11.1 KiB = manual/main.js
Entrypoint a 14.7 KiB = manual/vendors.js 1.08 KiB manual/a.js 13.6 KiB
Entrypoint b 8.38 KiB = manual/vendors.js 1.08 KiB manual/b.js 7.3 KiB
Entrypoint c 8.38 KiB = manual/vendors.js 1.08 KiB manual/c.js 7.3 KiB
Entrypoint a 14.6 KiB = manual/vendors.js 1.05 KiB manual/a.js 13.6 KiB
Entrypoint b 8.35 KiB = manual/vendors.js 1.05 KiB manual/b.js 7.3 KiB
Entrypoint c 8.35 KiB = manual/vendors.js 1.05 KiB manual/c.js 7.3 KiB
chunk (runtime: b) manual/b.js (b) 156 bytes (javascript) 2.7 KiB (runtime) ={216}= [entry] [rendered]
> ./b b
> x b
@ -3606,9 +3606,9 @@ custom-chunks-filter:
custom-chunks-filter-in-cache-groups:
Entrypoint main 11.2 KiB = custom-chunks-filter-in-cache-groups/main.js
Entrypoint a 14.5 KiB = custom-chunks-filter-in-cache-groups/176.js 892 bytes custom-chunks-filter-in-cache-groups/a.js 13.6 KiB
Entrypoint b 8.38 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.08 KiB custom-chunks-filter-in-cache-groups/b.js 7.3 KiB
Entrypoint c 8.38 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.08 KiB custom-chunks-filter-in-cache-groups/c.js 7.3 KiB
Entrypoint a 14.5 KiB = custom-chunks-filter-in-cache-groups/176.js 864 bytes custom-chunks-filter-in-cache-groups/a.js 13.6 KiB
Entrypoint b 8.36 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.05 KiB custom-chunks-filter-in-cache-groups/b.js 7.3 KiB
Entrypoint c 8.36 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.05 KiB custom-chunks-filter-in-cache-groups/c.js 7.3 KiB
chunk (runtime: b) custom-chunks-filter-in-cache-groups/b.js (b) 156 bytes (javascript) 2.7 KiB (runtime) ={216}= [entry] [rendered]
> ./b b
> x b
@ -4395,10 +4395,10 @@ webpack x.x.x compiled with 1 warning in X ms"
`;
exports[`StatsTestCases should print correct stats for wasm-explorer-examples-sync 1`] = `
"assets by path *.js 21.5 KiB
"assets by path *.js 21.4 KiB
asset bundle.js 16.1 KiB [emitted] (name: main)
asset 325.bundle.js 3.98 KiB [emitted]
asset 780.bundle.js 571 bytes [emitted]
asset 325.bundle.js 3.95 KiB [emitted]
asset 780.bundle.js 557 bytes [emitted]
asset 526.bundle.js 366 bytes [emitted] (id hint: vendors)
asset 230.bundle.js 243 bytes [emitted]
asset 99.bundle.js 241 bytes [emitted]

53
types.d.ts vendored
View File

@ -1099,6 +1099,11 @@ declare interface ChunkRenderContext {
* init fragments for the chunk
*/
chunkInitFragments: InitFragment<ChunkRenderContext>[];
/**
* rendering in strict context
*/
strictMode: boolean;
}
declare interface ChunkSizeOptions {
/**
@ -1787,7 +1792,9 @@ declare interface CompilationAssets {
[index: string]: Source;
}
declare interface CompilationHooksAsyncWebAssemblyModulesPlugin {
renderModuleContent: SyncWaterfallHook<[Source, Module, RenderContext]>;
renderModuleContent: SyncWaterfallHook<
[Source, Module, WebAssemblyRenderContext]
>;
}
declare interface CompilationHooksJavascriptModulesPlugin {
renderModuleContent: SyncWaterfallHook<[Source, Module, ChunkRenderContext]>;
@ -4517,7 +4524,7 @@ declare class JavascriptModulesPlugin {
module: Module,
renderContext: ChunkRenderContext,
hooks: CompilationHooksJavascriptModulesPlugin,
factory: boolean | "strict"
factory: boolean
): Source;
renderChunk(
renderContext: RenderContext,
@ -6132,6 +6139,11 @@ declare interface MainRenderContext {
* hash to be used for render call
*/
hash: string;
/**
* rendering in strict context
*/
strictMode: boolean;
}
declare abstract class MainTemplate {
hooks: Readonly<{
@ -8805,6 +8817,11 @@ declare interface RenderContext {
* results of code generation
*/
codeGenerationResults: CodeGenerationResults;
/**
* rendering in strict context
*/
strictMode: boolean;
}
type RenderManifestEntry =
| RenderManifestEntryTemplated
@ -11129,7 +11146,6 @@ declare class Template {
runtimeModules: RuntimeModule[],
renderContext: RenderContext & {
codeGenerationResults?: CodeGenerationResults;
useStrict?: boolean;
}
): Source;
static renderChunkRuntimeModules(
@ -11462,6 +11478,37 @@ declare abstract class Watching {
resume(): void;
close(callback: CallbackFunction<void>): void;
}
declare interface WebAssemblyRenderContext {
/**
* the chunk
*/
chunk: Chunk;
/**
* the dependency templates
*/
dependencyTemplates: DependencyTemplates;
/**
* the runtime template
*/
runtimeTemplate: RuntimeTemplate;
/**
* the module graph
*/
moduleGraph: ModuleGraph;
/**
* the chunk graph
*/
chunkGraph: ChunkGraph;
/**
* results of code generation
*/
codeGenerationResults: CodeGenerationResults;
}
declare class WebWorkerTemplatePlugin {
constructor();