webpack 5.71.0 → 5.72.0
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/lib/BannerPlugin.js +3 -1
- package/lib/ChunkGraph.js +93 -6
- package/lib/ExportsInfo.js +1 -1
- package/lib/Module.js +1 -0
- package/lib/NormalModule.js +3 -2
- package/lib/asset/AssetGenerator.js +36 -9
- package/lib/asset/AssetParser.js +1 -0
- package/lib/asset/AssetSourceGenerator.js +31 -6
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +8 -4
- package/lib/container/RemoteRuntimeModule.js +8 -7
- package/lib/optimize/ConcatenatedModule.js +2 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +20 -1
- package/package.json +1 -1
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/types.d.ts +17 -0
package/lib/BannerPlugin.js
CHANGED
@@ -106,7 +106,9 @@ class BannerPlugin {
|
|
106
106
|
compilation.updateAsset(file, old => {
|
107
107
|
let cached = cache.get(old);
|
108
108
|
if (!cached || cached.comment !== comment) {
|
109
|
-
const source =
|
109
|
+
const source = options.footer
|
110
|
+
? new ConcatSource(old, "\n", comment)
|
111
|
+
: new ConcatSource(comment, "\n", old);
|
110
112
|
cache.set(old, { source, comment });
|
111
113
|
return source;
|
112
114
|
}
|
package/lib/ChunkGraph.js
CHANGED
@@ -85,14 +85,17 @@ const getModuleRuntimes = chunks => {
|
|
85
85
|
};
|
86
86
|
|
87
87
|
/**
|
88
|
-
* @param {
|
89
|
-
* @returns {Map<string, SortableSet<Module>>} modules by source type
|
88
|
+
* @param {WeakMap<Module, Set<string>> | undefined} sourceTypesByModule sourceTypesByModule
|
89
|
+
* @returns {function (SortableSet<Module>): Map<string, SortableSet<Module>>} modules by source type
|
90
90
|
*/
|
91
|
-
const modulesBySourceType = set => {
|
91
|
+
const modulesBySourceType = sourceTypesByModule => set => {
|
92
92
|
/** @type {Map<string, SortableSet<Module>>} */
|
93
93
|
const map = new Map();
|
94
94
|
for (const module of set) {
|
95
|
-
|
95
|
+
const sourceTypes =
|
96
|
+
(sourceTypesByModule && sourceTypesByModule.get(module)) ||
|
97
|
+
module.getSourceTypes();
|
98
|
+
for (const sourceType of sourceTypes) {
|
96
99
|
let innerSet = map.get(sourceType);
|
97
100
|
if (innerSet === undefined) {
|
98
101
|
innerSet = new SortableSet();
|
@@ -110,6 +113,7 @@ const modulesBySourceType = set => {
|
|
110
113
|
}
|
111
114
|
return map;
|
112
115
|
};
|
116
|
+
const defaultModulesBySourceType = modulesBySourceType(undefined);
|
113
117
|
|
114
118
|
/** @type {WeakMap<Function, any>} */
|
115
119
|
const createOrderedArrayFunctionMap = new WeakMap();
|
@@ -201,6 +205,8 @@ class ChunkGraphChunk {
|
|
201
205
|
constructor() {
|
202
206
|
/** @type {SortableSet<Module>} */
|
203
207
|
this.modules = new SortableSet();
|
208
|
+
/** @type {WeakMap<Module, Set<string>> | undefined} */
|
209
|
+
this.sourceTypesByModule = undefined;
|
204
210
|
/** @type {Map<Module, Entrypoint>} */
|
205
211
|
this.entryModules = new Map();
|
206
212
|
/** @type {SortableSet<RuntimeModule>} */
|
@@ -213,6 +219,8 @@ class ChunkGraphChunk {
|
|
213
219
|
this.runtimeRequirements = undefined;
|
214
220
|
/** @type {Set<string>} */
|
215
221
|
this.runtimeRequirementsInTree = new Set();
|
222
|
+
|
223
|
+
this._modulesBySourceType = defaultModulesBySourceType;
|
216
224
|
}
|
217
225
|
}
|
218
226
|
|
@@ -315,6 +323,8 @@ class ChunkGraph {
|
|
315
323
|
const cgm = this._getChunkGraphModule(module);
|
316
324
|
const cgc = this._getChunkGraphChunk(chunk);
|
317
325
|
cgc.modules.delete(module);
|
326
|
+
// No need to invalidate cgc._modulesBySourceType because we modified cgc.modules anyway
|
327
|
+
if (cgc.sourceTypesByModule) cgc.sourceTypesByModule.delete(module);
|
318
328
|
cgm.chunks.delete(chunk);
|
319
329
|
}
|
320
330
|
|
@@ -568,11 +578,84 @@ class ChunkGraph {
|
|
568
578
|
getChunkModulesIterableBySourceType(chunk, sourceType) {
|
569
579
|
const cgc = this._getChunkGraphChunk(chunk);
|
570
580
|
const modulesWithSourceType = cgc.modules
|
571
|
-
.getFromUnorderedCache(
|
581
|
+
.getFromUnorderedCache(cgc._modulesBySourceType)
|
572
582
|
.get(sourceType);
|
573
583
|
return modulesWithSourceType;
|
574
584
|
}
|
575
585
|
|
586
|
+
/**
|
587
|
+
* @param {Chunk} chunk chunk
|
588
|
+
* @param {Module} module chunk module
|
589
|
+
* @param {Set<string>} sourceTypes source types
|
590
|
+
*/
|
591
|
+
setChunkModuleSourceTypes(chunk, module, sourceTypes) {
|
592
|
+
const cgc = this._getChunkGraphChunk(chunk);
|
593
|
+
if (cgc.sourceTypesByModule === undefined) {
|
594
|
+
cgc.sourceTypesByModule = new WeakMap();
|
595
|
+
}
|
596
|
+
cgc.sourceTypesByModule.set(module, sourceTypes);
|
597
|
+
// Update cgc._modulesBySourceType to invalidate the cache
|
598
|
+
cgc._modulesBySourceType = modulesBySourceType(cgc.sourceTypesByModule);
|
599
|
+
}
|
600
|
+
|
601
|
+
/**
|
602
|
+
* @param {Chunk} chunk chunk
|
603
|
+
* @param {Module} module chunk module
|
604
|
+
* @returns {Set<string>} source types
|
605
|
+
*/
|
606
|
+
getChunkModuleSourceTypes(chunk, module) {
|
607
|
+
const cgc = this._getChunkGraphChunk(chunk);
|
608
|
+
if (cgc.sourceTypesByModule === undefined) {
|
609
|
+
return module.getSourceTypes();
|
610
|
+
}
|
611
|
+
return cgc.sourceTypesByModule.get(module) || module.getSourceTypes();
|
612
|
+
}
|
613
|
+
|
614
|
+
/**
|
615
|
+
* @param {Module} module module
|
616
|
+
* @returns {Set<string>} source types
|
617
|
+
*/
|
618
|
+
getModuleSourceTypes(module) {
|
619
|
+
return (
|
620
|
+
this._getOverwrittenModuleSourceTypes(module) || module.getSourceTypes()
|
621
|
+
);
|
622
|
+
}
|
623
|
+
|
624
|
+
/**
|
625
|
+
* @param {Module} module module
|
626
|
+
* @returns {Set<string> | undefined} source types
|
627
|
+
*/
|
628
|
+
_getOverwrittenModuleSourceTypes(module) {
|
629
|
+
let newSet = false;
|
630
|
+
let sourceTypes;
|
631
|
+
for (const chunk of this.getModuleChunksIterable(module)) {
|
632
|
+
const cgc = this._getChunkGraphChunk(chunk);
|
633
|
+
if (cgc.sourceTypesByModule === undefined) return;
|
634
|
+
const st = cgc.sourceTypesByModule.get(module);
|
635
|
+
if (st === undefined) return;
|
636
|
+
if (!sourceTypes) {
|
637
|
+
sourceTypes = st;
|
638
|
+
continue;
|
639
|
+
} else if (!newSet) {
|
640
|
+
for (const type of st) {
|
641
|
+
if (!newSet) {
|
642
|
+
if (!sourceTypes.has(type)) {
|
643
|
+
newSet = true;
|
644
|
+
sourceTypes = new Set(sourceTypes);
|
645
|
+
sourceTypes.add(type);
|
646
|
+
}
|
647
|
+
} else {
|
648
|
+
sourceTypes.add(type);
|
649
|
+
}
|
650
|
+
}
|
651
|
+
} else {
|
652
|
+
for (const type of st) sourceTypes.add(type);
|
653
|
+
}
|
654
|
+
}
|
655
|
+
|
656
|
+
return sourceTypes;
|
657
|
+
}
|
658
|
+
|
576
659
|
/**
|
577
660
|
* @param {Chunk} chunk the chunk
|
578
661
|
* @param {function(Module, Module): -1|0|1} comparator comparator function
|
@@ -593,7 +676,7 @@ class ChunkGraph {
|
|
593
676
|
getOrderedChunkModulesIterableBySourceType(chunk, sourceType, comparator) {
|
594
677
|
const cgc = this._getChunkGraphChunk(chunk);
|
595
678
|
const modulesWithSourceType = cgc.modules
|
596
|
-
.getFromUnorderedCache(
|
679
|
+
.getFromUnorderedCache(cgc._modulesBySourceType)
|
597
680
|
.get(sourceType);
|
598
681
|
if (modulesWithSourceType === undefined) return undefined;
|
599
682
|
modulesWithSourceType.sortWith(comparator);
|
@@ -1473,6 +1556,10 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
1473
1556
|
const graphHash = cgm.graphHashes.provide(runtime, () => {
|
1474
1557
|
const hash = createHash(this._hashFunction);
|
1475
1558
|
hash.update(`${cgm.id}${this.moduleGraph.isAsync(module)}`);
|
1559
|
+
const sourceTypes = this._getOverwrittenModuleSourceTypes(module);
|
1560
|
+
if (sourceTypes !== undefined) {
|
1561
|
+
for (const type of sourceTypes) hash.update(type);
|
1562
|
+
}
|
1476
1563
|
this.moduleGraph.getExportsInfo(module).updateHash(hash, runtime);
|
1477
1564
|
return BigInt(`0x${/** @type {string} */ (hash.digest("hex"))}`);
|
1478
1565
|
});
|
package/lib/ExportsInfo.js
CHANGED
@@ -584,7 +584,7 @@ class ExportsInfo {
|
|
584
584
|
if (info.exportsInfo && name.length > 1) {
|
585
585
|
return info.exportsInfo.isExportProvided(name.slice(1));
|
586
586
|
}
|
587
|
-
return info.provided;
|
587
|
+
return info.provided ? name.length === 1 || undefined : info.provided;
|
588
588
|
}
|
589
589
|
const info = this.getReadOnlyExportInfo(name);
|
590
590
|
return info.provided;
|
package/lib/Module.js
CHANGED
@@ -60,6 +60,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
60
60
|
* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
|
61
61
|
* @property {CodeGenerationResults} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
|
62
62
|
* @property {Compilation=} compilation the compilation
|
63
|
+
* @property {ReadonlySet<string>=} sourceTypes source types
|
63
64
|
*/
|
64
65
|
|
65
66
|
/**
|
package/lib/NormalModule.js
CHANGED
@@ -1176,7 +1176,8 @@ class NormalModule extends Module {
|
|
1176
1176
|
chunkGraph,
|
1177
1177
|
runtime,
|
1178
1178
|
concatenationScope,
|
1179
|
-
codeGenerationResults
|
1179
|
+
codeGenerationResults,
|
1180
|
+
sourceTypes
|
1180
1181
|
}) {
|
1181
1182
|
/** @type {Set<string>} */
|
1182
1183
|
const runtimeRequirements = new Set();
|
@@ -1195,7 +1196,7 @@ class NormalModule extends Module {
|
|
1195
1196
|
};
|
1196
1197
|
|
1197
1198
|
const sources = new Map();
|
1198
|
-
for (const type of
|
1199
|
+
for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
|
1199
1200
|
const source = this.error
|
1200
1201
|
? new RawSource(
|
1201
1202
|
"throw new Error(" + JSON.stringify(this.error.message) + ");"
|
@@ -8,6 +8,7 @@
|
|
8
8
|
const mimeTypes = require("mime-types");
|
9
9
|
const path = require("path");
|
10
10
|
const { RawSource } = require("webpack-sources");
|
11
|
+
const ConcatenationScope = require("../ConcatenationScope");
|
11
12
|
const Generator = require("../Generator");
|
12
13
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
13
14
|
const createHash = require("../util/createHash");
|
@@ -23,6 +24,7 @@ const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
|
23
24
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
24
25
|
/** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */
|
25
26
|
/** @typedef {import("../Module")} Module */
|
27
|
+
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
26
28
|
/** @typedef {import("../NormalModule")} NormalModule */
|
27
29
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
28
30
|
/** @typedef {import("../util/Hash")} Hash */
|
@@ -145,6 +147,15 @@ class AssetGenerator extends Generator {
|
|
145
147
|
).replace(/^\.\//, "");
|
146
148
|
}
|
147
149
|
|
150
|
+
/**
|
151
|
+
* @param {NormalModule} module module for which the bailout reason should be determined
|
152
|
+
* @param {ConcatenationBailoutReasonContext} context context
|
153
|
+
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
154
|
+
*/
|
155
|
+
getConcatenationBailoutReason(module, context) {
|
156
|
+
return undefined;
|
157
|
+
}
|
158
|
+
|
148
159
|
/**
|
149
160
|
* @param {NormalModule} module module
|
150
161
|
* @returns {string} mime type
|
@@ -198,14 +209,21 @@ class AssetGenerator extends Generator {
|
|
198
209
|
*/
|
199
210
|
generate(
|
200
211
|
module,
|
201
|
-
{
|
212
|
+
{
|
213
|
+
runtime,
|
214
|
+
concatenationScope,
|
215
|
+
chunkGraph,
|
216
|
+
runtimeTemplate,
|
217
|
+
runtimeRequirements,
|
218
|
+
type,
|
219
|
+
getData
|
220
|
+
}
|
202
221
|
) {
|
203
222
|
switch (type) {
|
204
223
|
case "asset":
|
205
224
|
return module.originalSource();
|
206
225
|
default: {
|
207
|
-
|
208
|
-
|
226
|
+
let content;
|
209
227
|
const originalSource = module.originalSource();
|
210
228
|
if (module.buildInfo.dataUrl) {
|
211
229
|
let encodedSource;
|
@@ -255,11 +273,7 @@ class AssetGenerator extends Generator {
|
|
255
273
|
}
|
256
274
|
const data = getData();
|
257
275
|
data.set("url", Buffer.from(encodedSource));
|
258
|
-
|
259
|
-
`${RuntimeGlobals.module}.exports = ${JSON.stringify(
|
260
|
-
encodedSource
|
261
|
-
)};`
|
262
|
-
);
|
276
|
+
content = JSON.stringify(encodedSource);
|
263
277
|
} else {
|
264
278
|
const assetModuleFilename =
|
265
279
|
this.filename || runtimeTemplate.outputOptions.assetModuleFilename;
|
@@ -343,9 +357,22 @@ class AssetGenerator extends Generator {
|
|
343
357
|
data.set("filename", filename);
|
344
358
|
data.set("assetInfo", assetInfo);
|
345
359
|
}
|
360
|
+
content = assetPath;
|
361
|
+
}
|
346
362
|
|
363
|
+
if (concatenationScope) {
|
364
|
+
concatenationScope.registerNamespaceExport(
|
365
|
+
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
366
|
+
);
|
367
|
+
return new RawSource(
|
368
|
+
`${runtimeTemplate.supportsConst() ? "const" : "var"} ${
|
369
|
+
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
370
|
+
} = ${content};`
|
371
|
+
);
|
372
|
+
} else {
|
373
|
+
runtimeRequirements.add(RuntimeGlobals.module);
|
347
374
|
return new RawSource(
|
348
|
-
`${RuntimeGlobals.module}.exports = ${
|
375
|
+
`${RuntimeGlobals.module}.exports = ${content};`
|
349
376
|
);
|
350
377
|
}
|
351
378
|
}
|
package/lib/asset/AssetParser.js
CHANGED
@@ -31,6 +31,7 @@ class AssetParser extends Parser {
|
|
31
31
|
}
|
32
32
|
state.module.buildInfo.strict = true;
|
33
33
|
state.module.buildMeta.exportsType = "default";
|
34
|
+
state.module.buildMeta.defaultObject = false;
|
34
35
|
|
35
36
|
if (typeof this.dataUrlCondition === "function") {
|
36
37
|
state.module.buildInfo.dataUrl = this.dataUrlCondition(source, {
|
@@ -6,11 +6,13 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const { RawSource } = require("webpack-sources");
|
9
|
+
const ConcatenationScope = require("../ConcatenationScope");
|
9
10
|
const Generator = require("../Generator");
|
10
11
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
11
12
|
|
12
13
|
/** @typedef {import("webpack-sources").Source} Source */
|
13
14
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
15
|
+
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
14
16
|
/** @typedef {import("../NormalModule")} NormalModule */
|
15
17
|
|
16
18
|
const TYPES = new Set(["javascript"]);
|
@@ -21,9 +23,10 @@ class AssetSourceGenerator extends Generator {
|
|
21
23
|
* @param {GenerateContext} generateContext context for generate
|
22
24
|
* @returns {Source} generated code
|
23
25
|
*/
|
24
|
-
generate(
|
25
|
-
|
26
|
-
|
26
|
+
generate(
|
27
|
+
module,
|
28
|
+
{ concatenationScope, chunkGraph, runtimeTemplate, runtimeRequirements }
|
29
|
+
) {
|
27
30
|
const originalSource = module.originalSource();
|
28
31
|
|
29
32
|
if (!originalSource) {
|
@@ -38,9 +41,31 @@ class AssetSourceGenerator extends Generator {
|
|
38
41
|
} else {
|
39
42
|
encodedSource = content.toString("utf-8");
|
40
43
|
}
|
41
|
-
|
42
|
-
|
43
|
-
)
|
44
|
+
|
45
|
+
let sourceContent;
|
46
|
+
if (concatenationScope) {
|
47
|
+
concatenationScope.registerNamespaceExport(
|
48
|
+
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
49
|
+
);
|
50
|
+
sourceContent = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${
|
51
|
+
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
52
|
+
} = ${JSON.stringify(encodedSource)};`;
|
53
|
+
} else {
|
54
|
+
runtimeRequirements.add(RuntimeGlobals.module);
|
55
|
+
sourceContent = `${RuntimeGlobals.module}.exports = ${JSON.stringify(
|
56
|
+
encodedSource
|
57
|
+
)};`;
|
58
|
+
}
|
59
|
+
return new RawSource(sourceContent);
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* @param {NormalModule} module module for which the bailout reason should be determined
|
64
|
+
* @param {ConcatenationBailoutReasonContext} context context
|
65
|
+
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
66
|
+
*/
|
67
|
+
getConcatenationBailoutReason(module, context) {
|
68
|
+
return undefined;
|
44
69
|
}
|
45
70
|
|
46
71
|
/**
|
@@ -639,10 +639,14 @@ class PackContentItems {
|
|
639
639
|
} catch (e) {
|
640
640
|
rollback(s);
|
641
641
|
if (e === NOT_SERIALIZABLE) continue;
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
642
|
+
const msg = "Skipped not serializable cache item";
|
643
|
+
if (e.message.includes("ModuleBuildError")) {
|
644
|
+
logger.log(`${msg} (in build error): ${e.message}`);
|
645
|
+
logger.debug(`${msg} '${key}' (in build error): ${e.stack}`);
|
646
|
+
} else {
|
647
|
+
logger.warn(`${msg}: ${e.message}`);
|
648
|
+
logger.debug(`${msg} '${key}': ${e.stack}`);
|
649
|
+
}
|
646
650
|
}
|
647
651
|
}
|
648
652
|
write(null);
|
@@ -73,9 +73,9 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
73
73
|
Template.indent(
|
74
74
|
`error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2];`
|
75
75
|
),
|
76
|
-
|
77
|
-
|
78
|
-
])}`,
|
76
|
+
`${
|
77
|
+
RuntimeGlobals.moduleFactories
|
78
|
+
}[id] = ${runtimeTemplate.basicFunction("", ["throw error;"])}`,
|
79
79
|
"data.p = 0;"
|
80
80
|
])};`,
|
81
81
|
`var handleFunction = ${runtimeTemplate.basicFunction(
|
@@ -111,10 +111,11 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
111
111
|
)};`,
|
112
112
|
`var onFactory = ${runtimeTemplate.basicFunction("factory", [
|
113
113
|
"data.p = 1;",
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
114
|
+
`${
|
115
|
+
RuntimeGlobals.moduleFactories
|
116
|
+
}[id] = ${runtimeTemplate.basicFunction("module", [
|
117
|
+
"module.exports = factory();"
|
118
|
+
])}`
|
118
119
|
])};`,
|
119
120
|
"handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1);"
|
120
121
|
])});`
|
@@ -1669,7 +1669,8 @@ ${defineGetters}`
|
|
1669
1669
|
chunkGraph,
|
1670
1670
|
runtime,
|
1671
1671
|
concatenationScope,
|
1672
|
-
codeGenerationResults
|
1672
|
+
codeGenerationResults,
|
1673
|
+
sourceTypes: TYPES
|
1673
1674
|
});
|
1674
1675
|
const source = codeGenResult.sources.get("javascript");
|
1675
1676
|
const data = codeGenResult.data;
|
@@ -58,6 +58,11 @@ class ModuleConcatenationPlugin {
|
|
58
58
|
apply(compiler) {
|
59
59
|
const { _backCompat: backCompat } = compiler;
|
60
60
|
compiler.hooks.compilation.tap("ModuleConcatenationPlugin", compilation => {
|
61
|
+
if (compilation.moduleMemCaches) {
|
62
|
+
throw new Error(
|
63
|
+
"optimization.concatenateModules can't be used with cacheUnaffected as module concatenation is a global effect"
|
64
|
+
);
|
65
|
+
}
|
61
66
|
const moduleGraph = compilation.moduleGraph;
|
62
67
|
const bailoutReasonMap = new Map();
|
63
68
|
|
@@ -425,7 +430,21 @@ class ModuleConcatenationPlugin {
|
|
425
430
|
for (const chunk of chunkGraph.getModuleChunksIterable(
|
426
431
|
rootModule
|
427
432
|
)) {
|
428
|
-
chunkGraph.
|
433
|
+
const sourceTypes = chunkGraph.getChunkModuleSourceTypes(
|
434
|
+
chunk,
|
435
|
+
m
|
436
|
+
);
|
437
|
+
if (sourceTypes.size === 1) {
|
438
|
+
chunkGraph.disconnectChunkAndModule(chunk, m);
|
439
|
+
} else {
|
440
|
+
const newSourceTypes = new Set(sourceTypes);
|
441
|
+
newSourceTypes.delete("javascript");
|
442
|
+
chunkGraph.setChunkModuleSourceTypes(
|
443
|
+
chunk,
|
444
|
+
m,
|
445
|
+
newSourceTypes
|
446
|
+
);
|
447
|
+
}
|
429
448
|
}
|
430
449
|
}
|
431
450
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.72.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -3,4 +3,4 @@
|
|
3
3
|
* DO NOT MODIFY BY HAND.
|
4
4
|
* Run `yarn special-lint-fix` to update
|
5
5
|
*/
|
6
|
-
"use strict";function n(t,{instancePath:l="",parentData:
|
6
|
+
"use strict";function n(t,{instancePath:l="",parentData:e,parentDataProperty:s,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let l=0;l<n;l++){let n=t[l];const e=o,s=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=s,null!==r&&(s?r.length=s:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(e!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,l=o;let e=!1;const s=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=s===o;if(e=e||h,!e){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,e=e||h}if(e)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(l,{instancePath:e="",parentData:s,parentDataProperty:a,rootData:r=l}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof l){if(l.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(l&&"object"==typeof l&&!Array.isArray(l)){let t;if(void 0===l.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in l)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==l.banner){let n=l.banner;const t=u,e=u;let s=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(s=s||h,!s){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,s=s||h}if(s)u=e,null!==o&&(e?o.length=e:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var y=t===u}else y=!0;if(y){if(void 0!==l.entryOnly){const n=u;if("boolean"!=typeof l.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y){if(void 0!==l.exclude){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.exclude,{instancePath:e+"/exclude",parentData:l,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0;if(y){if(void 0!==l.footer){const n=u;if("boolean"!=typeof l.footer){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y){if(void 0!==l.include){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.include,{instancePath:e+"/include",parentData:l,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0;if(y){if(void 0!==l.raw){const n=u;if("boolean"!=typeof l.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y)if(void 0!==l.test){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.test,{instancePath:e+"/test",parentData:l,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0}}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(l instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t;
|
package/types.d.ts
CHANGED
@@ -430,6 +430,11 @@ declare interface BannerPluginOptions {
|
|
430
430
|
*/
|
431
431
|
exclude?: string | RegExp | Rule[];
|
432
432
|
|
433
|
+
/**
|
434
|
+
* If true, banner will be placed at the end of the output.
|
435
|
+
*/
|
436
|
+
footer?: boolean;
|
437
|
+
|
433
438
|
/**
|
434
439
|
* Include all modules matching any of these conditions.
|
435
440
|
*/
|
@@ -812,6 +817,13 @@ declare class ChunkGraph {
|
|
812
817
|
chunk: Chunk,
|
813
818
|
sourceType: string
|
814
819
|
): undefined | Iterable<Module>;
|
820
|
+
setChunkModuleSourceTypes(
|
821
|
+
chunk: Chunk,
|
822
|
+
module: Module,
|
823
|
+
sourceTypes: Set<string>
|
824
|
+
): void;
|
825
|
+
getChunkModuleSourceTypes(chunk: Chunk, module: Module): Set<string>;
|
826
|
+
getModuleSourceTypes(module: Module): Set<string>;
|
815
827
|
getOrderedChunkModulesIterable(
|
816
828
|
chunk: Chunk,
|
817
829
|
comparator: (arg0: Module, arg1: Module) => 0 | 1 | -1
|
@@ -1247,6 +1259,11 @@ declare interface CodeGenerationContext {
|
|
1247
1259
|
* the compilation
|
1248
1260
|
*/
|
1249
1261
|
compilation?: Compilation;
|
1262
|
+
|
1263
|
+
/**
|
1264
|
+
* source types
|
1265
|
+
*/
|
1266
|
+
sourceTypes?: ReadonlySet<string>;
|
1250
1267
|
}
|
1251
1268
|
declare interface CodeGenerationResult {
|
1252
1269
|
/**
|