webpack 5.10.0 → 5.11.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/bin/webpack.js +0 -0
- package/lib/Compilation.js +5 -21
- package/lib/Compiler.js +58 -13
- package/lib/FlagAllModulesAsUsedPlugin.js +4 -0
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +1 -1
- package/lib/ModuleInfoHeaderPlugin.js +1 -1
- package/lib/NormalModule.js +4 -2
- package/lib/RuntimeGlobals.js +11 -1
- package/lib/RuntimeModule.js +20 -0
- package/lib/RuntimeTemplate.js +4 -0
- package/lib/cache/PackFileCacheStrategy.js +4 -2
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/index.js +5 -0
- package/lib/javascript/JavascriptModulesPlugin.js +82 -26
- package/lib/node/NodeTargetPlugin.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +9 -13
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/rules/RuleSetCompiler.js +4 -2
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
- package/lib/runtime/CompatRuntimeModule.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +467 -136
- package/lib/serialization/FileMiddleware.js +227 -37
- package/lib/serialization/ObjectMiddleware.js +89 -5
- package/lib/sharing/ConsumeSharedRuntimeModule.js +1 -1
- package/lib/util/fs.js +4 -0
- package/lib/util/source.js +61 -0
- package/lib/validateSchema.js +84 -73
- package/lib/wasm-async/AsyncWasmChunkLoadingRuntimeModule.js +1 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +54 -55
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +8 -8
- package/types.d.ts +1170 -578
package/lib/validateSchema.js
CHANGED
@@ -69,94 +69,105 @@ const REMOVED = {
|
|
69
69
|
};
|
70
70
|
/* cSpell:enable */
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
) {
|
85
|
-
|
86
|
-
}
|
87
|
-
|
88
|
-
if (
|
89
|
-
children &&
|
90
|
-
children.some(
|
91
|
-
child => child.keyword === "pattern" && child.dataPath === ".devtool"
|
92
|
-
)
|
93
|
-
) {
|
94
|
-
return (
|
95
|
-
`${formattedError}\n` +
|
96
|
-
"BREAKING CHANGE since webpack 5: The devtool option is more strict.\n" +
|
97
|
-
"Please strictly follow the order of the keywords in the pattern."
|
98
|
-
);
|
99
|
-
}
|
100
|
-
|
101
|
-
if (error.keyword === "additionalProperties") {
|
102
|
-
const params = /** @type {import("ajv").AdditionalPropertiesParams} */ (error.params);
|
72
|
+
/**
|
73
|
+
* @param {Parameters<typeof validate>[0]} schema a json schema
|
74
|
+
* @param {Parameters<typeof validate>[1]} options the options that should be validated
|
75
|
+
* @param {Parameters<typeof validate>[2]=} validationConfiguration configuration for generating errors
|
76
|
+
* @returns {void}
|
77
|
+
*/
|
78
|
+
const validateSchema = (schema, options, validationConfiguration) => {
|
79
|
+
validate(
|
80
|
+
schema,
|
81
|
+
options,
|
82
|
+
validationConfiguration || {
|
83
|
+
name: "Webpack",
|
84
|
+
postFormatter: (formattedError, error) => {
|
85
|
+
const children = error.children;
|
103
86
|
if (
|
104
|
-
|
105
|
-
|
106
|
-
|
87
|
+
children &&
|
88
|
+
children.some(
|
89
|
+
child =>
|
90
|
+
child.keyword === "absolutePath" &&
|
91
|
+
child.dataPath === ".output.filename"
|
107
92
|
)
|
108
93
|
) {
|
109
|
-
return `${formattedError}\
|
110
|
-
DID_YOU_MEAN[params.additionalProperty]
|
111
|
-
}?`;
|
94
|
+
return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
|
112
95
|
}
|
113
96
|
|
114
97
|
if (
|
115
|
-
|
116
|
-
|
117
|
-
|
98
|
+
children &&
|
99
|
+
children.some(
|
100
|
+
child =>
|
101
|
+
child.keyword === "pattern" && child.dataPath === ".devtool"
|
118
102
|
)
|
119
103
|
) {
|
120
|
-
return
|
104
|
+
return (
|
105
|
+
`${formattedError}\n` +
|
106
|
+
"BREAKING CHANGE since webpack 5: The devtool option is more strict.\n" +
|
107
|
+
"Please strictly follow the order of the keywords in the pattern."
|
108
|
+
);
|
121
109
|
}
|
122
110
|
|
123
|
-
if (
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
"]"
|
135
|
-
);
|
111
|
+
if (error.keyword === "additionalProperties") {
|
112
|
+
const params = /** @type {import("ajv").AdditionalPropertiesParams} */ (error.params);
|
113
|
+
if (
|
114
|
+
Object.prototype.hasOwnProperty.call(
|
115
|
+
DID_YOU_MEAN,
|
116
|
+
params.additionalProperty
|
117
|
+
)
|
118
|
+
) {
|
119
|
+
return `${formattedError}\nDid you mean ${
|
120
|
+
DID_YOU_MEAN[params.additionalProperty]
|
121
|
+
}?`;
|
136
122
|
}
|
137
123
|
|
138
|
-
if (
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
124
|
+
if (
|
125
|
+
Object.prototype.hasOwnProperty.call(
|
126
|
+
REMOVED,
|
127
|
+
params.additionalProperty
|
128
|
+
)
|
129
|
+
) {
|
130
|
+
return `${formattedError}\n${REMOVED[params.additionalProperty]}?`;
|
131
|
+
}
|
132
|
+
|
133
|
+
if (!error.dataPath) {
|
134
|
+
if (params.additionalProperty === "debug") {
|
135
|
+
return (
|
136
|
+
`${formattedError}\n` +
|
137
|
+
"The 'debug' property was removed in webpack 2.0.0.\n" +
|
138
|
+
"Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
|
139
|
+
"Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
|
140
|
+
"plugins: [\n" +
|
141
|
+
" new webpack.LoaderOptionsPlugin({\n" +
|
142
|
+
" debug: true\n" +
|
143
|
+
" })\n" +
|
144
|
+
"]"
|
145
|
+
);
|
146
|
+
}
|
147
|
+
|
148
|
+
if (params.additionalProperty) {
|
149
|
+
return (
|
150
|
+
`${formattedError}\n` +
|
151
|
+
"For typos: please correct them.\n" +
|
152
|
+
"For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.\n" +
|
153
|
+
" Loaders should be updated to allow passing options via loader options in module.rules.\n" +
|
154
|
+
" Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
|
155
|
+
" plugins: [\n" +
|
156
|
+
" new webpack.LoaderOptionsPlugin({\n" +
|
157
|
+
" // test: /\\.xxx$/, // may apply this only for some modules\n" +
|
158
|
+
" options: {\n" +
|
159
|
+
` ${params.additionalProperty}: …\n` +
|
160
|
+
" }\n" +
|
161
|
+
" })\n" +
|
162
|
+
" ]"
|
163
|
+
);
|
164
|
+
}
|
154
165
|
}
|
155
166
|
}
|
156
|
-
}
|
157
167
|
|
158
|
-
|
168
|
+
return formattedError;
|
169
|
+
}
|
159
170
|
}
|
160
|
-
|
171
|
+
);
|
161
172
|
};
|
162
173
|
module.exports = validateSchema;
|
@@ -11,7 +11,7 @@ const Template = require("../Template");
|
|
11
11
|
|
12
12
|
class AsyncWasmChunkLoadingRuntimeModule extends RuntimeModule {
|
13
13
|
constructor({ generateLoadBinaryCode, supportsStreaming }) {
|
14
|
-
super("wasm chunk loading",
|
14
|
+
super("wasm chunk loading", RuntimeModule.STAGE_ATTACH);
|
15
15
|
this.generateLoadBinaryCode = generateLoadBinaryCode;
|
16
16
|
this.supportsStreaming = supportsStreaming;
|
17
17
|
}
|
@@ -190,7 +190,7 @@ const generateImportObject = (
|
|
190
190
|
|
191
191
|
class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
192
192
|
constructor({ generateLoadBinaryCode, supportsStreaming, mangleImports }) {
|
193
|
-
super("wasm chunk loading",
|
193
|
+
super("wasm chunk loading", RuntimeModule.STAGE_ATTACH);
|
194
194
|
this.generateLoadBinaryCode = generateLoadBinaryCode;
|
195
195
|
this.supportsStreaming = supportsStreaming;
|
196
196
|
this.mangleImports = mangleImports;
|
@@ -47,7 +47,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
47
47
|
}
|
48
48
|
|
49
49
|
constructor(runtimeRequirements) {
|
50
|
-
super("jsonp chunk loading",
|
50
|
+
super("jsonp chunk loading", RuntimeModule.STAGE_ATTACH);
|
51
51
|
this._runtimeRequirements = runtimeRequirements;
|
52
52
|
}
|
53
53
|
|
@@ -376,55 +376,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
376
376
|
"",
|
377
377
|
withDefer
|
378
378
|
? Template.asString([
|
379
|
-
`var checkDeferredModules = ${runtimeTemplate.
|
380
|
-
"",
|
381
|
-
""
|
382
|
-
)};`,
|
383
|
-
"function checkDeferredModulesImpl() {",
|
384
|
-
Template.indent([
|
385
|
-
"var result;",
|
386
|
-
"for(var i = 0; i < deferredModules.length; i++) {",
|
387
|
-
Template.indent([
|
388
|
-
"var deferredModule = deferredModules[i];",
|
389
|
-
"var fulfilled = true;",
|
390
|
-
"for(var j = 1; j < deferredModule.length; j++) {",
|
391
|
-
Template.indent([
|
392
|
-
"var depId = deferredModule[j];",
|
393
|
-
"if(installedChunks[depId] !== 0) fulfilled = false;"
|
394
|
-
]),
|
395
|
-
"}",
|
396
|
-
"if(fulfilled) {",
|
397
|
-
Template.indent([
|
398
|
-
"deferredModules.splice(i--, 1);",
|
399
|
-
"result = " +
|
400
|
-
"__webpack_require__(" +
|
401
|
-
`${RuntimeGlobals.entryModuleId} = deferredModule[0]);`
|
402
|
-
]),
|
403
|
-
"}"
|
404
|
-
]),
|
405
|
-
"}",
|
406
|
-
"if(deferredModules.length === 0) {",
|
407
|
-
Template.indent([
|
408
|
-
`${RuntimeGlobals.startup}();`,
|
409
|
-
`${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction(
|
410
|
-
"",
|
411
|
-
""
|
412
|
-
)}`
|
413
|
-
]),
|
414
|
-
"}",
|
415
|
-
"return result;"
|
416
|
-
]),
|
417
|
-
"}",
|
418
|
-
`${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction("", [
|
419
|
-
"// reset startup function so it can be called again when more startup code is added",
|
420
|
-
`${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction(
|
421
|
-
"",
|
422
|
-
""
|
423
|
-
)}`,
|
424
|
-
"chunkLoadingGlobal = chunkLoadingGlobal.slice();",
|
425
|
-
"for(var i = 0; i < chunkLoadingGlobal.length; i++) webpackJsonpCallback(chunkLoadingGlobal[i]);",
|
426
|
-
"return (checkDeferredModules = checkDeferredModulesImpl)();"
|
427
|
-
])};`
|
379
|
+
`var checkDeferredModules = ${runtimeTemplate.emptyFunction()};`
|
428
380
|
])
|
429
381
|
: "// no deferred startup",
|
430
382
|
"",
|
@@ -432,7 +384,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
432
384
|
? Template.asString([
|
433
385
|
"// install a JSONP callback for chunk loading",
|
434
386
|
`var webpackJsonpCallback = ${runtimeTemplate.basicFunction(
|
435
|
-
"data",
|
387
|
+
"parentChunkLoadingFunction, data",
|
436
388
|
[
|
437
389
|
runtimeTemplate.destructureArray(
|
438
390
|
[
|
@@ -467,7 +419,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
467
419
|
]),
|
468
420
|
"}",
|
469
421
|
"if(runtime) runtime(__webpack_require__);",
|
470
|
-
"parentChunkLoadingFunction(data);",
|
422
|
+
"if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);",
|
471
423
|
"while(resolves.length) {",
|
472
424
|
Template.indent("resolves.shift()();"),
|
473
425
|
"}",
|
@@ -485,10 +437,57 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
485
437
|
)}`,
|
486
438
|
"",
|
487
439
|
`var chunkLoadingGlobal = ${chunkLoadingGlobalExpr} = ${chunkLoadingGlobalExpr} || [];`,
|
488
|
-
"
|
489
|
-
"chunkLoadingGlobal.push = webpackJsonpCallback;"
|
440
|
+
"chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));",
|
441
|
+
"chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));"
|
442
|
+
])
|
443
|
+
: "// no jsonp function",
|
444
|
+
"",
|
445
|
+
withDefer
|
446
|
+
? Template.asString([
|
447
|
+
"function checkDeferredModulesImpl() {",
|
448
|
+
Template.indent([
|
449
|
+
"var result;",
|
450
|
+
"for(var i = 0; i < deferredModules.length; i++) {",
|
451
|
+
Template.indent([
|
452
|
+
"var deferredModule = deferredModules[i];",
|
453
|
+
"var fulfilled = true;",
|
454
|
+
"for(var j = 1; j < deferredModule.length; j++) {",
|
455
|
+
Template.indent([
|
456
|
+
"var depId = deferredModule[j];",
|
457
|
+
"if(installedChunks[depId] !== 0) fulfilled = false;"
|
458
|
+
]),
|
459
|
+
"}",
|
460
|
+
"if(fulfilled) {",
|
461
|
+
Template.indent([
|
462
|
+
"deferredModules.splice(i--, 1);",
|
463
|
+
"result = " +
|
464
|
+
"__webpack_require__(" +
|
465
|
+
`${RuntimeGlobals.entryModuleId} = deferredModule[0]);`
|
466
|
+
]),
|
467
|
+
"}"
|
468
|
+
]),
|
469
|
+
"}",
|
470
|
+
"if(deferredModules.length === 0) {",
|
471
|
+
Template.indent([
|
472
|
+
`${RuntimeGlobals.startup}();`,
|
473
|
+
`${
|
474
|
+
RuntimeGlobals.startup
|
475
|
+
} = ${runtimeTemplate.emptyFunction()};`
|
476
|
+
]),
|
477
|
+
"}",
|
478
|
+
"return result;"
|
479
|
+
]),
|
480
|
+
"}",
|
481
|
+
`var startup = ${RuntimeGlobals.startup};`,
|
482
|
+
`${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction("", [
|
483
|
+
"// reset startup function so it can be called again when more startup code is added",
|
484
|
+
`${
|
485
|
+
RuntimeGlobals.startup
|
486
|
+
} = startup || (${runtimeTemplate.emptyFunction()});`,
|
487
|
+
"return (checkDeferredModules = checkDeferredModulesImpl)();"
|
488
|
+
])};`
|
490
489
|
])
|
491
|
-
: "// no
|
490
|
+
: "// no deferred startup"
|
492
491
|
]);
|
493
492
|
}
|
494
493
|
}
|
@@ -14,7 +14,7 @@ const { getUndoPath } = require("../util/identifier");
|
|
14
14
|
|
15
15
|
class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
16
16
|
constructor(runtimeRequirements) {
|
17
|
-
super("importScripts chunk loading",
|
17
|
+
super("importScripts chunk loading", RuntimeModule.STAGE_ATTACH);
|
18
18
|
this.runtimeRequirements = runtimeRequirements;
|
19
19
|
}
|
20
20
|
|
package/package.json
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.11.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",
|
7
7
|
"dependencies": {
|
8
8
|
"@types/eslint-scope": "^3.7.0",
|
9
9
|
"@types/estree": "^0.0.45",
|
10
|
-
"@webassemblyjs/ast": "1.9.
|
11
|
-
"@webassemblyjs/helper-module-context": "1.9.
|
12
|
-
"@webassemblyjs/wasm-edit": "1.9.
|
13
|
-
"@webassemblyjs/wasm-parser": "1.9.
|
10
|
+
"@webassemblyjs/ast": "1.9.1",
|
11
|
+
"@webassemblyjs/helper-module-context": "1.9.1",
|
12
|
+
"@webassemblyjs/wasm-edit": "1.9.1",
|
13
|
+
"@webassemblyjs/wasm-parser": "1.9.1",
|
14
14
|
"acorn": "^8.0.4",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
@@ -53,7 +53,7 @@
|
|
53
53
|
"es5-ext": "^0.10.53",
|
54
54
|
"es6-promise-polyfill": "^1.2.0",
|
55
55
|
"eslint": "^7.14.0",
|
56
|
-
"eslint-config-prettier": "^
|
56
|
+
"eslint-config-prettier": "^7.0.0",
|
57
57
|
"eslint-plugin-jest": "^24.1.3",
|
58
58
|
"eslint-plugin-jsdoc": "^30.7.8",
|
59
59
|
"eslint-plugin-node": "^11.0.0",
|
@@ -69,7 +69,7 @@
|
|
69
69
|
"json-loader": "^0.5.7",
|
70
70
|
"json5": "^2.1.3",
|
71
71
|
"less": "^3.12.2",
|
72
|
-
"less-loader": "^
|
72
|
+
"less-loader": "^7.1.0",
|
73
73
|
"lint-staged": "^10.2.11",
|
74
74
|
"loader-utils": "^2.0.0",
|
75
75
|
"lodash": "^4.17.19",
|
@@ -92,7 +92,7 @@
|
|
92
92
|
"style-loader": "^2.0.0",
|
93
93
|
"terser": "^5.5.0",
|
94
94
|
"toml": "^3.0.0",
|
95
|
-
"tooling": "webpack/tooling#v1.10.
|
95
|
+
"tooling": "webpack/tooling#v1.10.2",
|
96
96
|
"ts-loader": "^8.0.2",
|
97
97
|
"typescript": "^4.2.0-dev.20201130",
|
98
98
|
"url-loader": "^4.1.0",
|