webpack 5.72.0 → 5.74.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/README.md +16 -9
- package/lib/Compilation.js +5 -1
- package/lib/Compiler.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/FileSystemInfo.js +35 -14
- package/lib/NodeStuffPlugin.js +3 -3
- package/lib/NormalModule.js +1 -1
- package/lib/RuntimePlugin.js +7 -0
- package/lib/config/defaults.js +12 -4
- package/lib/container/ModuleFederationPlugin.js +2 -0
- package/lib/css/CssLoadingRuntimeModule.js +9 -7
- package/lib/dependencies/CommonJsImportsParserPlugin.js +342 -61
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsRequireDependency.js +2 -1
- package/lib/dependencies/ContextDependency.js +15 -2
- package/lib/dependencies/ContextDependencyHelpers.js +18 -5
- package/lib/dependencies/ContextElementDependency.js +0 -16
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +35 -3
- package/lib/dependencies/ImportParserPlugin.js +31 -25
- package/lib/dependencies/JsonExportsDependency.js +17 -21
- package/lib/dependencies/LoaderDependency.js +13 -0
- package/lib/dependencies/LoaderImportDependency.js +13 -0
- package/lib/dependencies/ModuleDependency.js +11 -1
- package/lib/dependencies/ProvidedDependency.js +31 -8
- package/lib/dependencies/RequireResolveContextDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -1
- package/lib/dependencies/URLPlugin.js +21 -0
- package/lib/index.js +4 -0
- package/lib/javascript/JavascriptParser.js +47 -21
- package/lib/json/JsonData.js +8 -0
- package/lib/json/JsonParser.js +4 -6
- package/lib/optimize/ConcatenatedModule.js +40 -17
- package/lib/optimize/ModuleConcatenationPlugin.js +1 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -58
- package/lib/runtime/LoadScriptRuntimeModule.js +9 -7
- package/lib/runtime/NonceRuntimeModule.js +24 -0
- package/lib/sharing/ProvideSharedPlugin.js +1 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +11 -9
- package/package.json +6 -5
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +60 -0
- package/types.d.ts +94 -4
@@ -165,6 +165,14 @@ class JavascriptParser extends Parser {
|
|
165
165
|
evaluateDefinedIdentifier: new HookMap(
|
166
166
|
() => new SyncBailHook(["expression"])
|
167
167
|
),
|
168
|
+
/** @type {HookMap<SyncBailHook<[NewExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
|
169
|
+
evaluateNewExpression: new HookMap(
|
170
|
+
() => new SyncBailHook(["expression"])
|
171
|
+
),
|
172
|
+
/** @type {HookMap<SyncBailHook<[CallExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
|
173
|
+
evaluateCallExpression: new HookMap(
|
174
|
+
() => new SyncBailHook(["expression"])
|
175
|
+
),
|
168
176
|
/** @type {HookMap<SyncBailHook<[CallExpressionNode, BasicEvaluatedExpression | undefined], BasicEvaluatedExpression | undefined | null>>} */
|
169
177
|
evaluateCallExpressionMember: new HookMap(
|
170
178
|
() => new SyncBailHook(["expression", "param"])
|
@@ -361,9 +369,14 @@ class JavascriptParser extends Parser {
|
|
361
369
|
this.hooks.evaluate.for("NewExpression").tap("JavascriptParser", _expr => {
|
362
370
|
const expr = /** @type {NewExpressionNode} */ (_expr);
|
363
371
|
const callee = expr.callee;
|
364
|
-
if (
|
365
|
-
|
366
|
-
|
372
|
+
if (callee.type !== "Identifier") return;
|
373
|
+
if (callee.name !== "RegExp") {
|
374
|
+
return this.callHooksForName(
|
375
|
+
this.hooks.evaluateNewExpression,
|
376
|
+
callee.name,
|
377
|
+
expr
|
378
|
+
);
|
379
|
+
} else if (
|
367
380
|
expr.arguments.length > 2 ||
|
368
381
|
this.getVariableInfo("RegExp") !== "RegExp"
|
369
382
|
)
|
@@ -1036,24 +1049,28 @@ class JavascriptParser extends Parser {
|
|
1036
1049
|
this.hooks.evaluate.for("CallExpression").tap("JavascriptParser", _expr => {
|
1037
1050
|
const expr = /** @type {CallExpressionNode} */ (_expr);
|
1038
1051
|
if (
|
1039
|
-
expr.callee.type
|
1040
|
-
expr.callee.property.type
|
1052
|
+
expr.callee.type === "MemberExpression" &&
|
1053
|
+
expr.callee.property.type ===
|
1041
1054
|
(expr.callee.computed ? "Literal" : "Identifier")
|
1042
1055
|
) {
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
if (
|
1056
|
-
return
|
1056
|
+
// type Super also possible here
|
1057
|
+
const param = this.evaluateExpression(
|
1058
|
+
/** @type {ExpressionNode} */ (expr.callee.object)
|
1059
|
+
);
|
1060
|
+
const property =
|
1061
|
+
expr.callee.property.type === "Literal"
|
1062
|
+
? `${expr.callee.property.value}`
|
1063
|
+
: expr.callee.property.name;
|
1064
|
+
const hook = this.hooks.evaluateCallExpressionMember.get(property);
|
1065
|
+
if (hook !== undefined) {
|
1066
|
+
return hook.call(expr, param);
|
1067
|
+
}
|
1068
|
+
} else if (expr.callee.type === "Identifier") {
|
1069
|
+
return this.callHooksForName(
|
1070
|
+
this.hooks.evaluateCallExpression,
|
1071
|
+
expr.callee.name,
|
1072
|
+
expr
|
1073
|
+
);
|
1057
1074
|
}
|
1058
1075
|
});
|
1059
1076
|
this.hooks.evaluateCallExpressionMember
|
@@ -1430,6 +1447,11 @@ class JavascriptParser extends Parser {
|
|
1430
1447
|
this.walkExpression(classElement.value);
|
1431
1448
|
this.scope.topLevelScope = wasTopLevel;
|
1432
1449
|
}
|
1450
|
+
} else if (classElement.type === "StaticBlock") {
|
1451
|
+
const wasTopLevel = this.scope.topLevelScope;
|
1452
|
+
this.scope.topLevelScope = false;
|
1453
|
+
this.walkBlockStatement(classElement);
|
1454
|
+
this.scope.topLevelScope = wasTopLevel;
|
1433
1455
|
}
|
1434
1456
|
}
|
1435
1457
|
}
|
@@ -1886,7 +1908,7 @@ class JavascriptParser extends Parser {
|
|
1886
1908
|
!this.hooks.importSpecifier.call(
|
1887
1909
|
statement,
|
1888
1910
|
source,
|
1889
|
-
specifier.imported.name,
|
1911
|
+
specifier.imported.name || specifier.imported.value,
|
1890
1912
|
name
|
1891
1913
|
)
|
1892
1914
|
) {
|
@@ -1956,7 +1978,7 @@ class JavascriptParser extends Parser {
|
|
1956
1978
|
const specifier = statement.specifiers[specifierIndex];
|
1957
1979
|
switch (specifier.type) {
|
1958
1980
|
case "ExportSpecifier": {
|
1959
|
-
const name = specifier.exported.name;
|
1981
|
+
const name = specifier.exported.name || specifier.exported.value;
|
1960
1982
|
if (source) {
|
1961
1983
|
this.hooks.exportImportSpecifier.call(
|
1962
1984
|
statement,
|
@@ -3603,6 +3625,10 @@ class JavascriptParser extends Parser {
|
|
3603
3625
|
}
|
3604
3626
|
}
|
3605
3627
|
|
3628
|
+
evaluatedVariable(tagInfo) {
|
3629
|
+
return new VariableInfo(this.scope, undefined, tagInfo);
|
3630
|
+
}
|
3631
|
+
|
3606
3632
|
parseCommentOptions(range) {
|
3607
3633
|
const comments = this.getComments(range);
|
3608
3634
|
if (comments.length === 0) {
|
package/lib/json/JsonData.js
CHANGED
@@ -24,6 +24,14 @@ class JsonData {
|
|
24
24
|
}
|
25
25
|
return this._data;
|
26
26
|
}
|
27
|
+
|
28
|
+
updateHash(hash) {
|
29
|
+
if (this._buffer === undefined && this._data !== undefined) {
|
30
|
+
this._buffer = Buffer.from(JSON.stringify(this._data));
|
31
|
+
}
|
32
|
+
|
33
|
+
if (this._buffer) return hash.update(this._buffer);
|
34
|
+
}
|
27
35
|
}
|
28
36
|
|
29
37
|
register(JsonData, "webpack/lib/json/JsonData", null, {
|
package/lib/json/JsonParser.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const parseJson = require("json-parse-better-errors");
|
8
|
+
const parseJson = require("json-parse-even-better-errors");
|
9
9
|
const Parser = require("../Parser");
|
10
10
|
const JsonExportsDependency = require("../dependencies/JsonExportsDependency");
|
11
11
|
const JsonData = require("./JsonData");
|
@@ -41,15 +41,13 @@ class JsonParser extends Parser {
|
|
41
41
|
typeof source === "object"
|
42
42
|
? source
|
43
43
|
: parseFn(source[0] === "\ufeff" ? source.slice(1) : source);
|
44
|
-
|
45
|
-
state.module.buildInfo.jsonData =
|
44
|
+
const jsonData = new JsonData(data);
|
45
|
+
state.module.buildInfo.jsonData = jsonData;
|
46
46
|
state.module.buildInfo.strict = true;
|
47
47
|
state.module.buildMeta.exportsType = "default";
|
48
48
|
state.module.buildMeta.defaultObject =
|
49
49
|
typeof data === "object" ? "redirect-warn" : false;
|
50
|
-
state.module.addDependency(
|
51
|
-
new JsonExportsDependency(JsonExportsDependency.getExportsFromData(data))
|
52
|
-
);
|
50
|
+
state.module.addDependency(new JsonExportsDependency(jsonData));
|
53
51
|
return state;
|
54
52
|
}
|
55
53
|
}
|
@@ -21,7 +21,7 @@ const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency
|
|
21
21
|
const JavascriptParser = require("../javascript/JavascriptParser");
|
22
22
|
const { equals } = require("../util/ArrayHelpers");
|
23
23
|
const LazySet = require("../util/LazySet");
|
24
|
-
const { concatComparators
|
24
|
+
const { concatComparators } = require("../util/comparators");
|
25
25
|
const createHash = require("../util/createHash");
|
26
26
|
const { makePathsRelative } = require("../util/identifier");
|
27
27
|
const makeSerializable = require("../util/makeSerializable");
|
@@ -185,23 +185,25 @@ const RESERVED_NAMES = new Set(
|
|
185
185
|
.split(",")
|
186
186
|
);
|
187
187
|
|
188
|
-
const
|
189
|
-
|
190
|
-
|
191
|
-
if (isNaN(
|
192
|
-
if (!isNaN(
|
188
|
+
const createComparator = (property, comparator) => (a, b) =>
|
189
|
+
comparator(a[property], b[property]);
|
190
|
+
const compareNumbers = (a, b) => {
|
191
|
+
if (isNaN(a)) {
|
192
|
+
if (!isNaN(b)) {
|
193
193
|
return 1;
|
194
194
|
}
|
195
195
|
} else {
|
196
|
-
if (isNaN(
|
196
|
+
if (isNaN(b)) {
|
197
197
|
return -1;
|
198
198
|
}
|
199
|
-
if (
|
200
|
-
return
|
199
|
+
if (a !== b) {
|
200
|
+
return a < b ? -1 : 1;
|
201
201
|
}
|
202
202
|
}
|
203
203
|
return 0;
|
204
204
|
};
|
205
|
+
const bySourceOrder = createComparator("sourceOrder", compareNumbers);
|
206
|
+
const byRangeStart = createComparator("rangeStart", compareNumbers);
|
205
207
|
|
206
208
|
const joinIterableWithComma = iterable => {
|
207
209
|
// This is more performant than Array.from().join(", ")
|
@@ -885,6 +887,9 @@ class ConcatenatedModule extends Module {
|
|
885
887
|
for (const c of moduleGraph.getOutgoingConnections(this))
|
886
888
|
connections.push(c);
|
887
889
|
}
|
890
|
+
/**
|
891
|
+
* @type {Array<{ connection: ModuleGraphConnection, sourceOrder: number, rangeStart: number }>}
|
892
|
+
*/
|
888
893
|
const references = connections
|
889
894
|
.filter(connection => {
|
890
895
|
if (!(connection.dependency instanceof HarmonyImportDependency))
|
@@ -896,15 +901,33 @@ class ConcatenatedModule extends Module {
|
|
896
901
|
connection.isTargetActive(runtime)
|
897
902
|
);
|
898
903
|
})
|
899
|
-
.map(connection =>
|
900
|
-
|
901
|
-
sourceOrder: /** @type {HarmonyImportDependency} */ (
|
904
|
+
.map(connection => {
|
905
|
+
const dep = /** @type {HarmonyImportDependency} */ (
|
902
906
|
connection.dependency
|
903
|
-
)
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
907
|
+
);
|
908
|
+
return {
|
909
|
+
connection,
|
910
|
+
sourceOrder: dep.sourceOrder,
|
911
|
+
rangeStart: dep.range && dep.range[0]
|
912
|
+
};
|
913
|
+
});
|
914
|
+
/**
|
915
|
+
* bySourceOrder
|
916
|
+
* @example
|
917
|
+
* import a from "a"; // sourceOrder=1
|
918
|
+
* import b from "b"; // sourceOrder=2
|
919
|
+
*
|
920
|
+
* byRangeStart
|
921
|
+
* @example
|
922
|
+
* import {a, b} from "a"; // sourceOrder=1
|
923
|
+
* a.a(); // first range
|
924
|
+
* b.b(); // second range
|
925
|
+
*
|
926
|
+
* If there is no reexport, we have the same source.
|
927
|
+
* If there is reexport, but module has side effects, this will lead to reexport module only.
|
928
|
+
* If there is side-effects-free reexport, we can get simple deterministic result with range start comparison.
|
929
|
+
*/
|
930
|
+
references.sort(concatComparators(bySourceOrder, byRangeStart));
|
908
931
|
/** @type {Map<Module, { connection: ModuleGraphConnection, runtimeCondition: RuntimeSpec | true }>} */
|
909
932
|
const referencesMap = new Map();
|
910
933
|
for (const { connection } of references) {
|
@@ -606,7 +606,7 @@ class ModuleConcatenationPlugin {
|
|
606
606
|
incomingConnectionsFromNonModules.filter(connection => {
|
607
607
|
// We are not interested in inactive connections
|
608
608
|
// or connections without dependency
|
609
|
-
return connection.isActive(runtime)
|
609
|
+
return connection.isActive(runtime);
|
610
610
|
});
|
611
611
|
if (activeNonModulesConnections.length > 0) {
|
612
612
|
const problem = requestShortener => {
|
@@ -20,12 +20,13 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
20
20
|
const { runtimeTemplate } = this.compilation;
|
21
21
|
const fn = RuntimeGlobals.asyncModule;
|
22
22
|
return Template.asString([
|
23
|
-
'var
|
23
|
+
'var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";',
|
24
24
|
'var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";',
|
25
25
|
'var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";',
|
26
|
-
`var
|
27
|
-
"if(queue) {",
|
26
|
+
`var resolveQueue = ${runtimeTemplate.basicFunction("queue", [
|
27
|
+
"if(queue && !queue.d) {",
|
28
28
|
Template.indent([
|
29
|
+
"queue.d = 1;",
|
29
30
|
`queue.forEach(${runtimeTemplate.expressionFunction(
|
30
31
|
"fn.r--",
|
31
32
|
"fn"
|
@@ -37,35 +38,26 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
37
38
|
]),
|
38
39
|
"}"
|
39
40
|
])}`,
|
40
|
-
`var completeFunction = ${runtimeTemplate.expressionFunction(
|
41
|
-
"!--fn.r && fn()",
|
42
|
-
"fn"
|
43
|
-
)};`,
|
44
|
-
`var queueFunction = ${runtimeTemplate.expressionFunction(
|
45
|
-
"queue ? queue.push(fn) : completeFunction(fn)",
|
46
|
-
"queue, fn"
|
47
|
-
)};`,
|
48
41
|
`var wrapDeps = ${runtimeTemplate.returningFunction(
|
49
42
|
`deps.map(${runtimeTemplate.basicFunction("dep", [
|
50
43
|
'if(dep !== null && typeof dep === "object") {',
|
51
44
|
Template.indent([
|
52
|
-
"if(dep[
|
45
|
+
"if(dep[webpackQueues]) return dep;",
|
53
46
|
"if(dep.then) {",
|
54
47
|
Template.indent([
|
55
48
|
"var queue = [];",
|
49
|
+
"queue.d = 0;",
|
56
50
|
`dep.then(${runtimeTemplate.basicFunction("r", [
|
57
51
|
"obj[webpackExports] = r;",
|
58
|
-
"
|
59
|
-
"queue = 0;"
|
52
|
+
"resolveQueue(queue);"
|
60
53
|
])}, ${runtimeTemplate.basicFunction("e", [
|
61
54
|
"obj[webpackError] = e;",
|
62
|
-
"
|
63
|
-
"queue = 0;"
|
55
|
+
"resolveQueue(queue);"
|
64
56
|
])});`,
|
65
57
|
"var obj = {};",
|
66
|
-
`obj[
|
67
|
-
|
68
|
-
"fn
|
58
|
+
`obj[webpackQueues] = ${runtimeTemplate.expressionFunction(
|
59
|
+
`fn(queue)`,
|
60
|
+
"fn"
|
69
61
|
)};`,
|
70
62
|
"return obj;"
|
71
63
|
]),
|
@@ -73,54 +65,28 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
73
65
|
]),
|
74
66
|
"}",
|
75
67
|
"var ret = {};",
|
76
|
-
`ret[
|
77
|
-
"completeFunction(fn)",
|
78
|
-
"fn"
|
79
|
-
)};`,
|
68
|
+
`ret[webpackQueues] = ${runtimeTemplate.emptyFunction()};`,
|
80
69
|
"ret[webpackExports] = dep;",
|
81
70
|
"return ret;"
|
82
71
|
])})`,
|
83
72
|
"deps"
|
84
73
|
)};`,
|
85
74
|
`${fn} = ${runtimeTemplate.basicFunction("module, body, hasAwait", [
|
86
|
-
"var queue
|
75
|
+
"var queue;",
|
76
|
+
"hasAwait && ((queue = []).d = 1);",
|
77
|
+
"var depQueues = new Set();",
|
87
78
|
"var exports = module.exports;",
|
88
79
|
"var currentDeps;",
|
89
80
|
"var outerResolve;",
|
90
81
|
"var reject;",
|
91
|
-
"var isEvaluating = true;",
|
92
|
-
"var nested = false;",
|
93
|
-
`var whenAll = ${runtimeTemplate.basicFunction(
|
94
|
-
"deps, onResolve, onReject",
|
95
|
-
[
|
96
|
-
"if (nested) return;",
|
97
|
-
"nested = true;",
|
98
|
-
"onResolve.r += deps.length;",
|
99
|
-
`deps.map(${runtimeTemplate.expressionFunction(
|
100
|
-
"dep[webpackThen](onResolve, onReject)",
|
101
|
-
"dep, i"
|
102
|
-
)});`,
|
103
|
-
"nested = false;"
|
104
|
-
]
|
105
|
-
)};`,
|
106
82
|
`var promise = new Promise(${runtimeTemplate.basicFunction(
|
107
83
|
"resolve, rej",
|
108
|
-
[
|
109
|
-
"reject = rej;",
|
110
|
-
`outerResolve = ${runtimeTemplate.expressionFunction(
|
111
|
-
"resolve(exports), completeQueue(queue), queue = 0"
|
112
|
-
)};`
|
113
|
-
]
|
84
|
+
["reject = rej;", "outerResolve = resolve;"]
|
114
85
|
)});`,
|
115
86
|
"promise[webpackExports] = exports;",
|
116
|
-
`promise[
|
117
|
-
|
118
|
-
|
119
|
-
"if (isEvaluating) { return completeFunction(fn); }",
|
120
|
-
"if (currentDeps) whenAll(currentDeps, fn, rejectFn);",
|
121
|
-
"queueFunction(queue, fn);",
|
122
|
-
"promise['catch'](rejectFn);"
|
123
|
-
]
|
87
|
+
`promise[webpackQueues] = ${runtimeTemplate.expressionFunction(
|
88
|
+
`queue && fn(queue), depQueues.forEach(fn), promise["catch"](${runtimeTemplate.emptyFunction()})`,
|
89
|
+
"fn"
|
124
90
|
)};`,
|
125
91
|
"module.exports = promise;",
|
126
92
|
`body(${runtimeTemplate.basicFunction("deps", [
|
@@ -133,21 +99,29 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
133
99
|
])})`
|
134
100
|
)}`,
|
135
101
|
`var promise = new Promise(${runtimeTemplate.basicFunction(
|
136
|
-
"resolve
|
102
|
+
"resolve",
|
137
103
|
[
|
138
104
|
`fn = ${runtimeTemplate.expressionFunction(
|
139
|
-
"resolve(getResult)"
|
105
|
+
"resolve(getResult)",
|
106
|
+
""
|
140
107
|
)};`,
|
141
108
|
"fn.r = 0;",
|
142
|
-
|
109
|
+
`var fnQueue = ${runtimeTemplate.expressionFunction(
|
110
|
+
"q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)))",
|
111
|
+
"q"
|
112
|
+
)};`,
|
113
|
+
`currentDeps.map(${runtimeTemplate.expressionFunction(
|
114
|
+
"dep[webpackQueues](fnQueue)",
|
115
|
+
"dep"
|
116
|
+
)});`
|
143
117
|
]
|
144
118
|
)});`,
|
145
119
|
"return fn.r ? promise : getResult();"
|
146
120
|
])}, ${runtimeTemplate.expressionFunction(
|
147
|
-
"err
|
121
|
+
"(err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)",
|
148
122
|
"err"
|
149
123
|
)});`,
|
150
|
-
"
|
124
|
+
"queue && (queue.d = 0);"
|
151
125
|
])};`
|
152
126
|
]);
|
153
127
|
}
|
@@ -87,13 +87,15 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|
87
87
|
: "url"
|
88
88
|
};`,
|
89
89
|
crossOriginLoading
|
90
|
-
?
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
? crossOriginLoading === "use-credentials"
|
91
|
+
? 'script.crossOrigin = "use-credentials";'
|
92
|
+
: Template.asString([
|
93
|
+
"if (script.src.indexOf(window.location.origin + '/') !== 0) {",
|
94
|
+
Template.indent(
|
95
|
+
`script.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
96
|
+
),
|
97
|
+
"}"
|
98
|
+
])
|
97
99
|
: ""
|
98
100
|
]);
|
99
101
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Ivan Kopeykin @vankop
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
|
+
const RuntimeModule = require("../RuntimeModule");
|
10
|
+
|
11
|
+
class NonceRuntimeModule extends RuntimeModule {
|
12
|
+
constructor() {
|
13
|
+
super("nonce", RuntimeModule.STAGE_ATTACH);
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @returns {string} runtime code
|
18
|
+
*/
|
19
|
+
generate() {
|
20
|
+
return `${RuntimeGlobals.scriptNonce} = undefined;`;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
module.exports = NonceRuntimeModule;
|
@@ -129,8 +129,7 @@ class ProvideSharedPlugin {
|
|
129
129
|
details =
|
130
130
|
"No description file (usually package.json) found. Add description file with name and version, or manually specify version in shared config.";
|
131
131
|
} else if (!descriptionFileData.version) {
|
132
|
-
details =
|
133
|
-
"No version in description file (usually package.json). Add version to description file, or manually specify version in shared config.";
|
132
|
+
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
134
133
|
} else {
|
135
134
|
version = descriptionFileData.version;
|
136
135
|
}
|
@@ -263,15 +263,17 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
263
263
|
'link.as = "script";',
|
264
264
|
`link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
|
265
265
|
crossOriginLoading
|
266
|
-
?
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
266
|
+
? crossOriginLoading === "use-credentials"
|
267
|
+
? 'link.crossOrigin = "use-credentials";'
|
268
|
+
: Template.asString([
|
269
|
+
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
|
270
|
+
Template.indent(
|
271
|
+
`link.crossOrigin = ${JSON.stringify(
|
272
|
+
crossOriginLoading
|
273
|
+
)};`
|
274
|
+
),
|
275
|
+
"}"
|
276
|
+
])
|
275
277
|
: ""
|
276
278
|
]),
|
277
279
|
chunk
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.74.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",
|
@@ -10,24 +10,24 @@
|
|
10
10
|
"@webassemblyjs/ast": "1.11.1",
|
11
11
|
"@webassemblyjs/wasm-edit": "1.11.1",
|
12
12
|
"@webassemblyjs/wasm-parser": "1.11.1",
|
13
|
-
"acorn": "^8.
|
13
|
+
"acorn": "^8.7.1",
|
14
14
|
"acorn-import-assertions": "^1.7.6",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
17
|
-
"enhanced-resolve": "^5.
|
17
|
+
"enhanced-resolve": "^5.10.0",
|
18
18
|
"es-module-lexer": "^0.9.0",
|
19
19
|
"eslint-scope": "5.1.1",
|
20
20
|
"events": "^3.2.0",
|
21
21
|
"glob-to-regexp": "^0.4.1",
|
22
22
|
"graceful-fs": "^4.2.9",
|
23
|
-
"json-parse-better-errors": "^
|
23
|
+
"json-parse-even-better-errors": "^2.3.1",
|
24
24
|
"loader-runner": "^4.2.0",
|
25
25
|
"mime-types": "^2.1.27",
|
26
26
|
"neo-async": "^2.6.2",
|
27
27
|
"schema-utils": "^3.1.0",
|
28
28
|
"tapable": "^2.1.1",
|
29
29
|
"terser-webpack-plugin": "^5.1.3",
|
30
|
-
"watchpack": "^2.
|
30
|
+
"watchpack": "^2.4.0",
|
31
31
|
"webpack-sources": "^3.2.3"
|
32
32
|
},
|
33
33
|
"peerDependenciesMeta": {
|
@@ -121,6 +121,7 @@
|
|
121
121
|
"url": "https://opencollective.com/webpack"
|
122
122
|
},
|
123
123
|
"homepage": "https://github.com/webpack/webpack",
|
124
|
+
"bugs": "https://github.com/webpack/webpack/issues",
|
124
125
|
"main": "lib/index.js",
|
125
126
|
"bin": {
|
126
127
|
"webpack": "bin/webpack.js"
|