webpack 5.42.0 → 5.45.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/Compilation.js +5 -2
- package/lib/Compiler.js +4 -4
- package/lib/ExternalModule.js +18 -0
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +14 -15
- package/lib/FlagDependencyUsagePlugin.js +5 -1
- package/lib/MultiCompiler.js +10 -8
- package/lib/NormalModule.js +6 -2
- package/lib/NormalModuleFactory.js +9 -2
- package/lib/SourceMapDevToolPlugin.js +1 -1
- package/lib/Template.js +1 -0
- package/lib/Watching.js +12 -0
- package/lib/asset/AssetGenerator.js +2 -2
- package/lib/config/defaults.js +18 -12
- package/lib/container/ContainerPlugin.js +4 -1
- package/lib/container/ModuleFederationPlugin.js +1 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +6 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -2
- package/lib/dependencies/HarmonyImportDependency.js +5 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +40 -5
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -2
- package/lib/dependencies/ModuleDependency.js +8 -1
- package/lib/dependencies/WorkerPlugin.js +1 -1
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +29 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +91 -11
- package/lib/esm/ModuleChunkLoadingPlugin.js +13 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +46 -37
- package/lib/hmr/lazyCompilationBackend.js +5 -2
- package/lib/javascript/JavascriptParser.js +14 -9
- package/lib/json/JsonData.js +41 -0
- package/lib/json/JsonGenerator.js +8 -2
- package/lib/json/JsonParser.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +16 -0
- package/lib/optimize/RuntimeChunkPlugin.js +1 -1
- package/lib/rules/{DescriptionDataMatcherRulePlugin.js → ObjectMatcherRulePlugin.js} +14 -10
- package/lib/rules/RuleSetCompiler.js +2 -2
- package/lib/util/StackedCacheMap.js +110 -0
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/makeSerializable.js +0 -1
- package/lib/webpack.js +1 -1
- package/package.json +25 -18
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +16 -2
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +15 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +15 -0
- package/types.d.ts +60 -17
- package/lib/util/StackedSetMap.js +0 -166
@@ -8,28 +8,32 @@
|
|
8
8
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
9
9
|
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
10
10
|
|
11
|
-
|
11
|
+
class ObjectMatcherRulePlugin {
|
12
|
+
constructor(ruleProperty, dataProperty) {
|
13
|
+
this.ruleProperty = ruleProperty;
|
14
|
+
this.dataProperty = dataProperty || ruleProperty;
|
15
|
+
}
|
12
16
|
|
13
|
-
class DescriptionDataMatcherRulePlugin {
|
14
17
|
/**
|
15
18
|
* @param {RuleSetCompiler} ruleSetCompiler the rule set compiler
|
16
19
|
* @returns {void}
|
17
20
|
*/
|
18
21
|
apply(ruleSetCompiler) {
|
22
|
+
const { ruleProperty, dataProperty } = this;
|
19
23
|
ruleSetCompiler.hooks.rule.tap(
|
20
|
-
"
|
24
|
+
"ObjectMatcherRulePlugin",
|
21
25
|
(path, rule, unhandledProperties, result) => {
|
22
|
-
if (unhandledProperties.has(
|
23
|
-
unhandledProperties.delete(
|
24
|
-
const value = rule[
|
26
|
+
if (unhandledProperties.has(ruleProperty)) {
|
27
|
+
unhandledProperties.delete(ruleProperty);
|
28
|
+
const value = rule[ruleProperty];
|
25
29
|
for (const property of Object.keys(value)) {
|
26
|
-
const
|
30
|
+
const nestedDataProperties = property.split(".");
|
27
31
|
const condition = ruleSetCompiler.compileCondition(
|
28
|
-
`${path}.${
|
32
|
+
`${path}.${ruleProperty}.${property}`,
|
29
33
|
value[property]
|
30
34
|
);
|
31
35
|
result.conditions.push({
|
32
|
-
property: [
|
36
|
+
property: [dataProperty, ...nestedDataProperties],
|
33
37
|
matchWhenEmpty: condition.matchWhenEmpty,
|
34
38
|
fn: condition.fn
|
35
39
|
});
|
@@ -40,4 +44,4 @@ class DescriptionDataMatcherRulePlugin {
|
|
40
44
|
}
|
41
45
|
}
|
42
46
|
|
43
|
-
module.exports =
|
47
|
+
module.exports = ObjectMatcherRulePlugin;
|
@@ -225,7 +225,7 @@ class RuleSetCompiler {
|
|
225
225
|
if (typeof condition === "string") {
|
226
226
|
return {
|
227
227
|
matchWhenEmpty: condition.length === 0,
|
228
|
-
fn: str => str.startsWith(condition)
|
228
|
+
fn: str => typeof str === "string" && str.startsWith(condition)
|
229
229
|
};
|
230
230
|
}
|
231
231
|
if (typeof condition === "function") {
|
@@ -245,7 +245,7 @@ class RuleSetCompiler {
|
|
245
245
|
if (condition instanceof RegExp) {
|
246
246
|
return {
|
247
247
|
matchWhenEmpty: condition.test(""),
|
248
|
-
fn: v => condition.test(v)
|
248
|
+
fn: v => typeof v === "string" && condition.test(v)
|
249
249
|
};
|
250
250
|
}
|
251
251
|
if (Array.isArray(condition)) {
|
@@ -0,0 +1,110 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @template K
|
10
|
+
* @template V
|
11
|
+
*/
|
12
|
+
class StackedCacheMap {
|
13
|
+
constructor() {
|
14
|
+
/** @type {Map<K, V>} */
|
15
|
+
this.map = new Map();
|
16
|
+
/** @type {ReadonlyMap<K, V>[]} */
|
17
|
+
this.stack = [];
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @param {ReadonlyMap<K, V>} map map to add
|
22
|
+
* @param {boolean} immutable if 'map' is immutable and StackedCacheMap can keep referencing it
|
23
|
+
*/
|
24
|
+
addAll(map, immutable) {
|
25
|
+
if (immutable) {
|
26
|
+
this.stack.push(map);
|
27
|
+
|
28
|
+
// largest map should go first
|
29
|
+
for (let i = this.stack.length - 1; i > 0; i--) {
|
30
|
+
const beforeLast = this.stack[i - 1];
|
31
|
+
if (beforeLast.size >= map.size) break;
|
32
|
+
this.stack[i] = beforeLast;
|
33
|
+
this.stack[i - 1] = map;
|
34
|
+
}
|
35
|
+
} else {
|
36
|
+
for (const [key, value] of map) {
|
37
|
+
this.map.set(key, value);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @param {K} item the key of the element to add
|
44
|
+
* @param {V} value the value of the element to add
|
45
|
+
* @returns {void}
|
46
|
+
*/
|
47
|
+
set(item, value) {
|
48
|
+
this.map.set(item, value);
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @param {K} item the item to delete
|
53
|
+
* @returns {void}
|
54
|
+
*/
|
55
|
+
delete(item) {
|
56
|
+
throw new Error("Items can't be deleted from a StackedCacheMap");
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* @param {K} item the item to test
|
61
|
+
* @returns {boolean} true if the item exists in this set
|
62
|
+
*/
|
63
|
+
has(item) {
|
64
|
+
throw new Error(
|
65
|
+
"Checking StackedCacheMap.has before reading is inefficient, use StackedCacheMap.get and check for undefined"
|
66
|
+
);
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @param {K} item the key of the element to return
|
71
|
+
* @returns {V} the value of the element
|
72
|
+
*/
|
73
|
+
get(item) {
|
74
|
+
for (const map of this.stack) {
|
75
|
+
const value = map.get(item);
|
76
|
+
if (value !== undefined) return value;
|
77
|
+
}
|
78
|
+
return this.map.get(item);
|
79
|
+
}
|
80
|
+
|
81
|
+
clear() {
|
82
|
+
this.stack.length = 0;
|
83
|
+
this.map.clear();
|
84
|
+
}
|
85
|
+
|
86
|
+
get size() {
|
87
|
+
let size = this.map.size;
|
88
|
+
for (const map of this.stack) {
|
89
|
+
size += map.size;
|
90
|
+
}
|
91
|
+
return size;
|
92
|
+
}
|
93
|
+
|
94
|
+
[Symbol.iterator]() {
|
95
|
+
const iterators = this.stack.map(map => map[Symbol.iterator]());
|
96
|
+
let current = this.map[Symbol.iterator]();
|
97
|
+
return {
|
98
|
+
next() {
|
99
|
+
let result = current.next();
|
100
|
+
while (result.done && iterators.length > 0) {
|
101
|
+
current = iterators.pop();
|
102
|
+
result = current.next();
|
103
|
+
}
|
104
|
+
return result;
|
105
|
+
}
|
106
|
+
};
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
module.exports = StackedCacheMap;
|
@@ -156,6 +156,7 @@ module.exports = {
|
|
156
156
|
require("../dependencies/WebpackIsIncludedDependency"),
|
157
157
|
"dependencies/WorkerDependency": () =>
|
158
158
|
require("../dependencies/WorkerDependency"),
|
159
|
+
"json/JsonData": () => require("../json/JsonData"),
|
159
160
|
"optimize/ConcatenatedModule": () =>
|
160
161
|
require("../optimize/ConcatenatedModule"),
|
161
162
|
DelegatedModule: () => require("../DelegatedModule"),
|
package/lib/webpack.js
CHANGED
@@ -152,7 +152,7 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
|
152
152
|
if (watch) {
|
153
153
|
util.deprecate(
|
154
154
|
() => {},
|
155
|
-
"A 'callback' argument
|
155
|
+
"A 'callback' argument needs to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
|
156
156
|
"DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
|
157
157
|
)();
|
158
158
|
}
|
package/package.json
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.45.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
|
-
"@types/estree": "^0.0.
|
10
|
-
"@webassemblyjs/ast": "1.11.
|
11
|
-
"@webassemblyjs/wasm-edit": "1.11.
|
12
|
-
"@webassemblyjs/wasm-parser": "1.11.
|
9
|
+
"@types/estree": "^0.0.50",
|
10
|
+
"@webassemblyjs/ast": "1.11.1",
|
11
|
+
"@webassemblyjs/wasm-edit": "1.11.1",
|
12
|
+
"@webassemblyjs/wasm-parser": "1.11.1",
|
13
13
|
"acorn": "^8.4.1",
|
14
|
+
"acorn-import-assertions": "1.7.1",
|
14
15
|
"browserslist": "^4.14.5",
|
15
16
|
"chrome-trace-event": "^1.0.2",
|
16
17
|
"enhanced-resolve": "^5.8.0",
|
17
|
-
"es-module-lexer": "^0.
|
18
|
+
"es-module-lexer": "^0.7.1",
|
18
19
|
"eslint-scope": "5.1.1",
|
19
20
|
"events": "^3.2.0",
|
20
21
|
"glob-to-regexp": "^0.4.1",
|
@@ -23,7 +24,7 @@
|
|
23
24
|
"loader-runner": "^4.2.0",
|
24
25
|
"mime-types": "^2.1.27",
|
25
26
|
"neo-async": "^2.6.2",
|
26
|
-
"schema-utils": "^3.
|
27
|
+
"schema-utils": "^3.1.0",
|
27
28
|
"tapable": "^2.1.1",
|
28
29
|
"terser-webpack-plugin": "^5.1.3",
|
29
30
|
"watchpack": "^2.2.0",
|
@@ -38,7 +39,7 @@
|
|
38
39
|
"@babel/core": "^7.11.1",
|
39
40
|
"@babel/preset-react": "^7.10.4",
|
40
41
|
"@types/es-module-lexer": "^0.4.1",
|
41
|
-
"@types/jest": "^26.0.
|
42
|
+
"@types/jest": "^26.0.24",
|
42
43
|
"@types/node": "^15.0.1",
|
43
44
|
"babel-loader": "^8.1.0",
|
44
45
|
"benchmark": "^2.1.4",
|
@@ -54,7 +55,7 @@
|
|
54
55
|
"es6-promise-polyfill": "^1.2.0",
|
55
56
|
"eslint": "^7.14.0",
|
56
57
|
"eslint-config-prettier": "^8.1.0",
|
57
|
-
"eslint-plugin-jest": "^24.
|
58
|
+
"eslint-plugin-jest": "^24.3.6",
|
58
59
|
"eslint-plugin-jsdoc": "^33.0.0",
|
59
60
|
"eslint-plugin-node": "^11.0.0",
|
60
61
|
"eslint-plugin-prettier": "^3.1.4",
|
@@ -63,7 +64,8 @@
|
|
63
64
|
"husky": "^6.0.0",
|
64
65
|
"is-ci": "^3.0.0",
|
65
66
|
"istanbul": "^0.4.5",
|
66
|
-
"jest": "^
|
67
|
+
"jest": "^27.0.6",
|
68
|
+
"jest-circus": "^27.0.6",
|
67
69
|
"jest-diff": "^27.0.2",
|
68
70
|
"jest-junit": "^12.0.0",
|
69
71
|
"json-loader": "^0.5.7",
|
@@ -75,7 +77,7 @@
|
|
75
77
|
"lodash": "^4.17.19",
|
76
78
|
"lodash-es": "^4.17.15",
|
77
79
|
"memfs": "^3.2.0",
|
78
|
-
"mini-css-extract-plugin": "^1.
|
80
|
+
"mini-css-extract-plugin": "^1.6.1",
|
79
81
|
"mini-svg-data-uri": "^1.2.3",
|
80
82
|
"nyc": "^15.1.0",
|
81
83
|
"open-cli": "^6.0.1",
|
@@ -131,10 +133,11 @@
|
|
131
133
|
],
|
132
134
|
"scripts": {
|
133
135
|
"setup": "node ./setup/setup.js",
|
134
|
-
"
|
136
|
+
"jest": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
|
137
|
+
"test": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
|
135
138
|
"test:update-snapshots": "yarn jest -u",
|
136
|
-
"test:integration": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\"",
|
137
|
-
"test:basic": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/
|
139
|
+
"test:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
|
140
|
+
"test:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\"",
|
138
141
|
"test:unit": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
|
139
142
|
"travis:integration": "yarn cover:integration --ci $JEST",
|
140
143
|
"travis:basic": "yarn cover:basic --ci $JEST",
|
@@ -165,12 +168,14 @@
|
|
165
168
|
"benchmark": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
|
166
169
|
"cover": "yarn cover:all && yarn cover:report",
|
167
170
|
"cover:clean": "rimraf .nyc_output coverage",
|
168
|
-
"cover:all": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --coverage",
|
169
|
-
"cover:basic": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/
|
170
|
-
"cover:integration": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\" --coverage",
|
171
|
+
"cover:all": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --coverage",
|
172
|
+
"cover:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\" --coverage",
|
173
|
+
"cover:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" --coverage",
|
174
|
+
"cover:integration:a": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage",
|
175
|
+
"cover:integration:b": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.longtest.js\" --coverage",
|
171
176
|
"cover:unit": "node --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
|
172
177
|
"cover:types": "node node_modules/tooling/type-coverage",
|
173
|
-
"cover:merge": "nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
|
178
|
+
"cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
|
174
179
|
"cover:report": "nyc report -t coverage"
|
175
180
|
},
|
176
181
|
"lint-staged": {
|
@@ -191,6 +196,8 @@
|
|
191
196
|
],
|
192
197
|
"testMatch": [
|
193
198
|
"<rootDir>/test/*.test.js",
|
199
|
+
"<rootDir>/test/*.basictest.js",
|
200
|
+
"<rootDir>/test/*.longtest.js",
|
194
201
|
"<rootDir>/test/*.unittest.js"
|
195
202
|
],
|
196
203
|
"watchPathIgnorePatterns": [
|