webpack 5.51.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/lib/EvalSourceMapDevToolPlugin.js +2 -2
- package/lib/FileSystemInfo.js +2 -0
- package/lib/NormalModule.js +10 -2
- package/lib/SourceMapDevToolPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +4 -0
- package/lib/optimize/ConcatenatedModule.js +3 -3
- package/lib/util/identifier.js +26 -8
- package/package.json +1 -1
@@ -11,7 +11,7 @@ const NormalModule = require("./NormalModule");
|
|
11
11
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
12
12
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
13
13
|
const ConcatenatedModule = require("./optimize/ConcatenatedModule");
|
14
|
-
const {
|
14
|
+
const { makePathsAbsolute } = require("./util/identifier");
|
15
15
|
|
16
16
|
/** @typedef {import("webpack-sources").Source} Source */
|
17
17
|
/** @typedef {import("../declarations/WebpackOptions").DevTool} DevToolOptions */
|
@@ -125,7 +125,7 @@ class EvalSourceMapDevToolPlugin {
|
|
125
125
|
const root = compiler.root;
|
126
126
|
const modules = sourceMap.sources.map(source => {
|
127
127
|
if (!source.startsWith("webpack://")) return source;
|
128
|
-
source =
|
128
|
+
source = makePathsAbsolute(context, source.slice(10), root);
|
129
129
|
const module = compilation.findModule(source);
|
130
130
|
return module || source;
|
131
131
|
});
|
package/lib/FileSystemInfo.js
CHANGED
@@ -813,6 +813,7 @@ const getManagedItem = (managedPath, path) => {
|
|
813
813
|
*/
|
814
814
|
const getResolvedTimestamp = entry => {
|
815
815
|
if (entry === "ignore") return undefined;
|
816
|
+
if (entry === null) return null;
|
816
817
|
if (entry.resolved !== undefined) return entry.resolved;
|
817
818
|
return entry.symlinks === undefined ? entry : undefined;
|
818
819
|
};
|
@@ -822,6 +823,7 @@ const getResolvedTimestamp = entry => {
|
|
822
823
|
* @returns {string | undefined} the resolved entry
|
823
824
|
*/
|
824
825
|
const getResolvedHash = entry => {
|
826
|
+
if (entry === null) return null;
|
825
827
|
if (entry.resolved !== undefined) return entry.resolved;
|
826
828
|
return entry.symlinks === undefined ? entry.hash : undefined;
|
827
829
|
};
|
package/lib/NormalModule.js
CHANGED
@@ -38,7 +38,11 @@ const {
|
|
38
38
|
} = require("./util/comparators");
|
39
39
|
const createHash = require("./util/createHash");
|
40
40
|
const { join } = require("./util/fs");
|
41
|
-
const {
|
41
|
+
const {
|
42
|
+
contextify,
|
43
|
+
absolutify,
|
44
|
+
makePathsRelative
|
45
|
+
} = require("./util/identifier");
|
42
46
|
const makeSerializable = require("./util/makeSerializable");
|
43
47
|
const memoize = require("./util/memoize");
|
44
48
|
|
@@ -102,7 +106,11 @@ const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/;
|
|
102
106
|
*/
|
103
107
|
const contextifySourceUrl = (context, source, associatedObjectForCache) => {
|
104
108
|
if (source.startsWith("webpack://")) return source;
|
105
|
-
return `webpack://${
|
109
|
+
return `webpack://${makePathsRelative(
|
110
|
+
context,
|
111
|
+
source,
|
112
|
+
associatedObjectForCache
|
113
|
+
)}`;
|
106
114
|
};
|
107
115
|
|
108
116
|
/**
|
@@ -14,7 +14,7 @@ const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOpt
|
|
14
14
|
const createSchemaValidation = require("./util/create-schema-validation");
|
15
15
|
const createHash = require("./util/createHash");
|
16
16
|
const { relative, dirname } = require("./util/fs");
|
17
|
-
const {
|
17
|
+
const { makePathsAbsolute } = require("./util/identifier");
|
18
18
|
|
19
19
|
/** @typedef {import("webpack-sources").MapOptions} MapOptions */
|
20
20
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -91,7 +91,7 @@ const getTaskForFile = (
|
|
91
91
|
if (!sourceMap || typeof source !== "string") return;
|
92
92
|
const context = compilation.options.context;
|
93
93
|
const root = compilation.compiler.root;
|
94
|
-
const cachedAbsolutify =
|
94
|
+
const cachedAbsolutify = makePathsAbsolute.bindContextCache(context, root);
|
95
95
|
const modules = sourceMap.sources.map(source => {
|
96
96
|
if (!source.startsWith("webpack://")) return source;
|
97
97
|
source = cachedAbsolutify(source.slice(10));
|
@@ -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(
|
@@ -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");
|
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.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.51.
|
3
|
+
"version": "5.51.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",
|