webpack 5.45.0 → 5.45.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/NormalModule.js +2 -6
- package/lib/NormalModuleFactory.js +2 -8
- package/lib/asset/AssetGenerator.js +28 -15
- package/lib/config/defaults.js +12 -18
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -6
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependency.js +1 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +5 -40
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +2 -10
- package/lib/dependencies/ModuleDependency.js +1 -8
- package/lib/javascript/JavascriptModulesPlugin.js +3 -1
- package/lib/javascript/JavascriptParser.js +9 -14
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -4
- package/lib/rules/{ObjectMatcherRulePlugin.js → DescriptionDataMatcherRulePlugin.js} +10 -14
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +5 -1
- package/lib/schemes/DataUriPlugin.js +7 -6
- package/package.json +1 -2
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +0 -7
- package/types.d.ts +8 -38
package/lib/NormalModule.js
CHANGED
@@ -293,13 +293,9 @@ class NormalModule extends Module {
|
|
293
293
|
*/
|
294
294
|
identifier() {
|
295
295
|
if (this.layer === null) {
|
296
|
-
|
297
|
-
return this.request;
|
298
|
-
} else {
|
299
|
-
return `${this.type}|${this.request}`;
|
300
|
-
}
|
296
|
+
return this.request;
|
301
297
|
} else {
|
302
|
-
return `${this.
|
298
|
+
return `${this.request}|${this.layer}`;
|
303
299
|
}
|
304
300
|
}
|
305
301
|
|
@@ -20,7 +20,7 @@ const ModuleGraph = require("./ModuleGraph");
|
|
20
20
|
const NormalModule = require("./NormalModule");
|
21
21
|
const BasicEffectRulePlugin = require("./rules/BasicEffectRulePlugin");
|
22
22
|
const BasicMatcherRulePlugin = require("./rules/BasicMatcherRulePlugin");
|
23
|
-
const
|
23
|
+
const DescriptionDataMatcherRulePlugin = require("./rules/DescriptionDataMatcherRulePlugin");
|
24
24
|
const RuleSetCompiler = require("./rules/RuleSetCompiler");
|
25
25
|
const UseEffectRulePlugin = require("./rules/UseEffectRulePlugin");
|
26
26
|
const LazySet = require("./util/LazySet");
|
@@ -44,7 +44,6 @@ const { parseResource } = require("./util/identifier");
|
|
44
44
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
45
45
|
* @property {string} context
|
46
46
|
* @property {string} request
|
47
|
-
* @property {Record<string, any> | undefined} assertions
|
48
47
|
* @property {ModuleDependency[]} dependencies
|
49
48
|
* @property {Object} createData
|
50
49
|
* @property {LazySet<string>} fileDependencies
|
@@ -183,8 +182,7 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
183
182
|
new BasicMatcherRulePlugin("issuer"),
|
184
183
|
new BasicMatcherRulePlugin("compiler"),
|
185
184
|
new BasicMatcherRulePlugin("issuerLayer"),
|
186
|
-
new
|
187
|
-
new ObjectMatcherRulePlugin("descriptionData"),
|
185
|
+
new DescriptionDataMatcherRulePlugin(),
|
188
186
|
new BasicEffectRulePlugin("type"),
|
189
187
|
new BasicEffectRulePlugin("sideEffects"),
|
190
188
|
new BasicEffectRulePlugin("parser"),
|
@@ -341,7 +339,6 @@ class NormalModuleFactory extends ModuleFactory {
|
|
341
339
|
context,
|
342
340
|
dependencies,
|
343
341
|
request,
|
344
|
-
assertions,
|
345
342
|
resolveOptions,
|
346
343
|
fileDependencies,
|
347
344
|
missingDependencies,
|
@@ -450,7 +447,6 @@ class NormalModuleFactory extends ModuleFactory {
|
|
450
447
|
resourceQuery: resourceDataForRules.query,
|
451
448
|
resourceFragment: resourceDataForRules.fragment,
|
452
449
|
scheme,
|
453
|
-
assertions,
|
454
450
|
mimetype: matchResourceData ? "" : resourceData.data.mimetype || "",
|
455
451
|
dependency: dependencyType,
|
456
452
|
descriptionData: matchResourceData
|
@@ -698,7 +694,6 @@ class NormalModuleFactory extends ModuleFactory {
|
|
698
694
|
const resolveOptions = data.resolveOptions || EMPTY_RESOLVE_OPTIONS;
|
699
695
|
const dependency = dependencies[0];
|
700
696
|
const request = dependency.request;
|
701
|
-
const assertions = dependency.assertions;
|
702
697
|
const contextInfo = data.contextInfo;
|
703
698
|
const fileDependencies = new LazySet();
|
704
699
|
const missingDependencies = new LazySet();
|
@@ -709,7 +704,6 @@ class NormalModuleFactory extends ModuleFactory {
|
|
709
704
|
resolveOptions,
|
710
705
|
context,
|
711
706
|
request,
|
712
|
-
assertions,
|
713
707
|
dependencies,
|
714
708
|
fileDependencies,
|
715
709
|
missingDependencies,
|
@@ -141,7 +141,9 @@ class AssetGenerator extends Generator {
|
|
141
141
|
module.resourceResolveData &&
|
142
142
|
module.resourceResolveData.mimetype !== undefined
|
143
143
|
) {
|
144
|
-
mimeType =
|
144
|
+
mimeType =
|
145
|
+
module.resourceResolveData.mimetype +
|
146
|
+
module.resourceResolveData.parameters;
|
145
147
|
} else if (ext) {
|
146
148
|
mimeType = mimeTypes.lookup(ext);
|
147
149
|
}
|
@@ -156,22 +158,33 @@ class AssetGenerator extends Generator {
|
|
156
158
|
}
|
157
159
|
|
158
160
|
let encodedContent;
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
encodedContent =
|
168
|
-
|
169
|
-
|
161
|
+
if (
|
162
|
+
module.resourceResolveData &&
|
163
|
+
module.resourceResolveData.encoding === encoding
|
164
|
+
) {
|
165
|
+
encodedContent = module.resourceResolveData.encodedContent;
|
166
|
+
} else {
|
167
|
+
switch (encoding) {
|
168
|
+
case "base64": {
|
169
|
+
encodedContent = originalSource.buffer().toString("base64");
|
170
|
+
break;
|
171
|
+
}
|
172
|
+
case false: {
|
173
|
+
const content = originalSource.source();
|
174
|
+
|
175
|
+
if (typeof content !== "string") {
|
176
|
+
encodedContent = content.toString("utf-8");
|
177
|
+
}
|
178
|
+
|
179
|
+
encodedContent = encodeURIComponent(encodedContent).replace(
|
180
|
+
/[!'()*]/g,
|
181
|
+
character => "%" + character.codePointAt(0).toString(16)
|
182
|
+
);
|
183
|
+
break;
|
170
184
|
}
|
171
|
-
|
185
|
+
default:
|
186
|
+
throw new Error(`Unsupported encoding '${encoding}'`);
|
172
187
|
}
|
173
|
-
default:
|
174
|
-
throw new Error(`Unsupported encoding '${encoding}'`);
|
175
188
|
}
|
176
189
|
|
177
190
|
encodedSource = `data:${mimeType}${
|
package/lib/config/defaults.js
CHANGED
@@ -482,6 +482,18 @@ const applyModuleDefaults = (
|
|
482
482
|
or: ["text/javascript", "application/javascript"]
|
483
483
|
},
|
484
484
|
...esm
|
485
|
+
},
|
486
|
+
{
|
487
|
+
dependency: "url",
|
488
|
+
oneOf: [
|
489
|
+
{
|
490
|
+
scheme: /^data$/,
|
491
|
+
type: "asset/inline"
|
492
|
+
},
|
493
|
+
{
|
494
|
+
type: "asset/resource"
|
495
|
+
}
|
496
|
+
]
|
485
497
|
}
|
486
498
|
];
|
487
499
|
if (asyncWebAssembly) {
|
@@ -529,24 +541,6 @@ const applyModuleDefaults = (
|
|
529
541
|
...wasm
|
530
542
|
});
|
531
543
|
}
|
532
|
-
rules.push(
|
533
|
-
{
|
534
|
-
dependency: "url",
|
535
|
-
oneOf: [
|
536
|
-
{
|
537
|
-
scheme: /^data$/,
|
538
|
-
type: "asset/inline"
|
539
|
-
},
|
540
|
-
{
|
541
|
-
type: "asset/resource"
|
542
|
-
}
|
543
|
-
]
|
544
|
-
},
|
545
|
-
{
|
546
|
-
assert: { type: "json" },
|
547
|
-
type: "json"
|
548
|
-
}
|
549
|
-
);
|
550
544
|
return rules;
|
551
545
|
});
|
552
546
|
};
|
@@ -12,8 +12,7 @@ const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency")
|
|
12
12
|
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
|
13
13
|
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
14
14
|
const {
|
15
|
-
harmonySpecifierTag
|
16
|
-
getAssertions
|
15
|
+
harmonySpecifierTag
|
17
16
|
} = require("./HarmonyImportDependencyParserPlugin");
|
18
17
|
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
19
18
|
|
@@ -49,8 +48,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
49
48
|
parser.state.module.addPresentationalDependency(clearDep);
|
50
49
|
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
51
50
|
source,
|
52
|
-
parser.state.lastHarmonyImportOrder
|
53
|
-
getAssertions(statement)
|
51
|
+
parser.state.lastHarmonyImportOrder
|
54
52
|
);
|
55
53
|
sideEffectDep.loc = Object.create(statement.loc);
|
56
54
|
sideEffectDep.loc.index = -1;
|
@@ -129,8 +127,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
129
127
|
harmonyNamedExports,
|
130
128
|
null,
|
131
129
|
this.strictExportPresence,
|
132
|
-
null
|
133
|
-
settings.assertions
|
130
|
+
null
|
134
131
|
);
|
135
132
|
} else {
|
136
133
|
dep = new HarmonyExportSpecifierDependency(id, name);
|
@@ -159,7 +159,6 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
159
159
|
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency>} otherStarExports other star exports in the module before this import
|
160
160
|
* @param {boolean} strictExportPresence when true, missing exports in the imported module lead to errors instead of warnings
|
161
161
|
* @param {HarmonyStarExportsList} allStarExports all star exports in the module
|
162
|
-
* @param {Record<string, any>=} assertions import assertions
|
163
162
|
*/
|
164
163
|
constructor(
|
165
164
|
request,
|
@@ -169,10 +168,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
169
168
|
activeExports,
|
170
169
|
otherStarExports,
|
171
170
|
strictExportPresence,
|
172
|
-
allStarExports
|
173
|
-
assertions
|
171
|
+
allStarExports
|
174
172
|
) {
|
175
|
-
super(request, sourceOrder
|
173
|
+
super(request, sourceOrder);
|
176
174
|
|
177
175
|
this.ids = ids;
|
178
176
|
this.name = name;
|
@@ -32,12 +32,10 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
32
32
|
*
|
33
33
|
* @param {string} request request string
|
34
34
|
* @param {number} sourceOrder source order
|
35
|
-
* @param {Record<string, any>=} assertions import assertions
|
36
35
|
*/
|
37
|
-
constructor(request, sourceOrder
|
36
|
+
constructor(request, sourceOrder) {
|
38
37
|
super(request);
|
39
38
|
this.sourceOrder = sourceOrder;
|
40
|
-
this.assertions = assertions;
|
41
39
|
}
|
42
40
|
|
43
41
|
get category() {
|
@@ -203,14 +201,12 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
203
201
|
serialize(context) {
|
204
202
|
const { write } = context;
|
205
203
|
write(this.sourceOrder);
|
206
|
-
write(this.assertions);
|
207
204
|
super.serialize(context);
|
208
205
|
}
|
209
206
|
|
210
207
|
deserialize(context) {
|
211
208
|
const { read } = context;
|
212
209
|
this.sourceOrder = read();
|
213
|
-
this.assertions = read();
|
214
210
|
super.deserialize(context);
|
215
211
|
}
|
216
212
|
}
|
@@ -14,11 +14,7 @@ const HarmonyExports = require("./HarmonyExports");
|
|
14
14
|
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
15
15
|
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
|
16
16
|
|
17
|
-
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
|
18
|
-
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
|
19
17
|
/** @typedef {import("estree").Identifier} Identifier */
|
20
|
-
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
|
21
|
-
/** @typedef {import("estree").ImportExpression} ImportExpression */
|
22
18
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
23
19
|
/** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */
|
24
20
|
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
|
@@ -33,32 +29,8 @@ const harmonySpecifierTag = Symbol("harmony import");
|
|
33
29
|
* @property {number} sourceOrder
|
34
30
|
* @property {string} name
|
35
31
|
* @property {boolean} await
|
36
|
-
* @property {Record<string, any> | undefined} assertions
|
37
32
|
*/
|
38
33
|
|
39
|
-
/**
|
40
|
-
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ImportExpression} node node with assertions
|
41
|
-
* @returns {Record<string, any> | undefined} assertions
|
42
|
-
*/
|
43
|
-
function getAssertions(node) {
|
44
|
-
// TODO remove cast when @types/estree has been updated to import assertions
|
45
|
-
const assertions = /** @type {{ assertions?: ImportAttributeNode[] }} */ (
|
46
|
-
node
|
47
|
-
).assertions;
|
48
|
-
if (assertions === undefined) {
|
49
|
-
return undefined;
|
50
|
-
}
|
51
|
-
const result = {};
|
52
|
-
for (const assertion of assertions) {
|
53
|
-
const key =
|
54
|
-
assertion.key.type === "Identifier"
|
55
|
-
? assertion.key.name
|
56
|
-
: assertion.key.value;
|
57
|
-
result[key] = assertion.value.value;
|
58
|
-
}
|
59
|
-
return result;
|
60
|
-
}
|
61
|
-
|
62
34
|
module.exports = class HarmonyImportDependencyParserPlugin {
|
63
35
|
constructor(options) {
|
64
36
|
this.strictExportPresence = options.strictExportPresence;
|
@@ -93,11 +65,9 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
93
65
|
clearDep.loc = statement.loc;
|
94
66
|
parser.state.module.addPresentationalDependency(clearDep);
|
95
67
|
parser.unsetAsiPosition(statement.range[1]);
|
96
|
-
const assertions = getAssertions(statement);
|
97
68
|
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
98
69
|
source,
|
99
|
-
parser.state.lastHarmonyImportOrder
|
100
|
-
assertions
|
70
|
+
parser.state.lastHarmonyImportOrder
|
101
71
|
);
|
102
72
|
sideEffectDep.loc = statement.loc;
|
103
73
|
parser.state.module.addDependency(sideEffectDep);
|
@@ -112,8 +82,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
112
82
|
name,
|
113
83
|
source,
|
114
84
|
ids,
|
115
|
-
sourceOrder: parser.state.lastHarmonyImportOrder
|
116
|
-
assertions: getAssertions(statement)
|
85
|
+
sourceOrder: parser.state.lastHarmonyImportOrder
|
117
86
|
});
|
118
87
|
return true;
|
119
88
|
}
|
@@ -128,8 +97,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
128
97
|
settings.ids,
|
129
98
|
settings.name,
|
130
99
|
expr.range,
|
131
|
-
this.strictExportPresence
|
132
|
-
settings.assertions
|
100
|
+
this.strictExportPresence
|
133
101
|
);
|
134
102
|
dep.shorthand = parser.scope.inShorthand;
|
135
103
|
dep.directImport = true;
|
@@ -150,8 +118,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
150
118
|
ids,
|
151
119
|
settings.name,
|
152
120
|
expr.range,
|
153
|
-
this.strictExportPresence
|
154
|
-
settings.assertions
|
121
|
+
this.strictExportPresence
|
155
122
|
);
|
156
123
|
dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
|
157
124
|
dep.loc = expr.loc;
|
@@ -171,8 +138,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
171
138
|
ids,
|
172
139
|
settings.name,
|
173
140
|
callee.range,
|
174
|
-
this.strictExportPresence
|
175
|
-
settings.assertions
|
141
|
+
this.strictExportPresence
|
176
142
|
);
|
177
143
|
dep.directImport = members.length === 0;
|
178
144
|
dep.call = true;
|
@@ -240,4 +206,3 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
240
206
|
};
|
241
207
|
|
242
208
|
module.exports.harmonySpecifierTag = harmonySpecifierTag;
|
243
|
-
module.exports.getAssertions = getAssertions;
|
@@ -20,8 +20,8 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
20
20
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
21
21
|
|
22
22
|
class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
|
23
|
-
constructor(request, sourceOrder
|
24
|
-
super(request, sourceOrder
|
23
|
+
constructor(request, sourceOrder) {
|
24
|
+
super(request, sourceOrder);
|
25
25
|
}
|
26
26
|
|
27
27
|
get type() {
|
@@ -29,16 +29,8 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
29
29
|
const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids");
|
30
30
|
|
31
31
|
class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
32
|
-
constructor(
|
33
|
-
request,
|
34
|
-
sourceOrder,
|
35
|
-
ids,
|
36
|
-
name,
|
37
|
-
range,
|
38
|
-
strictExportPresence,
|
39
|
-
assertions
|
40
|
-
) {
|
41
|
-
super(request, sourceOrder, assertions);
|
32
|
+
constructor(request, sourceOrder, ids, name, range, strictExportPresence) {
|
33
|
+
super(request, sourceOrder);
|
42
34
|
this.ids = ids;
|
43
35
|
this.name = name;
|
44
36
|
this.range = range;
|
@@ -22,20 +22,13 @@ class ModuleDependency extends Dependency {
|
|
22
22
|
this.request = request;
|
23
23
|
this.userRequest = request;
|
24
24
|
this.range = undefined;
|
25
|
-
// assertions must be serialized by subclasses that use it
|
26
|
-
/** @type {Record<string, any> | undefined} */
|
27
|
-
this.assertions = undefined;
|
28
25
|
}
|
29
26
|
|
30
27
|
/**
|
31
28
|
* @returns {string | null} an identifier to merge equal requests
|
32
29
|
*/
|
33
30
|
getResourceIdentifier() {
|
34
|
-
|
35
|
-
if (this.assertions !== undefined) {
|
36
|
-
str += JSON.stringify(this.assertions);
|
37
|
-
}
|
38
|
-
return str;
|
31
|
+
return `module${this.request}`;
|
39
32
|
}
|
40
33
|
|
41
34
|
/**
|
@@ -834,7 +834,9 @@ class JavascriptModulesPlugin {
|
|
834
834
|
}
|
835
835
|
}
|
836
836
|
if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
|
837
|
-
startupSource.add(
|
837
|
+
startupSource.add(
|
838
|
+
`__webpack_exports__ = ${RuntimeGlobals.onChunksLoaded}(__webpack_exports__);\n`
|
839
|
+
);
|
838
840
|
}
|
839
841
|
source.add(
|
840
842
|
hooks.renderStartup.call(startupSource, lastInlinedModule, {
|
@@ -6,7 +6,6 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const { Parser: AcornParser } = require("acorn");
|
9
|
-
const { importAssertions } = require("acorn-import-assertions");
|
10
9
|
const { SyncBailHook, HookMap } = require("tapable");
|
11
10
|
const vm = require("vm");
|
12
11
|
const Parser = require("../Parser");
|
@@ -43,10 +42,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|
43
42
|
/** @typedef {import("estree").Node} AnyNode */
|
44
43
|
/** @typedef {import("estree").Program} ProgramNode */
|
45
44
|
/** @typedef {import("estree").Statement} StatementNode */
|
46
|
-
/** @typedef {import("estree").ImportDeclaration} ImportDeclarationNode */
|
47
|
-
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclarationNode */
|
48
|
-
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclarationNode */
|
49
|
-
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclarationNode */
|
50
45
|
/** @typedef {import("estree").Super} SuperNode */
|
51
46
|
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpressionNode */
|
52
47
|
/** @typedef {import("estree").TemplateLiteral} TemplateLiteralNode */
|
@@ -66,7 +61,7 @@ const ALLOWED_MEMBER_TYPES_ALL = 0b11;
|
|
66
61
|
|
67
62
|
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
|
68
63
|
|
69
|
-
const parser = AcornParser
|
64
|
+
const parser = AcornParser;
|
70
65
|
|
71
66
|
class VariableInfo {
|
72
67
|
/**
|
@@ -195,31 +190,31 @@ class JavascriptParser extends Parser {
|
|
195
190
|
]),
|
196
191
|
/** @type {HookMap<SyncBailHook<[LabeledStatementNode], boolean | void>>} */
|
197
192
|
label: new HookMap(() => new SyncBailHook(["statement"])),
|
198
|
-
/** @type {SyncBailHook<[
|
193
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource], boolean | void>} */
|
199
194
|
import: new SyncBailHook(["statement", "source"]),
|
200
|
-
/** @type {SyncBailHook<[
|
195
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource, string, string], boolean | void>} */
|
201
196
|
importSpecifier: new SyncBailHook([
|
202
197
|
"statement",
|
203
198
|
"source",
|
204
199
|
"exportName",
|
205
200
|
"identifierName"
|
206
201
|
]),
|
207
|
-
/** @type {SyncBailHook<[
|
202
|
+
/** @type {SyncBailHook<[StatementNode], boolean | void>} */
|
208
203
|
export: new SyncBailHook(["statement"]),
|
209
|
-
/** @type {SyncBailHook<[
|
204
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource], boolean | void>} */
|
210
205
|
exportImport: new SyncBailHook(["statement", "source"]),
|
211
|
-
/** @type {SyncBailHook<[
|
206
|
+
/** @type {SyncBailHook<[StatementNode, DeclarationNode], boolean | void>} */
|
212
207
|
exportDeclaration: new SyncBailHook(["statement", "declaration"]),
|
213
|
-
/** @type {SyncBailHook<[
|
208
|
+
/** @type {SyncBailHook<[StatementNode, DeclarationNode], boolean | void>} */
|
214
209
|
exportExpression: new SyncBailHook(["statement", "declaration"]),
|
215
|
-
/** @type {SyncBailHook<[
|
210
|
+
/** @type {SyncBailHook<[StatementNode, string, string, number | undefined], boolean | void>} */
|
216
211
|
exportSpecifier: new SyncBailHook([
|
217
212
|
"statement",
|
218
213
|
"identifierName",
|
219
214
|
"exportName",
|
220
215
|
"index"
|
221
216
|
]),
|
222
|
-
/** @type {SyncBailHook<[
|
217
|
+
/** @type {SyncBailHook<[StatementNode, ImportSource, string, string, number | undefined], boolean | void>} */
|
223
218
|
exportImportSpecifier: new SyncBailHook([
|
224
219
|
"statement",
|
225
220
|
"source",
|
@@ -32,16 +32,17 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
|
|
32
32
|
`${RuntimeGlobals.onChunksLoaded}(0, ${JSON.stringify(
|
33
33
|
// This need to include itself to delay execution after this chunk has been fully loaded
|
34
34
|
onChunks.filter(c => c === chunk).map(c => c.id)
|
35
|
-
)}, ${runtimeTemplate.
|
35
|
+
)}, ${runtimeTemplate.basicFunction(
|
36
|
+
"",
|
36
37
|
chunks.size < 3
|
37
38
|
? Array.from(
|
38
39
|
chunks,
|
39
40
|
c =>
|
40
|
-
`${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)})
|
41
|
-
)
|
41
|
+
`${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)});`
|
42
|
+
)
|
42
43
|
: `${JSON.stringify(Array.from(chunks, c => c.id))}.map(${
|
43
44
|
RuntimeGlobals.prefetchChunk
|
44
|
-
})
|
45
|
+
});`
|
45
46
|
)}, 5);`
|
46
47
|
)
|
47
48
|
);
|
@@ -8,32 +8,28 @@
|
|
8
8
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
9
9
|
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
10
10
|
|
11
|
-
|
12
|
-
constructor(ruleProperty, dataProperty) {
|
13
|
-
this.ruleProperty = ruleProperty;
|
14
|
-
this.dataProperty = dataProperty || ruleProperty;
|
15
|
-
}
|
11
|
+
const RULE_PROPERTY = "descriptionData";
|
16
12
|
|
13
|
+
class DescriptionDataMatcherRulePlugin {
|
17
14
|
/**
|
18
15
|
* @param {RuleSetCompiler} ruleSetCompiler the rule set compiler
|
19
16
|
* @returns {void}
|
20
17
|
*/
|
21
18
|
apply(ruleSetCompiler) {
|
22
|
-
const { ruleProperty, dataProperty } = this;
|
23
19
|
ruleSetCompiler.hooks.rule.tap(
|
24
|
-
"
|
20
|
+
"DescriptionDataMatcherRulePlugin",
|
25
21
|
(path, rule, unhandledProperties, result) => {
|
26
|
-
if (unhandledProperties.has(
|
27
|
-
unhandledProperties.delete(
|
28
|
-
const value = rule[
|
22
|
+
if (unhandledProperties.has(RULE_PROPERTY)) {
|
23
|
+
unhandledProperties.delete(RULE_PROPERTY);
|
24
|
+
const value = rule[RULE_PROPERTY];
|
29
25
|
for (const property of Object.keys(value)) {
|
30
|
-
const
|
26
|
+
const dataProperty = property.split(".");
|
31
27
|
const condition = ruleSetCompiler.compileCondition(
|
32
|
-
`${path}.${
|
28
|
+
`${path}.${RULE_PROPERTY}.${property}`,
|
33
29
|
value[property]
|
34
30
|
);
|
35
31
|
result.conditions.push({
|
36
|
-
property: [
|
32
|
+
property: ["descriptionData", ...dataProperty],
|
37
33
|
matchWhenEmpty: condition.matchWhenEmpty,
|
38
34
|
fn: condition.fn
|
39
35
|
});
|
@@ -44,4 +40,4 @@ class ObjectMatcherRulePlugin {
|
|
44
40
|
}
|
45
41
|
}
|
46
42
|
|
47
|
-
module.exports =
|
43
|
+
module.exports = DescriptionDataMatcherRulePlugin;
|
@@ -58,7 +58,11 @@ class OnChunksLoadedRuntimeModule extends RuntimeModule {
|
|
58
58
|
]),
|
59
59
|
"}",
|
60
60
|
"if(fulfilled) {",
|
61
|
-
Template.indent([
|
61
|
+
Template.indent([
|
62
|
+
"deferred.splice(i--, 1)",
|
63
|
+
"var r = fn();",
|
64
|
+
"if (r !== undefined) result = r;"
|
65
|
+
]),
|
62
66
|
"}"
|
63
67
|
]),
|
64
68
|
"}",
|
@@ -11,15 +11,14 @@ const NormalModule = require("../NormalModule");
|
|
11
11
|
|
12
12
|
// data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string"
|
13
13
|
// http://www.ietf.org/rfc/rfc2397.txt
|
14
|
-
const URIRegEx = /^data:(
|
15
|
-
const URIMetaRegEx = /^data:([^;,]+)?(?:(?:;[^;,]+)*?)(?:;(base64))?,/i;
|
14
|
+
const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64))?,(.*)$/i;
|
16
15
|
|
17
16
|
const decodeDataURI = uri => {
|
18
17
|
const match = URIRegEx.exec(uri);
|
19
18
|
if (!match) return null;
|
20
19
|
|
21
|
-
const isBase64 = match[
|
22
|
-
const body = match[
|
20
|
+
const isBase64 = match[3];
|
21
|
+
const body = match[4];
|
23
22
|
return isBase64
|
24
23
|
? Buffer.from(body, "base64")
|
25
24
|
: Buffer.from(decodeURIComponent(body), "ascii");
|
@@ -38,10 +37,12 @@ class DataUriPlugin {
|
|
38
37
|
normalModuleFactory.hooks.resolveForScheme
|
39
38
|
.for("data")
|
40
39
|
.tap("DataUriPlugin", resourceData => {
|
41
|
-
const match =
|
40
|
+
const match = URIRegEx.exec(resourceData.resource);
|
42
41
|
if (match) {
|
43
42
|
resourceData.data.mimetype = match[1] || "";
|
44
|
-
resourceData.data.
|
43
|
+
resourceData.data.parameters = match[2] || "";
|
44
|
+
resourceData.data.encoding = match[3] || false;
|
45
|
+
resourceData.data.encodedContent = match[4] || "";
|
45
46
|
}
|
46
47
|
});
|
47
48
|
NormalModule.getCompilationHooks(compilation)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.45.
|
3
|
+
"version": "5.45.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",
|
@@ -11,7 +11,6 @@
|
|
11
11
|
"@webassemblyjs/wasm-edit": "1.11.1",
|
12
12
|
"@webassemblyjs/wasm-parser": "1.11.1",
|
13
13
|
"acorn": "^8.4.1",
|
14
|
-
"acorn-import-assertions": "1.7.1",
|
15
14
|
"browserslist": "^4.14.5",
|
16
15
|
"chrome-trace-event": "^1.0.2",
|
17
16
|
"enhanced-resolve": "^5.8.0",
|