webpack 5.48.0 → 5.51.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/README.md +4 -16
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/CompatibilityPlugin.js +21 -4
- package/lib/Compilation.js +8 -3
- package/lib/EvalSourceMapDevToolPlugin.js +2 -2
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +665 -193
- package/lib/HotModuleReplacementPlugin.js +4 -4
- package/lib/Module.js +1 -0
- package/lib/MultiCompiler.js +0 -2
- package/lib/NormalModule.js +51 -20
- package/lib/NormalModuleFactory.js +137 -74
- package/lib/Parser.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/SourceMapDevToolPlugin.js +2 -2
- package/lib/WebpackOptionsApply.js +8 -0
- package/lib/asset/AssetModulesPlugin.js +0 -1
- package/lib/config/defaults.js +27 -6
- package/lib/config/normalization.js +6 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +10 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +5 -1
- package/lib/index.js +0 -3
- package/lib/javascript/JavascriptParser.js +2 -0
- package/lib/library/ModuleLibraryPlugin.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +7 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +7 -1
- package/lib/optimize/ConcatenatedModule.js +3 -3
- package/lib/optimize/SplitChunksPlugin.js +4 -4
- package/lib/schemes/HttpUriPlugin.js +942 -25
- package/lib/serialization/BinaryMiddleware.js +293 -267
- package/lib/util/fs.js +40 -0
- package/lib/util/identifier.js +26 -8
- package/lib/wasm-async/{AsyncWasmChunkLoadingRuntimeModule.js → AsyncWasmLoadingRuntimeModule.js} +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +18 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -2
- package/lib/web/FetchCompileWasmPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +7 -1
- package/package.json +1 -1
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +43 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +6 -0
- package/schemas/plugins/schemes/HttpUriPlugin.json +42 -0
- package/types.d.ts +110 -14
- package/lib/schemes/HttpsUriPlugin.js +0 -63
package/lib/config/defaults.js
CHANGED
@@ -171,7 +171,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
171
171
|
|
172
172
|
applySnapshotDefaults(options.snapshot, { production });
|
173
173
|
|
174
|
-
applyExperimentsDefaults(options.experiments);
|
174
|
+
applyExperimentsDefaults(options.experiments, { production, development });
|
175
175
|
|
176
176
|
applyModuleDefaults(options.module, {
|
177
177
|
cache,
|
@@ -193,7 +193,10 @@ const applyWebpackOptionsDefaults = options => {
|
|
193
193
|
module: options.module
|
194
194
|
});
|
195
195
|
|
196
|
-
applyExternalsPresetsDefaults(options.externalsPresets, {
|
196
|
+
applyExternalsPresetsDefaults(options.externalsPresets, {
|
197
|
+
targetProperties,
|
198
|
+
buildHttp: !!options.experiments.buildHttp
|
199
|
+
});
|
197
200
|
|
198
201
|
applyLoaderDefaults(options.loader, { targetProperties });
|
199
202
|
|
@@ -245,13 +248,26 @@ const applyWebpackOptionsDefaults = options => {
|
|
245
248
|
|
246
249
|
/**
|
247
250
|
* @param {Experiments} experiments options
|
251
|
+
* @param {Object} options options
|
252
|
+
* @param {boolean} options.production is production
|
253
|
+
* @param {boolean} options.development is development mode
|
248
254
|
* @returns {void}
|
249
255
|
*/
|
250
|
-
const applyExperimentsDefaults = experiments => {
|
256
|
+
const applyExperimentsDefaults = (experiments, { production, development }) => {
|
251
257
|
D(experiments, "topLevelAwait", false);
|
252
258
|
D(experiments, "syncWebAssembly", false);
|
253
259
|
D(experiments, "asyncWebAssembly", false);
|
254
260
|
D(experiments, "outputModule", false);
|
261
|
+
D(experiments, "asset", false);
|
262
|
+
D(experiments, "executeModule", false);
|
263
|
+
D(experiments, "layers", false);
|
264
|
+
D(experiments, "lazyCompilation", false);
|
265
|
+
D(experiments, "buildHttp", false);
|
266
|
+
|
267
|
+
if (typeof experiments.buildHttp === "object") {
|
268
|
+
D(experiments.buildHttp, "frozen", production);
|
269
|
+
D(experiments.buildHttp, "upgrade", development);
|
270
|
+
}
|
255
271
|
};
|
256
272
|
|
257
273
|
/**
|
@@ -298,7 +314,7 @@ const applyCacheDefaults = (cache, { name, mode, development }) => {
|
|
298
314
|
);
|
299
315
|
D(cache, "hashAlgorithm", "md4");
|
300
316
|
D(cache, "store", "pack");
|
301
|
-
D(cache, "compression",
|
317
|
+
D(cache, "compression", false);
|
302
318
|
D(cache, "profile", false);
|
303
319
|
D(cache, "idleTimeout", 60000);
|
304
320
|
D(cache, "idleTimeoutForInitialStore", 5000);
|
@@ -860,13 +876,18 @@ const applyOutputDefaults = (
|
|
860
876
|
* @param {ExternalsPresets} externalsPresets options
|
861
877
|
* @param {Object} options options
|
862
878
|
* @param {TargetProperties | false} options.targetProperties target properties
|
879
|
+
* @param {boolean} options.buildHttp buildHttp experiment enabled
|
863
880
|
* @returns {void}
|
864
881
|
*/
|
865
882
|
const applyExternalsPresetsDefaults = (
|
866
883
|
externalsPresets,
|
867
|
-
{ targetProperties }
|
884
|
+
{ targetProperties, buildHttp }
|
868
885
|
) => {
|
869
|
-
D(
|
886
|
+
D(
|
887
|
+
externalsPresets,
|
888
|
+
"web",
|
889
|
+
!buildHttp && targetProperties && targetProperties.web
|
890
|
+
);
|
870
891
|
D(externalsPresets, "node", targetProperties && targetProperties.node);
|
871
892
|
D(externalsPresets, "nwjs", targetProperties && targetProperties.nwjs);
|
872
893
|
D(
|
@@ -171,7 +171,12 @@ const getNormalizedWebpackOptions = config => {
|
|
171
171
|
Promise.resolve().then(fn).then(getNormalizedEntryStatic)
|
172
172
|
)(config.entry)
|
173
173
|
: getNormalizedEntryStatic(config.entry),
|
174
|
-
experiments:
|
174
|
+
experiments: nestedConfig(config.experiments, experiments => ({
|
175
|
+
...experiments,
|
176
|
+
buildHttp: optionalNestedConfig(experiments.buildHttp, options =>
|
177
|
+
options === true ? {} : options
|
178
|
+
)
|
179
|
+
})),
|
175
180
|
externals: config.externals,
|
176
181
|
externalsPresets: cloneObject(config.externalsPresets),
|
177
182
|
externalsType: config.externalsType,
|
@@ -76,6 +76,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
76
76
|
const withOnChunkLoad = this._runtimeRequirements.has(
|
77
77
|
RuntimeGlobals.onChunksLoaded
|
78
78
|
);
|
79
|
+
const withHmr = this._runtimeRequirements.has(
|
80
|
+
RuntimeGlobals.hmrDownloadUpdateHandlers
|
81
|
+
);
|
79
82
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
80
83
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
81
84
|
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
|
@@ -93,6 +96,10 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
93
96
|
true
|
94
97
|
);
|
95
98
|
|
99
|
+
const stateExpression = withHmr
|
100
|
+
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_module`
|
101
|
+
: undefined;
|
102
|
+
|
96
103
|
return Template.asString([
|
97
104
|
withBaseURI
|
98
105
|
? Template.asString([
|
@@ -105,7 +112,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
105
112
|
"// object to store loaded and loading chunks",
|
106
113
|
"// undefined = chunk not loaded, null = chunk preloaded/prefetched",
|
107
114
|
"// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded",
|
108
|
-
|
115
|
+
`var installedChunks = ${
|
116
|
+
stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
|
117
|
+
}{`,
|
109
118
|
Template.indent(
|
110
119
|
Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 0`).join(
|
111
120
|
",\n"
|
@@ -252,7 +252,11 @@ module.exports = function () {
|
|
252
252
|
.then($hmrDownloadManifest$)
|
253
253
|
.then(function (update) {
|
254
254
|
if (!update) {
|
255
|
-
return setStatus(applyInvalidatedModules() ? "ready" : "idle")
|
255
|
+
return setStatus(applyInvalidatedModules() ? "ready" : "idle").then(
|
256
|
+
function () {
|
257
|
+
return null;
|
258
|
+
}
|
259
|
+
);
|
256
260
|
}
|
257
261
|
|
258
262
|
return setStatus("prepare").then(function () {
|
package/lib/index.js
CHANGED
@@ -78,6 +78,10 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
78
78
|
const result = new ConcatSource(source);
|
79
79
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
80
80
|
const exports = [];
|
81
|
+
const isAsync = moduleGraph.isAsync(module);
|
82
|
+
if (isAsync) {
|
83
|
+
result.add(`__webpack_exports__ = await __webpack_exports__;\n`);
|
84
|
+
}
|
81
85
|
for (const exportInfo of exportsInfo.orderedExports) {
|
82
86
|
if (!exportInfo.provided) continue;
|
83
87
|
const varName = `__webpack_exports__${Template.toIdentifier(
|
@@ -61,6 +61,10 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
61
61
|
false
|
62
62
|
);
|
63
63
|
|
64
|
+
const stateExpression = withHmr
|
65
|
+
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
|
66
|
+
: undefined;
|
67
|
+
|
64
68
|
return Template.asString([
|
65
69
|
withBaseURI
|
66
70
|
? Template.asString([
|
@@ -74,7 +78,9 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
74
78
|
"",
|
75
79
|
"// object to store loaded chunks",
|
76
80
|
'// "0" means "already loaded", Promise means loading',
|
77
|
-
|
81
|
+
`var installedChunks = ${
|
82
|
+
stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
|
83
|
+
}{`,
|
78
84
|
Template.indent(
|
79
85
|
Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 0`).join(
|
80
86
|
",\n"
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
9
|
const Template = require("../Template");
|
10
|
-
const
|
10
|
+
const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
|
11
11
|
|
12
12
|
/** @typedef {import("../Compiler")} Compiler */
|
13
13
|
|
@@ -93,7 +93,7 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
93
93
|
set.add(RuntimeGlobals.publicPath);
|
94
94
|
compilation.addRuntimeModule(
|
95
95
|
chunk,
|
96
|
-
new
|
96
|
+
new AsyncWasmLoadingRuntimeModule({
|
97
97
|
generateLoadBinaryCode,
|
98
98
|
supportsStreaming: false
|
99
99
|
})
|
@@ -80,7 +80,8 @@ class ReadFileCompileWasmPlugin {
|
|
80
80
|
new WasmChunkLoadingRuntimeModule({
|
81
81
|
generateLoadBinaryCode,
|
82
82
|
supportsStreaming: false,
|
83
|
-
mangleImports: this.options.mangleImports
|
83
|
+
mangleImports: this.options.mangleImports,
|
84
|
+
runtimeRequirements: set
|
84
85
|
})
|
85
86
|
);
|
86
87
|
});
|
@@ -61,6 +61,10 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
61
61
|
true
|
62
62
|
);
|
63
63
|
|
64
|
+
const stateExpression = withHmr
|
65
|
+
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_require`
|
66
|
+
: undefined;
|
67
|
+
|
64
68
|
return Template.asString([
|
65
69
|
withBaseURI
|
66
70
|
? Template.asString([
|
@@ -74,7 +78,9 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
74
78
|
"",
|
75
79
|
"// object to store loaded chunks",
|
76
80
|
'// "1" means "loaded", otherwise not loaded yet',
|
77
|
-
|
81
|
+
`var installedChunks = ${
|
82
|
+
stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
|
83
|
+
}{`,
|
78
84
|
Template.indent(
|
79
85
|
Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 1`).join(
|
80
86
|
",\n"
|
@@ -23,7 +23,7 @@ const { equals } = require("../util/ArrayHelpers");
|
|
23
23
|
const LazySet = require("../util/LazySet");
|
24
24
|
const { concatComparators, keepOriginalOrder } = require("../util/comparators");
|
25
25
|
const createHash = require("../util/createHash");
|
26
|
-
const
|
26
|
+
const { makePathsRelative } = require("../util/identifier");
|
27
27
|
const makeSerializable = require("../util/makeSerializable");
|
28
28
|
const propertyAccess = require("../util/propertyAccess");
|
29
29
|
const {
|
@@ -1011,13 +1011,13 @@ class ConcatenatedModule extends Module {
|
|
1011
1011
|
}
|
1012
1012
|
|
1013
1013
|
static _createIdentifier(rootModule, modules, associatedObjectForCache) {
|
1014
|
-
const
|
1014
|
+
const cachedMakePathsRelative = makePathsRelative.bindContextCache(
|
1015
1015
|
rootModule.context,
|
1016
1016
|
associatedObjectForCache
|
1017
1017
|
);
|
1018
1018
|
let identifiers = [];
|
1019
1019
|
for (const module of modules) {
|
1020
|
-
identifiers.push(
|
1020
|
+
identifiers.push(cachedMakePathsRelative(module.identifier()));
|
1021
1021
|
}
|
1022
1022
|
identifiers.sort();
|
1023
1023
|
const hash = createHash("md4");
|
@@ -17,7 +17,7 @@ const {
|
|
17
17
|
} = require("../util/comparators");
|
18
18
|
const createHash = require("../util/createHash");
|
19
19
|
const deterministicGrouping = require("../util/deterministicGrouping");
|
20
|
-
const
|
20
|
+
const { makePathsRelative } = require("../util/identifier");
|
21
21
|
const memoize = require("../util/memoize");
|
22
22
|
const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
23
23
|
|
@@ -748,7 +748,7 @@ module.exports = class SplitChunksPlugin {
|
|
748
748
|
* @returns {void}
|
749
749
|
*/
|
750
750
|
apply(compiler) {
|
751
|
-
const
|
751
|
+
const cachedMakePathsRelative = makePathsRelative.bindContextCache(
|
752
752
|
compiler.context,
|
753
753
|
compiler.root
|
754
754
|
);
|
@@ -1596,11 +1596,11 @@ module.exports = class SplitChunksPlugin {
|
|
1596
1596
|
getKey(module) {
|
1597
1597
|
const cache = getKeyCache.get(module);
|
1598
1598
|
if (cache !== undefined) return cache;
|
1599
|
-
const ident =
|
1599
|
+
const ident = cachedMakePathsRelative(module.identifier());
|
1600
1600
|
const nameForCondition =
|
1601
1601
|
module.nameForCondition && module.nameForCondition();
|
1602
1602
|
const name = nameForCondition
|
1603
|
-
?
|
1603
|
+
? cachedMakePathsRelative(nameForCondition)
|
1604
1604
|
: ident.replace(/^.*!|\?[^?!]*$/g, "");
|
1605
1605
|
const fullKey =
|
1606
1606
|
name +
|