webpack 5.45.0 → 5.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/bin/webpack.js +0 -0
- package/lib/NormalModule.js +10 -12
- package/lib/NormalModuleFactory.js +2 -8
- package/lib/Template.js +1 -4
- package/lib/asset/AssetGenerator.js +29 -16
- package/lib/asset/AssetModulesPlugin.js +23 -18
- package/lib/config/defaults.js +12 -18
- package/lib/dependencies/AMDRequireDependency.js +2 -8
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -6
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependency.js +1 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +5 -40
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +2 -10
- package/lib/dependencies/ModuleDependency.js +1 -8
- package/lib/hmr/HotModuleReplacement.runtime.js +66 -60
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -8
- package/lib/javascript/JavascriptModulesPlugin.js +51 -30
- package/lib/javascript/JavascriptParser.js +9 -14
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -4
- package/lib/rules/{ObjectMatcherRulePlugin.js → DescriptionDataMatcherRulePlugin.js} +10 -14
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +5 -1
- package/lib/schemes/DataUriPlugin.js +7 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +32 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +6 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +51 -9
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
- package/package.json +2 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +8 -7
- package/types.d.ts +68 -41
@@ -9,6 +9,7 @@ var $interceptModuleExecution$ = undefined;
|
|
9
9
|
var $moduleCache$ = undefined;
|
10
10
|
// eslint-disable-next-line no-unused-vars
|
11
11
|
var $hmrModuleData$ = undefined;
|
12
|
+
/** @type {() => Promise} */
|
12
13
|
var $hmrDownloadManifest$ = undefined;
|
13
14
|
var $hmrDownloadUpdateHandlers$ = undefined;
|
14
15
|
var $hmrInvalidateModuleHandlers$ = undefined;
|
@@ -209,8 +210,12 @@ module.exports = function () {
|
|
209
210
|
|
210
211
|
function setStatus(newStatus) {
|
211
212
|
currentStatus = newStatus;
|
213
|
+
var results = [];
|
214
|
+
|
212
215
|
for (var i = 0; i < registeredStatusHandlers.length; i++)
|
213
|
-
registeredStatusHandlers[i].call(null, newStatus);
|
216
|
+
results[i] = registeredStatusHandlers[i].call(null, newStatus);
|
217
|
+
|
218
|
+
return Promise.all(results);
|
214
219
|
}
|
215
220
|
|
216
221
|
function trackBlockingPromise(promise) {
|
@@ -219,7 +224,7 @@ module.exports = function () {
|
|
219
224
|
setStatus("prepare");
|
220
225
|
blockingPromises.push(promise);
|
221
226
|
waitForBlockingPromises(function () {
|
222
|
-
setStatus("ready");
|
227
|
+
return setStatus("ready");
|
223
228
|
});
|
224
229
|
return promise;
|
225
230
|
case "prepare":
|
@@ -243,47 +248,47 @@ module.exports = function () {
|
|
243
248
|
if (currentStatus !== "idle") {
|
244
249
|
throw new Error("check() is only allowed in idle status");
|
245
250
|
}
|
246
|
-
setStatus("check")
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
setStatus("prepare");
|
254
|
-
|
255
|
-
var updatedModules = [];
|
256
|
-
blockingPromises = [];
|
257
|
-
currentUpdateApplyHandlers = [];
|
258
|
-
|
259
|
-
return Promise.all(
|
260
|
-
Object.keys($hmrDownloadUpdateHandlers$).reduce(function (
|
261
|
-
promises,
|
262
|
-
key
|
263
|
-
) {
|
264
|
-
$hmrDownloadUpdateHandlers$[key](
|
265
|
-
update.c,
|
266
|
-
update.r,
|
267
|
-
update.m,
|
268
|
-
promises,
|
269
|
-
currentUpdateApplyHandlers,
|
270
|
-
updatedModules
|
271
|
-
);
|
272
|
-
return promises;
|
273
|
-
},
|
274
|
-
[])
|
275
|
-
).then(function () {
|
276
|
-
return waitForBlockingPromises(function () {
|
277
|
-
if (applyOnUpdate) {
|
278
|
-
return internalApply(applyOnUpdate);
|
279
|
-
} else {
|
280
|
-
setStatus("ready");
|
251
|
+
return setStatus("check")
|
252
|
+
.then($hmrDownloadManifest$)
|
253
|
+
.then(function (update) {
|
254
|
+
if (!update) {
|
255
|
+
return setStatus(applyInvalidatedModules() ? "ready" : "idle");
|
256
|
+
}
|
281
257
|
|
282
|
-
|
283
|
-
|
258
|
+
return setStatus("prepare").then(function () {
|
259
|
+
var updatedModules = [];
|
260
|
+
blockingPromises = [];
|
261
|
+
currentUpdateApplyHandlers = [];
|
262
|
+
|
263
|
+
return Promise.all(
|
264
|
+
Object.keys($hmrDownloadUpdateHandlers$).reduce(function (
|
265
|
+
promises,
|
266
|
+
key
|
267
|
+
) {
|
268
|
+
$hmrDownloadUpdateHandlers$[key](
|
269
|
+
update.c,
|
270
|
+
update.r,
|
271
|
+
update.m,
|
272
|
+
promises,
|
273
|
+
currentUpdateApplyHandlers,
|
274
|
+
updatedModules
|
275
|
+
);
|
276
|
+
return promises;
|
277
|
+
},
|
278
|
+
[])
|
279
|
+
).then(function () {
|
280
|
+
return waitForBlockingPromises(function () {
|
281
|
+
if (applyOnUpdate) {
|
282
|
+
return internalApply(applyOnUpdate);
|
283
|
+
} else {
|
284
|
+
return setStatus("ready").then(function () {
|
285
|
+
return updatedModules;
|
286
|
+
});
|
287
|
+
}
|
288
|
+
});
|
289
|
+
});
|
284
290
|
});
|
285
291
|
});
|
286
|
-
});
|
287
292
|
}
|
288
293
|
|
289
294
|
function hotApply(options) {
|
@@ -312,21 +317,20 @@ module.exports = function () {
|
|
312
317
|
.filter(Boolean);
|
313
318
|
|
314
319
|
if (errors.length > 0) {
|
315
|
-
setStatus("abort")
|
316
|
-
return Promise.resolve().then(function () {
|
320
|
+
return setStatus("abort").then(function () {
|
317
321
|
throw errors[0];
|
318
322
|
});
|
319
323
|
}
|
320
324
|
|
321
325
|
// Now in "dispose" phase
|
322
|
-
setStatus("dispose");
|
326
|
+
var disposePromise = setStatus("dispose");
|
323
327
|
|
324
328
|
results.forEach(function (result) {
|
325
329
|
if (result.dispose) result.dispose();
|
326
330
|
});
|
327
331
|
|
328
332
|
// Now in "apply" phase
|
329
|
-
setStatus("apply");
|
333
|
+
var applyPromise = setStatus("apply");
|
330
334
|
|
331
335
|
var error;
|
332
336
|
var reportError = function (err) {
|
@@ -345,25 +349,27 @@ module.exports = function () {
|
|
345
349
|
}
|
346
350
|
});
|
347
351
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
352
|
+
return Promise.all([disposePromise, applyPromise]).then(function () {
|
353
|
+
// handle errors in accept handlers and self accepted module load
|
354
|
+
if (error) {
|
355
|
+
return setStatus("fail").then(function () {
|
356
|
+
throw error;
|
357
|
+
});
|
358
|
+
}
|
355
359
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
+
if (queuedInvalidatedModules) {
|
361
|
+
return internalApply(options).then(function (list) {
|
362
|
+
outdatedModules.forEach(function (moduleId) {
|
363
|
+
if (list.indexOf(moduleId) < 0) list.push(moduleId);
|
364
|
+
});
|
365
|
+
return list;
|
360
366
|
});
|
361
|
-
|
362
|
-
});
|
363
|
-
}
|
367
|
+
}
|
364
368
|
|
365
|
-
|
366
|
-
|
369
|
+
return setStatus("idle").then(function () {
|
370
|
+
return outdatedModules;
|
371
|
+
});
|
372
|
+
});
|
367
373
|
}
|
368
374
|
|
369
375
|
function applyInvalidatedModules() {
|
@@ -82,23 +82,17 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
82
82
|
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
83
83
|
);
|
84
84
|
if (runtimeModules.length > 0 || entries.length > 0) {
|
85
|
-
const strictBailout =
|
86
|
-
hooks.strictRuntimeBailout.call(renderContext);
|
87
85
|
const runtime = new ConcatSource(
|
88
86
|
(runtimeTemplate.supportsArrowFunction()
|
89
87
|
? "__webpack_require__ =>"
|
90
88
|
: "function(__webpack_require__)") +
|
91
|
-
" { // webpackRuntimeModules\n"
|
92
|
-
strictBailout
|
93
|
-
? `// runtime can't be in strict mode because ${strictBailout}.\n\n`
|
94
|
-
: '"use strict";\n\n'
|
89
|
+
" { // webpackRuntimeModules\n"
|
95
90
|
);
|
96
91
|
if (runtimeModules.length > 0) {
|
97
92
|
runtime.add(
|
98
93
|
Template.renderRuntimeModules(runtimeModules, {
|
99
94
|
...renderContext,
|
100
|
-
codeGenerationResults: compilation.codeGenerationResults
|
101
|
-
useStrict: !!strictBailout
|
95
|
+
codeGenerationResults: compilation.codeGenerationResults
|
102
96
|
})
|
103
97
|
);
|
104
98
|
}
|
@@ -72,6 +72,7 @@ const printGeneratedCodeForStack = (module, code) => {
|
|
72
72
|
* @property {ModuleGraph} moduleGraph the module graph
|
73
73
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
74
74
|
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
75
|
+
* @property {boolean} strictMode rendering in strict context
|
75
76
|
*/
|
76
77
|
|
77
78
|
/**
|
@@ -83,6 +84,7 @@ const printGeneratedCodeForStack = (module, code) => {
|
|
83
84
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
84
85
|
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
85
86
|
* @property {string} hash hash to be used for render call
|
87
|
+
* @property {boolean} strictMode rendering in strict context
|
86
88
|
*/
|
87
89
|
|
88
90
|
/**
|
@@ -94,6 +96,7 @@ const printGeneratedCodeForStack = (module, code) => {
|
|
94
96
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
95
97
|
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
96
98
|
* @property {InitFragment<ChunkRenderContext>[]} chunkInitFragments init fragments for the chunk
|
99
|
+
* @property {boolean} strictMode rendering in strict context
|
97
100
|
*/
|
98
101
|
|
99
102
|
/**
|
@@ -256,7 +259,8 @@ class JavascriptModulesPlugin {
|
|
256
259
|
runtimeTemplate,
|
257
260
|
moduleGraph,
|
258
261
|
chunkGraph,
|
259
|
-
codeGenerationResults
|
262
|
+
codeGenerationResults,
|
263
|
+
strictMode: runtimeTemplate.isModule()
|
260
264
|
},
|
261
265
|
hooks
|
262
266
|
);
|
@@ -270,7 +274,8 @@ class JavascriptModulesPlugin {
|
|
270
274
|
runtimeTemplate,
|
271
275
|
moduleGraph,
|
272
276
|
chunkGraph,
|
273
|
-
codeGenerationResults
|
277
|
+
codeGenerationResults,
|
278
|
+
strictMode: runtimeTemplate.isModule()
|
274
279
|
},
|
275
280
|
hooks,
|
276
281
|
compilation
|
@@ -288,7 +293,8 @@ class JavascriptModulesPlugin {
|
|
288
293
|
runtimeTemplate,
|
289
294
|
moduleGraph,
|
290
295
|
chunkGraph,
|
291
|
-
codeGenerationResults
|
296
|
+
codeGenerationResults,
|
297
|
+
strictMode: runtimeTemplate.isModule()
|
292
298
|
},
|
293
299
|
hooks
|
294
300
|
);
|
@@ -478,12 +484,17 @@ class JavascriptModulesPlugin {
|
|
478
484
|
* @param {Module} module the rendered module
|
479
485
|
* @param {ChunkRenderContext} renderContext options object
|
480
486
|
* @param {CompilationHooks} hooks hooks
|
481
|
-
* @param {boolean
|
487
|
+
* @param {boolean} factory true: renders as factory method, false: pure module content
|
482
488
|
* @returns {Source} the newly generated source from rendering
|
483
489
|
*/
|
484
490
|
renderModule(module, renderContext, hooks, factory) {
|
485
|
-
const {
|
486
|
-
|
491
|
+
const {
|
492
|
+
chunk,
|
493
|
+
chunkGraph,
|
494
|
+
runtimeTemplate,
|
495
|
+
codeGenerationResults,
|
496
|
+
strictMode
|
497
|
+
} = renderContext;
|
487
498
|
try {
|
488
499
|
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
|
489
500
|
const moduleSource = codeGenResult.sources.get("javascript");
|
@@ -514,7 +525,7 @@ class JavascriptModulesPlugin {
|
|
514
525
|
const needThisAsExports = runtimeRequirements.has(
|
515
526
|
RuntimeGlobals.thisAsExports
|
516
527
|
);
|
517
|
-
const needStrict = module.buildInfo.strict &&
|
528
|
+
const needStrict = module.buildInfo.strict && !strictMode;
|
518
529
|
const cacheEntry = this._moduleFactoryCache.get(
|
519
530
|
moduleSourcePostContent
|
520
531
|
);
|
@@ -598,16 +609,25 @@ class JavascriptModulesPlugin {
|
|
598
609
|
"javascript",
|
599
610
|
compareModulesByIdentifier
|
600
611
|
);
|
612
|
+
const allModules = modules ? Array.from(modules) : [];
|
613
|
+
let strictHeader;
|
614
|
+
let allStrict = renderContext.strictMode;
|
615
|
+
if (!allStrict && allModules.every(m => m.buildInfo.strict)) {
|
616
|
+
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
|
617
|
+
strictHeader = strictBailout
|
618
|
+
? `// runtime can't be in strict mode because ${strictBailout}.\n`
|
619
|
+
: '"use strict";\n';
|
620
|
+
if (!strictBailout) allStrict = true;
|
621
|
+
}
|
601
622
|
/** @type {ChunkRenderContext} */
|
602
623
|
const chunkRenderContext = {
|
603
624
|
...renderContext,
|
604
|
-
chunkInitFragments: []
|
625
|
+
chunkInitFragments: [],
|
626
|
+
strictMode: allStrict
|
605
627
|
};
|
606
628
|
const moduleSources =
|
607
|
-
Template.renderChunkModules(
|
608
|
-
chunkRenderContext,
|
609
|
-
modules ? Array.from(modules) : [],
|
610
|
-
module => this.renderModule(module, chunkRenderContext, hooks, true)
|
629
|
+
Template.renderChunkModules(chunkRenderContext, allModules, module =>
|
630
|
+
this.renderModule(module, chunkRenderContext, hooks, true)
|
611
631
|
) || new RawSource("{}");
|
612
632
|
let source = tryRunOrWebpackError(
|
613
633
|
() => hooks.renderChunk.call(moduleSources, chunkRenderContext),
|
@@ -637,7 +657,11 @@ class JavascriptModulesPlugin {
|
|
637
657
|
);
|
638
658
|
}
|
639
659
|
chunk.rendered = true;
|
640
|
-
return
|
660
|
+
return strictHeader
|
661
|
+
? new ConcatSource(strictHeader, source, ";")
|
662
|
+
: renderContext.runtimeTemplate.isModule()
|
663
|
+
? source
|
664
|
+
: new ConcatSource(source, ";");
|
641
665
|
}
|
642
666
|
|
643
667
|
/**
|
@@ -649,12 +673,6 @@ class JavascriptModulesPlugin {
|
|
649
673
|
renderMain(renderContext, hooks, compilation) {
|
650
674
|
const { chunk, chunkGraph, runtimeTemplate } = renderContext;
|
651
675
|
|
652
|
-
/** @type {ChunkRenderContext} */
|
653
|
-
const chunkRenderContext = {
|
654
|
-
...renderContext,
|
655
|
-
chunkInitFragments: []
|
656
|
-
};
|
657
|
-
|
658
676
|
const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);
|
659
677
|
const iife = runtimeTemplate.isIIFE();
|
660
678
|
|
@@ -687,8 +705,8 @@ class JavascriptModulesPlugin {
|
|
687
705
|
} else {
|
688
706
|
prefix = "/******/ ";
|
689
707
|
}
|
690
|
-
let allStrict =
|
691
|
-
if (allModules.every(m => m.buildInfo.strict)) {
|
708
|
+
let allStrict = renderContext.strictMode;
|
709
|
+
if (!allStrict && allModules.every(m => m.buildInfo.strict)) {
|
692
710
|
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
|
693
711
|
if (strictBailout) {
|
694
712
|
source.add(
|
@@ -701,18 +719,19 @@ class JavascriptModulesPlugin {
|
|
701
719
|
}
|
702
720
|
}
|
703
721
|
|
722
|
+
/** @type {ChunkRenderContext} */
|
723
|
+
const chunkRenderContext = {
|
724
|
+
...renderContext,
|
725
|
+
chunkInitFragments: [],
|
726
|
+
strictMode: allStrict
|
727
|
+
};
|
728
|
+
|
704
729
|
const chunkModules = Template.renderChunkModules(
|
705
730
|
chunkRenderContext,
|
706
731
|
inlinedModules
|
707
732
|
? allModules.filter(m => !inlinedModules.has(m))
|
708
733
|
: allModules,
|
709
|
-
module =>
|
710
|
-
this.renderModule(
|
711
|
-
module,
|
712
|
-
chunkRenderContext,
|
713
|
-
hooks,
|
714
|
-
allStrict ? "strict" : true
|
715
|
-
),
|
734
|
+
module => this.renderModule(module, chunkRenderContext, hooks, true),
|
716
735
|
prefix
|
717
736
|
);
|
718
737
|
if (
|
@@ -751,7 +770,7 @@ class JavascriptModulesPlugin {
|
|
751
770
|
source.add(
|
752
771
|
new PrefixSource(
|
753
772
|
prefix,
|
754
|
-
Template.renderRuntimeModules(runtimeModules,
|
773
|
+
Template.renderRuntimeModules(runtimeModules, chunkRenderContext)
|
755
774
|
)
|
756
775
|
);
|
757
776
|
source.add(
|
@@ -834,7 +853,9 @@ class JavascriptModulesPlugin {
|
|
834
853
|
}
|
835
854
|
}
|
836
855
|
if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
|
837
|
-
startupSource.add(
|
856
|
+
startupSource.add(
|
857
|
+
`__webpack_exports__ = ${RuntimeGlobals.onChunksLoaded}(__webpack_exports__);\n`
|
858
|
+
);
|
838
859
|
}
|
839
860
|
source.add(
|
840
861
|
hooks.renderStartup.call(startupSource, lastInlinedModule, {
|
@@ -6,7 +6,6 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const { Parser: AcornParser } = require("acorn");
|
9
|
-
const { importAssertions } = require("acorn-import-assertions");
|
10
9
|
const { SyncBailHook, HookMap } = require("tapable");
|
11
10
|
const vm = require("vm");
|
12
11
|
const Parser = require("../Parser");
|
@@ -43,10 +42,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
43
42
|
/** @typedef {import("estree").Node} AnyNode */
|
44
43
|
/** @typedef {import("estree").Program} ProgramNode */
|
45
44
|
/** @typedef {import("estree").Statement} StatementNode */
|
46
|
-
/** @typedef {import("estree").ImportDeclaration} ImportDeclarationNode */
|
47
|
-
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclarationNode */
|
48
|
-
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclarationNode */
|
49
|
-
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclarationNode */
|
50
45
|
/** @typedef {import("estree").Super} SuperNode */
|
51
46
|
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpressionNode */
|
52
47
|
/** @typedef {import("estree").TemplateLiteral} TemplateLiteralNode */
|
@@ -66,7 +61,7 @@ const ALLOWED_MEMBER_TYPES_ALL = 0b11;
|
|
66
61
|
|
67
62
|
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
|
68
63
|
|
69
|
-
const parser = AcornParser
|
64
|
+
const parser = AcornParser;
|
70
65
|
|
71
66
|
class VariableInfo {
|
72
67
|
/**
|
@@ -195,31 +190,31 @@ class JavascriptParser extends Parser {
|
|
195
190
|
]),
|
196
191
|
/** @type {HookMap<SyncBailHook<[LabeledStatementNode], boolean | void>>} */
|
197
192
|
label: new HookMap(() => new SyncBailHook(["statement"])),
|
198
|
-
/** @type {SyncBailHook<[
|
193
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource], boolean | void>} */
|
199
194
|
import: new SyncBailHook(["statement", "source"]),
|
200
|
-
/** @type {SyncBailHook<[
|
195
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource, string, string], boolean | void>} */
|
201
196
|
importSpecifier: new SyncBailHook([
|
202
197
|
"statement",
|
203
198
|
"source",
|
204
199
|
"exportName",
|
205
200
|
"identifierName"
|
206
201
|
]),
|
207
|
-
/** @type {SyncBailHook<[
|
202
|
+
/** @type {SyncBailHook<[StatementNode], boolean | void>} */
|
208
203
|
export: new SyncBailHook(["statement"]),
|
209
|
-
/** @type {SyncBailHook<[
|
204
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource], boolean | void>} */
|
210
205
|
exportImport: new SyncBailHook(["statement", "source"]),
|
211
|
-
/** @type {SyncBailHook<[
|
206
|
+
/** @type {SyncBailHook<[StatementNode, DeclarationNode], boolean | void>} */
|
212
207
|
exportDeclaration: new SyncBailHook(["statement", "declaration"]),
|
213
|
-
/** @type {SyncBailHook<[
|
208
|
+
/** @type {SyncBailHook<[StatementNode, DeclarationNode], boolean | void>} */
|
214
209
|
exportExpression: new SyncBailHook(["statement", "declaration"]),
|
215
|
-
/** @type {SyncBailHook<[
|
210
|
+
/** @type {SyncBailHook<[StatementNode, string, string, number | undefined], boolean | void>} */
|
216
211
|
exportSpecifier: new SyncBailHook([
|
217
212
|
"statement",
|
218
213
|
"identifierName",
|
219
214
|
"exportName",
|
220
215
|
"index"
|
221
216
|
]),
|
222
|
-
/** @type {SyncBailHook<[
|
217
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource, string, string, number | undefined], boolean | void>} */
|
223
218
|
exportImportSpecifier: new SyncBailHook([
|
224
219
|
"statement",
|
225
220
|
"source",
|
@@ -32,16 +32,17 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
|
|
32
32
|
`${RuntimeGlobals.onChunksLoaded}(0, ${JSON.stringify(
|
33
33
|
// This need to include itself to delay execution after this chunk has been fully loaded
|
34
34
|
onChunks.filter(c => c === chunk).map(c => c.id)
|
35
|
-
)}, ${runtimeTemplate.
|
35
|
+
)}, ${runtimeTemplate.basicFunction(
|
36
|
+
"",
|
36
37
|
chunks.size < 3
|
37
38
|
? Array.from(
|
38
39
|
chunks,
|
39
40
|
c =>
|
40
|
-
`${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)})
|
41
|
-
)
|
41
|
+
`${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)});`
|
42
|
+
)
|
42
43
|
: `${JSON.stringify(Array.from(chunks, c => c.id))}.map(${
|
43
44
|
RuntimeGlobals.prefetchChunk
|
44
|
-
})
|
45
|
+
});`
|
45
46
|
)}, 5);`
|
46
47
|
)
|
47
48
|
);
|
@@ -8,32 +8,28 @@
|
|
8
8
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
9
9
|
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
10
10
|
|
11
|
-
|
12
|
-
constructor(ruleProperty, dataProperty) {
|
13
|
-
this.ruleProperty = ruleProperty;
|
14
|
-
this.dataProperty = dataProperty || ruleProperty;
|
15
|
-
}
|
11
|
+
const RULE_PROPERTY = "descriptionData";
|
16
12
|
|
13
|
+
class DescriptionDataMatcherRulePlugin {
|
17
14
|
/**
|
18
15
|
* @param {RuleSetCompiler} ruleSetCompiler the rule set compiler
|
19
16
|
* @returns {void}
|
20
17
|
*/
|
21
18
|
apply(ruleSetCompiler) {
|
22
|
-
const { ruleProperty, dataProperty } = this;
|
23
19
|
ruleSetCompiler.hooks.rule.tap(
|
24
|
-
"
|
20
|
+
"DescriptionDataMatcherRulePlugin",
|
25
21
|
(path, rule, unhandledProperties, result) => {
|
26
|
-
if (unhandledProperties.has(
|
27
|
-
unhandledProperties.delete(
|
28
|
-
const value = rule[
|
22
|
+
if (unhandledProperties.has(RULE_PROPERTY)) {
|
23
|
+
unhandledProperties.delete(RULE_PROPERTY);
|
24
|
+
const value = rule[RULE_PROPERTY];
|
29
25
|
for (const property of Object.keys(value)) {
|
30
|
-
const
|
26
|
+
const dataProperty = property.split(".");
|
31
27
|
const condition = ruleSetCompiler.compileCondition(
|
32
|
-
`${path}.${
|
28
|
+
`${path}.${RULE_PROPERTY}.${property}`,
|
33
29
|
value[property]
|
34
30
|
);
|
35
31
|
result.conditions.push({
|
36
|
-
property: [
|
32
|
+
property: ["descriptionData", ...dataProperty],
|
37
33
|
matchWhenEmpty: condition.matchWhenEmpty,
|
38
34
|
fn: condition.fn
|
39
35
|
});
|
@@ -44,4 +40,4 @@ class ObjectMatcherRulePlugin {
|
|
44
40
|
}
|
45
41
|
}
|
46
42
|
|
47
|
-
module.exports =
|
43
|
+
module.exports = DescriptionDataMatcherRulePlugin;
|
@@ -58,7 +58,11 @@ class OnChunksLoadedRuntimeModule extends RuntimeModule {
|
|
58
58
|
]),
|
59
59
|
"}",
|
60
60
|
"if(fulfilled) {",
|
61
|
-
Template.indent([
|
61
|
+
Template.indent([
|
62
|
+
"deferred.splice(i--, 1)",
|
63
|
+
"var r = fn();",
|
64
|
+
"if (r !== undefined) result = r;"
|
65
|
+
]),
|
62
66
|
"}"
|
63
67
|
]),
|
64
68
|
"}",
|
@@ -11,15 +11,14 @@ const NormalModule = require("../NormalModule");
|
|
11
11
|
|
12
12
|
// data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string"
|
13
13
|
// http://www.ietf.org/rfc/rfc2397.txt
|
14
|
-
const URIRegEx = /^data:(
|
15
|
-
const URIMetaRegEx = /^data:([^;,]+)?(?:(?:;[^;,]+)*?)(?:;(base64))?,/i;
|
14
|
+
const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64))?,(.*)$/i;
|
16
15
|
|
17
16
|
const decodeDataURI = uri => {
|
18
17
|
const match = URIRegEx.exec(uri);
|
19
18
|
if (!match) return null;
|
20
19
|
|
21
|
-
const isBase64 = match[
|
22
|
-
const body = match[
|
20
|
+
const isBase64 = match[3];
|
21
|
+
const body = match[4];
|
23
22
|
return isBase64
|
24
23
|
? Buffer.from(body, "base64")
|
25
24
|
: Buffer.from(decodeURIComponent(body), "ascii");
|
@@ -38,10 +37,12 @@ class DataUriPlugin {
|
|
38
37
|
normalModuleFactory.hooks.resolveForScheme
|
39
38
|
.for("data")
|
40
39
|
.tap("DataUriPlugin", resourceData => {
|
41
|
-
const match =
|
40
|
+
const match = URIRegEx.exec(resourceData.resource);
|
42
41
|
if (match) {
|
43
42
|
resourceData.data.mimetype = match[1] || "";
|
44
|
-
resourceData.data.
|
43
|
+
resourceData.data.parameters = match[2] || "";
|
44
|
+
resourceData.data.encoding = match[3] || false;
|
45
|
+
resourceData.data.encodedContent = match[4] || "";
|
45
46
|
}
|
46
47
|
});
|
47
48
|
NormalModule.getCompilationHooks(compilation)
|
@@ -1182,11 +1182,14 @@ const SIMPLE_EXTRACTORS = {
|
|
1182
1182
|
type,
|
1183
1183
|
compilation: { moduleGraph }
|
1184
1184
|
} = context;
|
1185
|
-
|
1185
|
+
const groupsReasons = factory.create(
|
1186
1186
|
`${type.slice(0, -8)}.reasons`,
|
1187
1187
|
Array.from(moduleGraph.getIncomingConnections(module)),
|
1188
1188
|
context
|
1189
1189
|
);
|
1190
|
+
const limited = spaceLimited(groupsReasons, options.reasonsSpace);
|
1191
|
+
object.reasons = limited.children;
|
1192
|
+
object.filteredReasons = limited.filteredChildren;
|
1190
1193
|
},
|
1191
1194
|
usedExports: (
|
1192
1195
|
object,
|
@@ -1764,6 +1767,16 @@ const moduleGroup = (children, modules) => {
|
|
1764
1767
|
};
|
1765
1768
|
};
|
1766
1769
|
|
1770
|
+
const reasonGroup = (children, reasons) => {
|
1771
|
+
let active = false;
|
1772
|
+
for (const reason of children) {
|
1773
|
+
active = active || reason.active;
|
1774
|
+
}
|
1775
|
+
return {
|
1776
|
+
active
|
1777
|
+
};
|
1778
|
+
};
|
1779
|
+
|
1767
1780
|
/** @type {Record<string, (groupConfigs: GroupConfig[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} */
|
1768
1781
|
const ASSETS_GROUPERS = {
|
1769
1782
|
_: (groupConfigs, context, options) => {
|
@@ -2074,7 +2087,24 @@ const RESULT_GROUPERS = {
|
|
2074
2087
|
"compilation.modules": MODULES_GROUPERS("module"),
|
2075
2088
|
"chunk.modules": MODULES_GROUPERS("chunk"),
|
2076
2089
|
"chunk.rootModules": MODULES_GROUPERS("root-of-chunk"),
|
2077
|
-
"module.modules": MODULES_GROUPERS("nested")
|
2090
|
+
"module.modules": MODULES_GROUPERS("nested"),
|
2091
|
+
"module.reasons": {
|
2092
|
+
groupReasonsByOrigin: groupConfigs => {
|
2093
|
+
groupConfigs.push({
|
2094
|
+
getKeys: reason => {
|
2095
|
+
return [reason.module];
|
2096
|
+
},
|
2097
|
+
createGroup: (key, children, reasons) => {
|
2098
|
+
return {
|
2099
|
+
type: "from origin",
|
2100
|
+
module: key,
|
2101
|
+
children,
|
2102
|
+
...reasonGroup(children, reasons)
|
2103
|
+
};
|
2104
|
+
}
|
2105
|
+
});
|
2106
|
+
}
|
2107
|
+
}
|
2078
2108
|
};
|
2079
2109
|
|
2080
2110
|
// remove a prefixed "!" that can be specified to reverse sort order
|
@@ -50,6 +50,7 @@ const NAMED_PRESETS = {
|
|
50
50
|
modulesSpace: Infinity,
|
51
51
|
chunkModulesSpace: Infinity,
|
52
52
|
assetsSpace: Infinity,
|
53
|
+
reasonsSpace: Infinity,
|
53
54
|
children: true
|
54
55
|
},
|
55
56
|
detailed: {
|
@@ -72,8 +73,9 @@ const NAMED_PRESETS = {
|
|
72
73
|
logging: true,
|
73
74
|
runtimeModules: true,
|
74
75
|
exclude: false,
|
75
|
-
modulesSpace:
|
76
|
-
assetsSpace:
|
76
|
+
modulesSpace: 1000,
|
77
|
+
assetsSpace: 1000,
|
78
|
+
reasonsSpace: 1000
|
77
79
|
},
|
78
80
|
minimal: {
|
79
81
|
all: false,
|
@@ -194,6 +196,8 @@ const DEFAULTS = {
|
|
194
196
|
depth: OFF_FOR_TO_STRING,
|
195
197
|
cachedAssets: OFF_FOR_TO_STRING,
|
196
198
|
reasons: OFF_FOR_TO_STRING,
|
199
|
+
reasonsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
|
200
|
+
groupReasonsByOrigin: ON_FOR_TO_STRING,
|
197
201
|
usedExports: OFF_FOR_TO_STRING,
|
198
202
|
providedExports: OFF_FOR_TO_STRING,
|
199
203
|
optimizationBailout: OFF_FOR_TO_STRING,
|