webpack 5.51.0 → 5.52.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/ChunkGraph.js +75 -1
- package/lib/Compilation.js +7 -0
- package/lib/Compiler.js +7 -0
- package/lib/EvalSourceMapDevToolPlugin.js +2 -2
- package/lib/ExternalModule.js +25 -16
- package/lib/FileSystemInfo.js +11 -12
- package/lib/HotModuleReplacementPlugin.js +14 -0
- package/lib/InitFragment.js +23 -0
- package/lib/NormalModule.js +10 -2
- package/lib/NormalModuleFactory.js +7 -4
- package/lib/RuntimeModule.js +2 -1
- package/lib/SourceMapDevToolPlugin.js +2 -2
- package/lib/Watching.js +8 -10
- package/lib/WebpackOptionsApply.js +1 -3
- package/lib/cache/PackFileCacheStrategy.js +172 -52
- package/lib/config/defaults.js +0 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +6 -2
- package/lib/dependencies/LoaderPlugin.js +94 -98
- package/lib/library/ModuleLibraryPlugin.js +4 -0
- package/lib/optimize/ConcatenatedModule.js +3 -3
- package/lib/optimize/MangleExportsPlugin.js +21 -4
- package/lib/optimize/SplitChunksPlugin.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -0
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -1
- package/lib/serialization/ObjectMiddleware.js +4 -4
- package/lib/util/identifier.js +26 -8
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/propertyAccess.js +54 -1
- package/lib/util/serialization.js +6 -2
- package/package.json +3 -2
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +0 -4
- package/types.d.ts +13 -5
@@ -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");
|
@@ -39,13 +39,28 @@ const comparator = compareSelect(e => e.name, compareStringsNumeric);
|
|
39
39
|
/**
|
40
40
|
* @param {boolean} deterministic use deterministic names
|
41
41
|
* @param {ExportsInfo} exportsInfo exports info
|
42
|
+
* @param {boolean} isNamespace is namespace object
|
42
43
|
* @returns {void}
|
43
44
|
*/
|
44
|
-
const mangleExportsInfo = (deterministic, exportsInfo) => {
|
45
|
+
const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
|
45
46
|
if (!canMangle(exportsInfo)) return;
|
46
47
|
const usedNames = new Set();
|
47
48
|
/** @type {ExportInfo[]} */
|
48
49
|
const mangleableExports = [];
|
50
|
+
|
51
|
+
// Avoid to renamed exports that are not provided when
|
52
|
+
// 1. it's not a namespace export: non-provided exports can be found in prototype chain
|
53
|
+
// 2. there are other provided exports and deterministic mode is chosen:
|
54
|
+
// non-provided exports would break the determinism
|
55
|
+
let avoidMangleNonProvided = !isNamespace;
|
56
|
+
if (!avoidMangleNonProvided && deterministic) {
|
57
|
+
for (const exportInfo of exportsInfo.ownedExports) {
|
58
|
+
if (exportInfo.provided !== false) {
|
59
|
+
avoidMangleNonProvided = true;
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
49
64
|
for (const exportInfo of exportsInfo.ownedExports) {
|
50
65
|
const name = exportInfo.name;
|
51
66
|
if (!exportInfo.hasUsedName()) {
|
@@ -59,7 +74,7 @@ const mangleExportsInfo = (deterministic, exportsInfo) => {
|
|
59
74
|
name.length === 2 &&
|
60
75
|
/^[a-zA-Z_$][a-zA-Z0-9_$]|^[1-9][0-9]/.test(name)) ||
|
61
76
|
// Don't rename exports that are not provided
|
62
|
-
exportInfo.provided !== true
|
77
|
+
(avoidMangleNonProvided && exportInfo.provided !== true)
|
63
78
|
) {
|
64
79
|
exportInfo.setUsedName(name);
|
65
80
|
usedNames.add(name);
|
@@ -73,7 +88,7 @@ const mangleExportsInfo = (deterministic, exportsInfo) => {
|
|
73
88
|
used === UsageState.OnlyPropertiesUsed ||
|
74
89
|
used === UsageState.Unused
|
75
90
|
) {
|
76
|
-
mangleExportsInfo(deterministic, exportInfo.exportsInfo);
|
91
|
+
mangleExportsInfo(deterministic, exportInfo.exportsInfo, false);
|
77
92
|
}
|
78
93
|
}
|
79
94
|
}
|
@@ -143,8 +158,10 @@ class MangleExportsPlugin {
|
|
143
158
|
"MangleExportsPlugin",
|
144
159
|
modules => {
|
145
160
|
for (const module of modules) {
|
161
|
+
const isNamespace =
|
162
|
+
module.buildMeta && module.buildMeta.exportsType === "namespace";
|
146
163
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
147
|
-
mangleExportsInfo(deterministic, exportsInfo);
|
164
|
+
mangleExportsInfo(deterministic, exportsInfo, isNamespace);
|
148
165
|
}
|
149
166
|
}
|
150
167
|
);
|
@@ -1073,7 +1073,7 @@ module.exports = class SplitChunksPlugin {
|
|
1073
1073
|
"SplitChunksPlugin\n" +
|
1074
1074
|
`Cache group "${cacheGroup.key}" conflicts with existing chunk.\n` +
|
1075
1075
|
`Both have the same name "${name}" and existing chunk is not a parent of the selected modules.\n` +
|
1076
|
-
"Use a different name for the cache group or make sure that the existing chunk is a parent (e. g. via
|
1076
|
+
"Use a different name for the cache group or make sure that the existing chunk is a parent (e. g. via dependOn).\n" +
|
1077
1077
|
'HINT: You can omit "name" to automatically create a name.\n' +
|
1078
1078
|
"BREAKING CHANGE: webpack < 5 used to allow to use an entrypoint as splitChunk. " +
|
1079
1079
|
"This is no longer allowed when the entrypoint is not a parent of the selected modules.\n" +
|
@@ -30,7 +30,7 @@ class RelativeUrlRuntimeModule extends HelperRuntimeModule {
|
|
30
30
|
`values.toString = values.toJSON = ${runtimeTemplate.returningFunction(
|
31
31
|
"url"
|
32
32
|
)};`,
|
33
|
-
"for (var key in values) Object.defineProperty(this, key,
|
33
|
+
"for (var key in values) Object.defineProperty(this, key, { enumerable: true, configurable: true, value: values[key] });"
|
34
34
|
]),
|
35
35
|
"};",
|
36
36
|
`${RuntimeGlobals.relativeUrl}.prototype = URL.prototype;`
|
@@ -510,11 +510,11 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
510
510
|
} else if (SerializerMiddleware.isLazy(item, this)) {
|
511
511
|
throw new Error("Not implemented");
|
512
512
|
} else {
|
513
|
-
|
514
|
-
|
515
|
-
this.serialize([data], context)
|
516
|
-
)
|
513
|
+
const data = SerializerMiddleware.serializeLazy(item, data =>
|
514
|
+
this.serialize([data], context)
|
517
515
|
);
|
516
|
+
SerializerMiddleware.setLazySerializedValue(item, data);
|
517
|
+
result.push(data);
|
518
518
|
}
|
519
519
|
} else if (item === undefined) {
|
520
520
|
result.push(ESCAPE, ESCAPE_UNDEFINED);
|
package/lib/util/identifier.js
CHANGED
@@ -15,6 +15,13 @@ const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
15
15
|
* @property {Map<string, Map<string, string>>=} relativePaths
|
16
16
|
*/
|
17
17
|
|
18
|
+
const relativePathToRequest = relativePath => {
|
19
|
+
if (relativePath === "") return "./.";
|
20
|
+
if (relativePath === "..") return "../.";
|
21
|
+
if (relativePath.startsWith("../")) return relativePath;
|
22
|
+
return `./${relativePath}`;
|
23
|
+
};
|
24
|
+
|
18
25
|
/**
|
19
26
|
* @param {string} context context for relative path
|
20
27
|
* @param {string} maybeAbsolutePath path to make relative
|
@@ -36,10 +43,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
|
|
36
43
|
querySplitPos === -1
|
37
44
|
? maybeAbsolutePath
|
38
45
|
: maybeAbsolutePath.slice(0, querySplitPos);
|
39
|
-
resource = path.posix.relative(context, resource);
|
40
|
-
if (!resource.startsWith("../")) {
|
41
|
-
resource = "./" + resource;
|
42
|
-
}
|
46
|
+
resource = relativePathToRequest(path.posix.relative(context, resource));
|
43
47
|
return querySplitPos === -1
|
44
48
|
? resource
|
45
49
|
: resource + maybeAbsolutePath.slice(querySplitPos);
|
@@ -53,10 +57,9 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
|
|
53
57
|
: maybeAbsolutePath.slice(0, querySplitPos);
|
54
58
|
resource = path.win32.relative(context, resource);
|
55
59
|
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
|
56
|
-
resource =
|
57
|
-
|
58
|
-
|
59
|
-
}
|
60
|
+
resource = relativePathToRequest(
|
61
|
+
resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/")
|
62
|
+
);
|
60
63
|
}
|
61
64
|
return querySplitPos === -1
|
62
65
|
? resource
|
@@ -214,6 +217,21 @@ const _makePathsRelative = (context, identifier) => {
|
|
214
217
|
|
215
218
|
exports.makePathsRelative = makeCacheable(_makePathsRelative);
|
216
219
|
|
220
|
+
/**
|
221
|
+
*
|
222
|
+
* @param {string} context context for relative path
|
223
|
+
* @param {string} identifier identifier for path
|
224
|
+
* @returns {string} a converted relative path
|
225
|
+
*/
|
226
|
+
const _makePathsAbsolute = (context, identifier) => {
|
227
|
+
return identifier
|
228
|
+
.split(SEGMENTS_SPLIT_REGEXP)
|
229
|
+
.map(str => requestToAbsolute(context, str))
|
230
|
+
.join("");
|
231
|
+
};
|
232
|
+
|
233
|
+
exports.makePathsAbsolute = makeCacheable(_makePathsAbsolute);
|
234
|
+
|
217
235
|
/**
|
218
236
|
* @param {string} context absolute context path
|
219
237
|
* @param {string} request any request string may containing absolute paths, query string, etc.
|
@@ -164,6 +164,7 @@ module.exports = {
|
|
164
164
|
DllModule: () => require("../DllModule"),
|
165
165
|
ExternalModule: () => require("../ExternalModule"),
|
166
166
|
FileSystemInfo: () => require("../FileSystemInfo"),
|
167
|
+
InitFragment: () => require("../InitFragment"),
|
167
168
|
InvalidDependenciesModuleWarning: () =>
|
168
169
|
require("../InvalidDependenciesModuleWarning"),
|
169
170
|
Module: () => require("../Module"),
|
@@ -6,6 +6,59 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const SAFE_IDENTIFIER = /^[_a-zA-Z$][_a-zA-Z$0-9]*$/;
|
9
|
+
const RESERVED_IDENTIFER = new Set([
|
10
|
+
"break",
|
11
|
+
"case",
|
12
|
+
"catch",
|
13
|
+
"class",
|
14
|
+
"const",
|
15
|
+
"continue",
|
16
|
+
"debugger",
|
17
|
+
"default",
|
18
|
+
"delete",
|
19
|
+
"do",
|
20
|
+
"else",
|
21
|
+
"export",
|
22
|
+
"extends",
|
23
|
+
"finally",
|
24
|
+
"for",
|
25
|
+
"function",
|
26
|
+
"if",
|
27
|
+
"import",
|
28
|
+
"in",
|
29
|
+
"instanceof",
|
30
|
+
"new",
|
31
|
+
"return",
|
32
|
+
"super",
|
33
|
+
"switch",
|
34
|
+
"this",
|
35
|
+
"throw",
|
36
|
+
"try",
|
37
|
+
"typeof",
|
38
|
+
"var",
|
39
|
+
"void",
|
40
|
+
"while",
|
41
|
+
"with",
|
42
|
+
"enum",
|
43
|
+
// strict mode
|
44
|
+
"implements",
|
45
|
+
"interface",
|
46
|
+
"let",
|
47
|
+
"package",
|
48
|
+
"private",
|
49
|
+
"protected",
|
50
|
+
"public",
|
51
|
+
"static",
|
52
|
+
"yield",
|
53
|
+
"yield",
|
54
|
+
// module code
|
55
|
+
"await",
|
56
|
+
// skip future reserved keywords defined under ES1 till ES3
|
57
|
+
// additional
|
58
|
+
"null",
|
59
|
+
"true",
|
60
|
+
"false"
|
61
|
+
]);
|
9
62
|
|
10
63
|
const propertyAccess = (properties, start = 0) => {
|
11
64
|
let str = "";
|
@@ -13,7 +66,7 @@ const propertyAccess = (properties, start = 0) => {
|
|
13
66
|
const p = properties[i];
|
14
67
|
if (`${+p}` === p) {
|
15
68
|
str += `[${p}]`;
|
16
|
-
} else if (SAFE_IDENTIFIER.test(p)) {
|
69
|
+
} else if (SAFE_IDENTIFIER.test(p) && !RESERVED_IDENTIFER.has(p)) {
|
17
70
|
str += `.${p}`;
|
18
71
|
} else {
|
19
72
|
str += `[${JSON.stringify(p)}]`;
|
@@ -111,9 +111,13 @@ module.exports = {
|
|
111
111
|
);
|
112
112
|
};
|
113
113
|
context.writeSeparate = (value, options) => {
|
114
|
-
|
115
|
-
|
114
|
+
const lazy = SerializerMiddleware.createLazy(
|
115
|
+
value,
|
116
|
+
fileMiddleware,
|
117
|
+
options
|
116
118
|
);
|
119
|
+
context.write(lazy);
|
120
|
+
return lazy;
|
117
121
|
};
|
118
122
|
}
|
119
123
|
}),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.52.1",
|
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",
|
@@ -58,7 +58,7 @@
|
|
58
58
|
"eslint-plugin-jest": "^24.3.6",
|
59
59
|
"eslint-plugin-jsdoc": "^33.0.0",
|
60
60
|
"eslint-plugin-node": "^11.0.0",
|
61
|
-
"eslint-plugin-prettier": "^
|
61
|
+
"eslint-plugin-prettier": "^4.0.0",
|
62
62
|
"file-loader": "^6.0.0",
|
63
63
|
"fork-ts-checker-webpack-plugin": "^6.0.5",
|
64
64
|
"husky": "^6.0.0",
|
@@ -66,6 +66,7 @@
|
|
66
66
|
"istanbul": "^0.4.5",
|
67
67
|
"jest": "^27.0.6",
|
68
68
|
"jest-circus": "^27.0.6",
|
69
|
+
"jest-cli": "^27.0.6",
|
69
70
|
"jest-diff": "^27.0.2",
|
70
71
|
"jest-junit": "^12.0.0",
|
71
72
|
"json-loader": "^0.5.7",
|