webpack 5.52.0 → 5.55.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/bin/webpack.js +0 -0
- package/lib/AsyncDependenciesBlock.js +9 -2
- package/lib/CacheFacade.js +10 -3
- package/lib/ChunkGraph.js +19 -8
- package/lib/CodeGenerationResults.js +7 -2
- package/lib/Compilation.js +549 -144
- package/lib/Compiler.js +12 -4
- package/lib/Dependency.js +11 -0
- package/lib/DependencyTemplates.js +8 -2
- package/lib/EvalDevToolModulePlugin.js +2 -1
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/ExternalModule.js +18 -9
- package/lib/FileSystemInfo.js +101 -170
- package/lib/FlagDependencyExportsPlugin.js +25 -16
- package/lib/JavascriptMetaInfoPlugin.js +6 -1
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleFilenameHelpers.js +21 -7
- package/lib/ModuleGraph.js +90 -21
- package/lib/NodeStuffInWebError.js +34 -0
- package/lib/NodeStuffPlugin.js +59 -16
- package/lib/NormalModuleFactory.js +8 -43
- package/lib/SourceMapDevToolPlugin.js +7 -3
- package/lib/WebpackOptionsApply.js +19 -1
- package/lib/cache/PackFileCacheStrategy.js +183 -53
- package/lib/cache/getLazyHashedEtag.js +35 -8
- package/lib/config/defaults.js +32 -12
- package/lib/dependencies/CachedConstDependency.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +19 -9
- package/lib/dependencies/CommonJsFullRequireDependency.js +11 -9
- package/lib/dependencies/ConstDependency.js +12 -4
- package/lib/dependencies/ContextDependency.js +8 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +179 -163
- package/lib/dependencies/HarmonyImportDependency.js +4 -1
- package/lib/dependencies/JsonExportsDependency.js +7 -1
- package/lib/dependencies/ModuleDecoratorDependency.js +5 -2
- package/lib/dependencies/ModuleDependency.js +8 -0
- package/lib/dependencies/NullDependency.js +8 -4
- package/lib/dependencies/ProvidedDependency.js +6 -2
- package/lib/dependencies/PureExpressionDependency.js +5 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +9 -0
- package/lib/ids/IdHelpers.js +21 -8
- package/lib/ids/NamedChunkIdsPlugin.js +3 -0
- package/lib/ids/NamedModuleIdsPlugin.js +3 -1
- package/lib/index.js +6 -0
- package/lib/javascript/BasicEvaluatedExpression.js +3 -0
- package/lib/javascript/JavascriptParser.js +22 -4
- package/lib/javascript/JavascriptParserHelpers.js +0 -2
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +25 -4
- package/lib/optimize/InnerGraph.js +22 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +2 -1
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -2
- package/lib/serialization/BinaryMiddleware.js +11 -2
- package/lib/serialization/FileMiddleware.js +24 -7
- package/lib/serialization/ObjectMiddleware.js +23 -12
- package/lib/util/WeakTupleMap.js +95 -92
- package/lib/util/createHash.js +10 -0
- package/lib/util/hash/BatchedHash.js +65 -0
- package/lib/util/hash/xxhash64.js +154 -0
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/serialization.js +10 -6
- package/package.json +11 -7
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +19 -3
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.json +20 -2
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.json +4 -2
- package/types.d.ts +211 -25
@@ -18,6 +18,7 @@ const processExportInfo = require("./processExportInfo");
|
|
18
18
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
19
19
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
20
20
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
21
|
+
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
21
22
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
22
23
|
/** @typedef {import("../Module")} Module */
|
23
24
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
@@ -43,6 +44,13 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
43
44
|
return "cjs export require";
|
44
45
|
}
|
45
46
|
|
47
|
+
/**
|
48
|
+
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
49
|
+
*/
|
50
|
+
couldAffectReferencingModule() {
|
51
|
+
return Dependency.TRANSITIVE;
|
52
|
+
}
|
53
|
+
|
46
54
|
/**
|
47
55
|
* @param {ModuleGraph} moduleGraph the module graph
|
48
56
|
* @returns {string[]} the imported id
|
@@ -332,15 +340,17 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
|
|
332
340
|
weak: dep.weak,
|
333
341
|
runtimeRequirements
|
334
342
|
});
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
343
|
+
if (importedModule) {
|
344
|
+
const ids = dep.getIds(moduleGraph);
|
345
|
+
const usedImported = moduleGraph
|
346
|
+
.getExportsInfo(importedModule)
|
347
|
+
.getUsedName(ids, runtime);
|
348
|
+
if (usedImported) {
|
349
|
+
const comment = equals(usedImported, ids)
|
350
|
+
? ""
|
351
|
+
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
352
|
+
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
353
|
+
}
|
344
354
|
}
|
345
355
|
|
346
356
|
switch (type) {
|
@@ -108,15 +108,17 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
|
|
108
108
|
weak: dep.weak,
|
109
109
|
runtimeRequirements
|
110
110
|
});
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
111
|
+
if (importedModule) {
|
112
|
+
const ids = dep.names;
|
113
|
+
const usedImported = moduleGraph
|
114
|
+
.getExportsInfo(importedModule)
|
115
|
+
.getUsedName(ids, runtime);
|
116
|
+
if (usedImported) {
|
117
|
+
const comment = equals(usedImported, ids)
|
118
|
+
? ""
|
119
|
+
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
120
|
+
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
121
|
+
}
|
120
122
|
}
|
121
123
|
source.replace(dep.range[0], dep.range[1] - 1, requireExpr);
|
122
124
|
}
|
@@ -30,6 +30,7 @@ class ConstDependency extends NullDependency {
|
|
30
30
|
this.runtimeRequirements = runtimeRequirements
|
31
31
|
? new Set(runtimeRequirements)
|
32
32
|
: null;
|
33
|
+
this._hashUpdate = undefined;
|
33
34
|
}
|
34
35
|
|
35
36
|
/**
|
@@ -39,10 +40,17 @@ class ConstDependency extends NullDependency {
|
|
39
40
|
* @returns {void}
|
40
41
|
*/
|
41
42
|
updateHash(hash, context) {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
if (this._hashUpdate === undefined) {
|
44
|
+
let hashUpdate = "" + this.range + "|" + this.expression;
|
45
|
+
if (this.runtimeRequirements) {
|
46
|
+
for (const item of this.runtimeRequirements) {
|
47
|
+
hashUpdate += "|";
|
48
|
+
hashUpdate += item;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
this._hashUpdate = hashUpdate;
|
52
|
+
}
|
53
|
+
hash.update(this._hashUpdate);
|
46
54
|
}
|
47
55
|
|
48
56
|
/**
|
@@ -11,6 +11,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
11
11
|
const memoize = require("../util/memoize");
|
12
12
|
|
13
13
|
/** @typedef {import("../ContextModule").ContextOptions} ContextOptions */
|
14
|
+
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
14
15
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
15
16
|
/** @typedef {import("../WebpackError")} WebpackError */
|
16
17
|
|
@@ -54,6 +55,13 @@ class ContextDependency extends Dependency {
|
|
54
55
|
return "commonjs";
|
55
56
|
}
|
56
57
|
|
58
|
+
/**
|
59
|
+
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
60
|
+
*/
|
61
|
+
couldAffectReferencingModule() {
|
62
|
+
return true;
|
63
|
+
}
|
64
|
+
|
57
65
|
/**
|
58
66
|
* @returns {string | null} an identifier to merge equal requests
|
59
67
|
*/
|
@@ -15,6 +15,7 @@ const { countIterable } = require("../util/IterableHelpers");
|
|
15
15
|
const { first, combine } = require("../util/SetHelpers");
|
16
16
|
const makeSerializable = require("../util/makeSerializable");
|
17
17
|
const propertyAccess = require("../util/propertyAccess");
|
18
|
+
const { getRuntimeKey, keyToRuntime } = require("../util/runtime");
|
18
19
|
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
19
20
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
20
21
|
const processExportInfo = require("./processExportInfo");
|
@@ -23,6 +24,7 @@ const processExportInfo = require("./processExportInfo");
|
|
23
24
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
24
25
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
25
26
|
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
27
|
+
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
26
28
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
27
29
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
28
30
|
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
@@ -149,6 +151,172 @@ const findDependencyForName = (
|
|
149
151
|
return undefined;
|
150
152
|
};
|
151
153
|
|
154
|
+
/**
|
155
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
156
|
+
* @param {HarmonyExportImportedSpecifierDependency} dep the dependency
|
157
|
+
* @param {string} runtimeKey the runtime key
|
158
|
+
* @returns {ExportMode} the export mode
|
159
|
+
*/
|
160
|
+
const getMode = (moduleGraph, dep, runtimeKey) => {
|
161
|
+
const importedModule = moduleGraph.getModule(dep);
|
162
|
+
|
163
|
+
if (!importedModule) {
|
164
|
+
const mode = new ExportMode("missing");
|
165
|
+
|
166
|
+
mode.userRequest = dep.userRequest;
|
167
|
+
|
168
|
+
return mode;
|
169
|
+
}
|
170
|
+
|
171
|
+
const name = dep.name;
|
172
|
+
const runtime = keyToRuntime(runtimeKey);
|
173
|
+
const parentModule = moduleGraph.getParentModule(dep);
|
174
|
+
const exportsInfo = moduleGraph.getExportsInfo(parentModule);
|
175
|
+
|
176
|
+
if (
|
177
|
+
name
|
178
|
+
? exportsInfo.getUsed(name, runtime) === UsageState.Unused
|
179
|
+
: exportsInfo.isUsed(runtime) === false
|
180
|
+
) {
|
181
|
+
const mode = new ExportMode("unused");
|
182
|
+
|
183
|
+
mode.name = name || "*";
|
184
|
+
|
185
|
+
return mode;
|
186
|
+
}
|
187
|
+
|
188
|
+
const importedExportsType = importedModule.getExportsType(
|
189
|
+
moduleGraph,
|
190
|
+
parentModule.buildMeta.strictHarmonyModule
|
191
|
+
);
|
192
|
+
|
193
|
+
const ids = dep.getIds(moduleGraph);
|
194
|
+
|
195
|
+
// Special handling for reexporting the default export
|
196
|
+
// from non-namespace modules
|
197
|
+
if (name && ids.length > 0 && ids[0] === "default") {
|
198
|
+
switch (importedExportsType) {
|
199
|
+
case "dynamic": {
|
200
|
+
const mode = new ExportMode("reexport-dynamic-default");
|
201
|
+
|
202
|
+
mode.name = name;
|
203
|
+
|
204
|
+
return mode;
|
205
|
+
}
|
206
|
+
case "default-only":
|
207
|
+
case "default-with-named": {
|
208
|
+
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
209
|
+
const mode = new ExportMode("reexport-named-default");
|
210
|
+
|
211
|
+
mode.name = name;
|
212
|
+
mode.partialNamespaceExportInfo = exportInfo;
|
213
|
+
|
214
|
+
return mode;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
// reexporting with a fixed name
|
220
|
+
if (name) {
|
221
|
+
let mode;
|
222
|
+
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
223
|
+
|
224
|
+
if (ids.length > 0) {
|
225
|
+
// export { name as name }
|
226
|
+
switch (importedExportsType) {
|
227
|
+
case "default-only":
|
228
|
+
mode = new ExportMode("reexport-undefined");
|
229
|
+
mode.name = name;
|
230
|
+
break;
|
231
|
+
default:
|
232
|
+
mode = new ExportMode("normal-reexport");
|
233
|
+
mode.items = [
|
234
|
+
new NormalReexportItem(name, ids, exportInfo, false, false)
|
235
|
+
];
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
} else {
|
239
|
+
// export * as name
|
240
|
+
switch (importedExportsType) {
|
241
|
+
case "default-only":
|
242
|
+
mode = new ExportMode("reexport-fake-namespace-object");
|
243
|
+
mode.name = name;
|
244
|
+
mode.partialNamespaceExportInfo = exportInfo;
|
245
|
+
mode.fakeType = 0;
|
246
|
+
break;
|
247
|
+
case "default-with-named":
|
248
|
+
mode = new ExportMode("reexport-fake-namespace-object");
|
249
|
+
mode.name = name;
|
250
|
+
mode.partialNamespaceExportInfo = exportInfo;
|
251
|
+
mode.fakeType = 2;
|
252
|
+
break;
|
253
|
+
case "dynamic":
|
254
|
+
default:
|
255
|
+
mode = new ExportMode("reexport-namespace-object");
|
256
|
+
mode.name = name;
|
257
|
+
mode.partialNamespaceExportInfo = exportInfo;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
return mode;
|
262
|
+
}
|
263
|
+
|
264
|
+
// Star reexporting
|
265
|
+
|
266
|
+
const { ignoredExports, exports, checked, hidden } = dep.getStarReexports(
|
267
|
+
moduleGraph,
|
268
|
+
runtime,
|
269
|
+
exportsInfo,
|
270
|
+
importedModule
|
271
|
+
);
|
272
|
+
if (!exports) {
|
273
|
+
// We have too few info about the modules
|
274
|
+
// Delegate the logic to the runtime code
|
275
|
+
|
276
|
+
const mode = new ExportMode("dynamic-reexport");
|
277
|
+
mode.ignored = ignoredExports;
|
278
|
+
mode.hidden = hidden;
|
279
|
+
|
280
|
+
return mode;
|
281
|
+
}
|
282
|
+
|
283
|
+
if (exports.size === 0) {
|
284
|
+
const mode = new ExportMode("empty-star");
|
285
|
+
mode.hidden = hidden;
|
286
|
+
|
287
|
+
return mode;
|
288
|
+
}
|
289
|
+
|
290
|
+
const mode = new ExportMode("normal-reexport");
|
291
|
+
|
292
|
+
mode.items = Array.from(
|
293
|
+
exports,
|
294
|
+
exportName =>
|
295
|
+
new NormalReexportItem(
|
296
|
+
exportName,
|
297
|
+
[exportName],
|
298
|
+
exportsInfo.getReadOnlyExportInfo(exportName),
|
299
|
+
checked.has(exportName),
|
300
|
+
false
|
301
|
+
)
|
302
|
+
);
|
303
|
+
if (hidden !== undefined) {
|
304
|
+
for (const exportName of hidden) {
|
305
|
+
mode.items.push(
|
306
|
+
new NormalReexportItem(
|
307
|
+
exportName,
|
308
|
+
[exportName],
|
309
|
+
exportsInfo.getReadOnlyExportInfo(exportName),
|
310
|
+
false,
|
311
|
+
true
|
312
|
+
)
|
313
|
+
);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
return mode;
|
318
|
+
};
|
319
|
+
|
152
320
|
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
153
321
|
/**
|
154
322
|
* @param {string} request the request string
|
@@ -180,7 +348,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
180
348
|
this.otherStarExports = otherStarExports;
|
181
349
|
this.strictExportPresence = strictExportPresence;
|
182
350
|
this.allStarExports = allStarExports;
|
183
|
-
|
351
|
+
}
|
352
|
+
|
353
|
+
/**
|
354
|
+
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
355
|
+
*/
|
356
|
+
couldAffectReferencingModule() {
|
357
|
+
return Dependency.TRANSITIVE;
|
184
358
|
}
|
185
359
|
|
186
360
|
// TODO webpack 6 remove
|
@@ -225,169 +399,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
225
399
|
* @returns {ExportMode} the export mode
|
226
400
|
*/
|
227
401
|
getMode(moduleGraph, runtime) {
|
228
|
-
return moduleGraph.
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
* @param {ModuleGraph} moduleGraph the module graph
|
233
|
-
* @param {RuntimeSpec} runtime the runtime
|
234
|
-
* @returns {ExportMode} the export mode
|
235
|
-
*/
|
236
|
-
_getMode(moduleGraph, runtime) {
|
237
|
-
const name = this.name;
|
238
|
-
const ids = this.getIds(moduleGraph);
|
239
|
-
const parentModule = moduleGraph.getParentModule(this);
|
240
|
-
const importedModule = moduleGraph.getModule(this);
|
241
|
-
const exportsInfo = moduleGraph.getExportsInfo(parentModule);
|
242
|
-
|
243
|
-
if (!importedModule) {
|
244
|
-
const mode = new ExportMode("missing");
|
245
|
-
|
246
|
-
mode.userRequest = this.userRequest;
|
247
|
-
|
248
|
-
return mode;
|
249
|
-
}
|
250
|
-
|
251
|
-
if (
|
252
|
-
name
|
253
|
-
? exportsInfo.getUsed(name, runtime) === UsageState.Unused
|
254
|
-
: exportsInfo.isUsed(runtime) === false
|
255
|
-
) {
|
256
|
-
const mode = new ExportMode("unused");
|
257
|
-
|
258
|
-
mode.name = name || "*";
|
259
|
-
|
260
|
-
return mode;
|
261
|
-
}
|
262
|
-
|
263
|
-
const importedExportsType = importedModule.getExportsType(
|
264
|
-
moduleGraph,
|
265
|
-
parentModule.buildMeta.strictHarmonyModule
|
266
|
-
);
|
267
|
-
|
268
|
-
// Special handling for reexporting the default export
|
269
|
-
// from non-namespace modules
|
270
|
-
if (name && ids.length > 0 && ids[0] === "default") {
|
271
|
-
switch (importedExportsType) {
|
272
|
-
case "dynamic": {
|
273
|
-
const mode = new ExportMode("reexport-dynamic-default");
|
274
|
-
|
275
|
-
mode.name = name;
|
276
|
-
|
277
|
-
return mode;
|
278
|
-
}
|
279
|
-
case "default-only":
|
280
|
-
case "default-with-named": {
|
281
|
-
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
282
|
-
const mode = new ExportMode("reexport-named-default");
|
283
|
-
|
284
|
-
mode.name = name;
|
285
|
-
mode.partialNamespaceExportInfo = exportInfo;
|
286
|
-
|
287
|
-
return mode;
|
288
|
-
}
|
289
|
-
}
|
290
|
-
}
|
291
|
-
|
292
|
-
// reexporting with a fixed name
|
293
|
-
if (name) {
|
294
|
-
let mode;
|
295
|
-
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
296
|
-
|
297
|
-
if (ids.length > 0) {
|
298
|
-
// export { name as name }
|
299
|
-
switch (importedExportsType) {
|
300
|
-
case "default-only":
|
301
|
-
mode = new ExportMode("reexport-undefined");
|
302
|
-
mode.name = name;
|
303
|
-
break;
|
304
|
-
default:
|
305
|
-
mode = new ExportMode("normal-reexport");
|
306
|
-
mode.items = [
|
307
|
-
new NormalReexportItem(name, ids, exportInfo, false, false)
|
308
|
-
];
|
309
|
-
break;
|
310
|
-
}
|
311
|
-
} else {
|
312
|
-
// export * as name
|
313
|
-
switch (importedExportsType) {
|
314
|
-
case "default-only":
|
315
|
-
mode = new ExportMode("reexport-fake-namespace-object");
|
316
|
-
mode.name = name;
|
317
|
-
mode.partialNamespaceExportInfo = exportInfo;
|
318
|
-
mode.fakeType = 0;
|
319
|
-
break;
|
320
|
-
case "default-with-named":
|
321
|
-
mode = new ExportMode("reexport-fake-namespace-object");
|
322
|
-
mode.name = name;
|
323
|
-
mode.partialNamespaceExportInfo = exportInfo;
|
324
|
-
mode.fakeType = 2;
|
325
|
-
break;
|
326
|
-
case "dynamic":
|
327
|
-
default:
|
328
|
-
mode = new ExportMode("reexport-namespace-object");
|
329
|
-
mode.name = name;
|
330
|
-
mode.partialNamespaceExportInfo = exportInfo;
|
331
|
-
}
|
332
|
-
}
|
333
|
-
|
334
|
-
return mode;
|
335
|
-
}
|
336
|
-
|
337
|
-
// Star reexporting
|
338
|
-
|
339
|
-
const { ignoredExports, exports, checked, hidden } = this.getStarReexports(
|
340
|
-
moduleGraph,
|
341
|
-
runtime,
|
342
|
-
exportsInfo,
|
343
|
-
importedModule
|
344
|
-
);
|
345
|
-
if (!exports) {
|
346
|
-
// We have too few info about the modules
|
347
|
-
// Delegate the logic to the runtime code
|
348
|
-
|
349
|
-
const mode = new ExportMode("dynamic-reexport");
|
350
|
-
mode.ignored = ignoredExports;
|
351
|
-
mode.hidden = hidden;
|
352
|
-
|
353
|
-
return mode;
|
354
|
-
}
|
355
|
-
|
356
|
-
if (exports.size === 0) {
|
357
|
-
const mode = new ExportMode("empty-star");
|
358
|
-
mode.hidden = hidden;
|
359
|
-
|
360
|
-
return mode;
|
361
|
-
}
|
362
|
-
|
363
|
-
const mode = new ExportMode("normal-reexport");
|
364
|
-
|
365
|
-
mode.items = Array.from(
|
366
|
-
exports,
|
367
|
-
exportName =>
|
368
|
-
new NormalReexportItem(
|
369
|
-
exportName,
|
370
|
-
[exportName],
|
371
|
-
exportsInfo.getReadOnlyExportInfo(exportName),
|
372
|
-
checked.has(exportName),
|
373
|
-
false
|
374
|
-
)
|
402
|
+
return moduleGraph.dependencyCacheProvide(
|
403
|
+
this,
|
404
|
+
getRuntimeKey(runtime),
|
405
|
+
getMode
|
375
406
|
);
|
376
|
-
if (hidden !== undefined) {
|
377
|
-
for (const exportName of hidden) {
|
378
|
-
mode.items.push(
|
379
|
-
new NormalReexportItem(
|
380
|
-
exportName,
|
381
|
-
[exportName],
|
382
|
-
exportsInfo.getReadOnlyExportInfo(exportName),
|
383
|
-
false,
|
384
|
-
true
|
385
|
-
)
|
386
|
-
);
|
387
|
-
}
|
388
|
-
}
|
389
|
-
|
390
|
-
return mode;
|
391
407
|
}
|
392
408
|
|
393
409
|
/**
|
@@ -282,7 +282,10 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
282
282
|
}
|
283
283
|
|
284
284
|
const importStatement = dep.getImportStatement(false, templateContext);
|
285
|
-
if (
|
285
|
+
if (
|
286
|
+
referencedModule &&
|
287
|
+
templateContext.moduleGraph.isAsync(referencedModule)
|
288
|
+
) {
|
286
289
|
templateContext.initFragments.push(
|
287
290
|
new ConditionalInitFragment(
|
288
291
|
importStatement[0],
|
@@ -47,6 +47,7 @@ class JsonExportsDependency extends NullDependency {
|
|
47
47
|
constructor(exports) {
|
48
48
|
super();
|
49
49
|
this.exports = exports;
|
50
|
+
this._hashUpdate = undefined;
|
50
51
|
}
|
51
52
|
|
52
53
|
get type() {
|
@@ -72,7 +73,12 @@ class JsonExportsDependency extends NullDependency {
|
|
72
73
|
* @returns {void}
|
73
74
|
*/
|
74
75
|
updateHash(hash, context) {
|
75
|
-
|
76
|
+
if (this._hashUpdate === undefined) {
|
77
|
+
this._hashUpdate = this.exports
|
78
|
+
? JSON.stringify(this.exports)
|
79
|
+
: "undefined";
|
80
|
+
}
|
81
|
+
hash.update(this._hashUpdate);
|
76
82
|
}
|
77
83
|
|
78
84
|
serialize(context) {
|
@@ -30,6 +30,7 @@ class ModuleDecoratorDependency extends NullDependency {
|
|
30
30
|
super();
|
31
31
|
this.decorator = decorator;
|
32
32
|
this.allowExportsAccess = allowExportsAccess;
|
33
|
+
this._hashUpdate = undefined;
|
33
34
|
}
|
34
35
|
|
35
36
|
/**
|
@@ -69,8 +70,10 @@ class ModuleDecoratorDependency extends NullDependency {
|
|
69
70
|
* @returns {void}
|
70
71
|
*/
|
71
72
|
updateHash(hash, context) {
|
72
|
-
|
73
|
-
|
73
|
+
if (this._hashUpdate === undefined) {
|
74
|
+
this._hashUpdate = `${this.decorator}${this.allowExportsAccess}`;
|
75
|
+
}
|
76
|
+
hash.update(this._hashUpdate);
|
74
77
|
}
|
75
78
|
|
76
79
|
serialize(context) {
|
@@ -9,6 +9,7 @@ const Dependency = require("../Dependency");
|
|
9
9
|
const DependencyTemplate = require("../DependencyTemplate");
|
10
10
|
const memoize = require("../util/memoize");
|
11
11
|
|
12
|
+
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
12
13
|
/** @typedef {import("../Module")} Module */
|
13
14
|
|
14
15
|
const getRawModule = memoize(() => require("../RawModule"));
|
@@ -38,6 +39,13 @@ class ModuleDependency extends Dependency {
|
|
38
39
|
return str;
|
39
40
|
}
|
40
41
|
|
42
|
+
/**
|
43
|
+
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
44
|
+
*/
|
45
|
+
couldAffectReferencingModule() {
|
46
|
+
return true;
|
47
|
+
}
|
48
|
+
|
41
49
|
/**
|
42
50
|
* @param {string} context context directory
|
43
51
|
* @returns {Module} a module
|
@@ -9,16 +9,20 @@ const Dependency = require("../Dependency");
|
|
9
9
|
const DependencyTemplate = require("../DependencyTemplate");
|
10
10
|
|
11
11
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
12
|
-
/** @typedef {import("../
|
13
|
-
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
12
|
+
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
14
13
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
15
|
-
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
16
|
-
/** @typedef {import("../util/Hash")} Hash */
|
17
14
|
|
18
15
|
class NullDependency extends Dependency {
|
19
16
|
get type() {
|
20
17
|
return "null";
|
21
18
|
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
22
|
+
*/
|
23
|
+
couldAffectReferencingModule() {
|
24
|
+
return false;
|
25
|
+
}
|
22
26
|
}
|
23
27
|
|
24
28
|
NullDependency.Template = class NullDependencyTemplate extends (
|
@@ -34,6 +34,7 @@ class ProvidedDependency extends ModuleDependency {
|
|
34
34
|
this.identifier = identifier;
|
35
35
|
this.path = path;
|
36
36
|
this.range = range;
|
37
|
+
this._hashUpdate = undefined;
|
37
38
|
}
|
38
39
|
|
39
40
|
get type() {
|
@@ -51,8 +52,11 @@ class ProvidedDependency extends ModuleDependency {
|
|
51
52
|
* @returns {void}
|
52
53
|
*/
|
53
54
|
updateHash(hash, context) {
|
54
|
-
|
55
|
-
|
55
|
+
if (this._hashUpdate === undefined) {
|
56
|
+
this._hashUpdate =
|
57
|
+
this.identifier + (this.path ? this.path.join(",") : "null");
|
58
|
+
}
|
59
|
+
hash.update(this._hashUpdate);
|
56
60
|
}
|
57
61
|
|
58
62
|
serialize(context) {
|
@@ -28,6 +28,7 @@ class PureExpressionDependency extends NullDependency {
|
|
28
28
|
this.range = range;
|
29
29
|
/** @type {Set<string> | false} */
|
30
30
|
this.usedByExports = false;
|
31
|
+
this._hashUpdate = undefined;
|
31
32
|
}
|
32
33
|
|
33
34
|
/**
|
@@ -37,7 +38,10 @@ class PureExpressionDependency extends NullDependency {
|
|
37
38
|
* @returns {void}
|
38
39
|
*/
|
39
40
|
updateHash(hash, context) {
|
40
|
-
|
41
|
+
if (this._hashUpdate === undefined) {
|
42
|
+
this._hashUpdate = this.range + "";
|
43
|
+
}
|
44
|
+
hash.update(this._hashUpdate);
|
41
45
|
}
|
42
46
|
|
43
47
|
/**
|
@@ -23,6 +23,7 @@ class RuntimeRequirementsDependency extends NullDependency {
|
|
23
23
|
constructor(runtimeRequirements) {
|
24
24
|
super();
|
25
25
|
this.runtimeRequirements = new Set(runtimeRequirements);
|
26
|
+
this._hashUpdate = undefined;
|
26
27
|
}
|
27
28
|
|
28
29
|
/**
|
@@ -32,7 +33,10 @@ class RuntimeRequirementsDependency extends NullDependency {
|
|
32
33
|
* @returns {void}
|
33
34
|
*/
|
34
35
|
updateHash(hash, context) {
|
35
|
-
|
36
|
+
if (this._hashUpdate === undefined) {
|
37
|
+
this._hashUpdate = Array.from(this.runtimeRequirements).join() + "";
|
38
|
+
}
|
39
|
+
hash.update(this._hashUpdate);
|
36
40
|
}
|
37
41
|
|
38
42
|
serialize(context) {
|