webpack 5.37.0 → 5.37.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/README.md +5 -8
- package/lib/CacheFacade.js +3 -3
- package/lib/Chunk.js +2 -3
- package/lib/Compilation.js +43 -55
- package/lib/Compiler.js +4 -4
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ContextModule.js +3 -3
- package/lib/ContextReplacementPlugin.js +4 -3
- package/lib/DefinePlugin.js +16 -12
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/FileSystemInfo.js +24 -30
- package/lib/FlagDependencyExportsPlugin.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +2 -4
- package/lib/HotModuleReplacementPlugin.js +20 -30
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -3
- package/lib/ModuleFilenameHelpers.js +4 -2
- package/lib/ModuleGraphConnection.js +6 -2
- package/lib/ModuleInfoHeaderPlugin.js +2 -3
- package/lib/MultiCompiler.js +31 -27
- package/lib/NormalModule.js +22 -5
- package/lib/RecordIdsPlugin.js +5 -4
- package/lib/ResolverFactory.js +10 -7
- package/lib/SourceMapDevToolPlugin.js +13 -14
- package/lib/Template.js +4 -2
- package/lib/Watching.js +83 -46
- package/lib/asset/AssetGenerator.js +19 -23
- package/lib/buildChunkGraph.js +21 -21
- package/lib/cache/PackFileCacheStrategy.js +12 -9
- package/lib/config/defaults.js +12 -9
- package/lib/config/normalization.js +7 -7
- package/lib/debug/ProfilingPlugin.js +4 -3
- package/lib/dependencies/AMDRequireDependency.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -3
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -4
- package/lib/dependencies/CommonJsPlugin.js +8 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +10 -8
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -13
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +2 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -11
- package/lib/dependencies/ImportDependency.js +3 -3
- package/lib/dependencies/ImportParserPlugin.js +2 -4
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +2 -3
- package/lib/dependencies/RequireEnsureDependency.js +3 -3
- package/lib/dependencies/WorkerDependency.js +6 -6
- package/lib/dependencies/WorkerPlugin.js +18 -19
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/ids/HashedModuleIdsPlugin.js +3 -3
- package/lib/ids/OccurrenceModuleIdsPlugin.js +2 -3
- package/lib/index.js +5 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -6
- package/lib/javascript/CommonJsChunkFormatPlugin.js +2 -3
- package/lib/javascript/JavascriptGenerator.js +3 -1
- package/lib/javascript/JavascriptModulesPlugin.js +15 -23
- package/lib/javascript/JavascriptParser.js +10 -8
- package/lib/library/AssignLibraryPlugin.js +4 -2
- package/lib/node/NodeWatchFileSystem.js +19 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -4
- package/lib/optimize/ConcatenatedModule.js +22 -27
- package/lib/optimize/FlagIncludedChunksPlugin.js +4 -6
- package/lib/optimize/InnerGraph.js +9 -11
- package/lib/optimize/InnerGraphPlugin.js +3 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +7 -10
- package/lib/optimize/RealContentHashPlugin.js +14 -16
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -5
- package/lib/optimize/SplitChunksPlugin.js +13 -15
- package/lib/runtime/EnsureChunkRuntimeModule.js +9 -8
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -3
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +38 -37
- package/lib/serialization/BinaryMiddleware.js +2 -3
- package/lib/serialization/FileMiddleware.js +3 -1
- package/lib/serialization/ObjectMiddleware.js +11 -7
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -3
- package/lib/stats/DefaultStatsPrinterPlugin.js +11 -9
- package/lib/stats/StatsFactory.js +2 -1
- package/lib/stats/StatsPrinter.js +3 -3
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/cleverMerge.js +3 -1
- package/lib/util/comparators.js +13 -13
- package/lib/util/identifier.js +2 -1
- package/lib/validateSchema.js +5 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +4 -4
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +5 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +89 -83
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyParser.js +6 -5
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -4
- package/lib/webpack.js +11 -7
- package/package.json +6 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +68 -60
- package/types.d.ts +89 -257
package/lib/buildChunkGraph.js
CHANGED
@@ -519,7 +519,8 @@ const visitModules = (
|
|
519
519
|
if (skipConnectionBuffer.length > 0) {
|
520
520
|
let { skippedModuleConnections } = chunkGroupInfo;
|
521
521
|
if (skippedModuleConnections === undefined) {
|
522
|
-
chunkGroupInfo.skippedModuleConnections = skippedModuleConnections =
|
522
|
+
chunkGroupInfo.skippedModuleConnections = skippedModuleConnections =
|
523
|
+
new Set();
|
523
524
|
}
|
524
525
|
for (let i = skipConnectionBuffer.length - 1; i >= 0; i--) {
|
525
526
|
skippedModuleConnections.add(skipConnectionBuffer[i]);
|
@@ -695,7 +696,8 @@ const visitModules = (
|
|
695
696
|
let resultingAvailableModules;
|
696
697
|
if (minAvailableModules.size > minAvailableModules.plus.size) {
|
697
698
|
// resultingAvailableModules = (modules of chunk) + (minAvailableModules + minAvailableModules.plus)
|
698
|
-
resultingAvailableModules =
|
699
|
+
resultingAvailableModules =
|
700
|
+
/** @type {Set<Module> & {plus: Set<Module>}} */ (new Set());
|
699
701
|
for (const module of minAvailableModules.plus)
|
700
702
|
minAvailableModules.add(module);
|
701
703
|
minAvailableModules.plus = EMPTY_SET;
|
@@ -703,9 +705,10 @@ const visitModules = (
|
|
703
705
|
chunkGroupInfo.minAvailableModulesOwned = false;
|
704
706
|
} else {
|
705
707
|
// resultingAvailableModules = (minAvailableModules + modules of chunk) + (minAvailableModules.plus)
|
706
|
-
resultingAvailableModules =
|
707
|
-
|
708
|
-
|
708
|
+
resultingAvailableModules =
|
709
|
+
/** @type {Set<Module> & {plus: Set<Module>}} */ (
|
710
|
+
new Set(minAvailableModules)
|
711
|
+
);
|
709
712
|
resultingAvailableModules.plus = minAvailableModules.plus;
|
710
713
|
}
|
711
714
|
|
@@ -715,7 +718,8 @@ const visitModules = (
|
|
715
718
|
resultingAvailableModules.add(m);
|
716
719
|
}
|
717
720
|
}
|
718
|
-
return (chunkGroupInfo.resultingAvailableModules =
|
721
|
+
return (chunkGroupInfo.resultingAvailableModules =
|
722
|
+
resultingAvailableModules);
|
719
723
|
};
|
720
724
|
|
721
725
|
const processConnectQueue = () => {
|
@@ -732,9 +736,8 @@ const visitModules = (
|
|
732
736
|
}
|
733
737
|
|
734
738
|
// 2. Calculate resulting available modules
|
735
|
-
const resultingAvailableModules =
|
736
|
-
chunkGroupInfo
|
737
|
-
);
|
739
|
+
const resultingAvailableModules =
|
740
|
+
calculateResultingAvailableModules(chunkGroupInfo);
|
738
741
|
|
739
742
|
const runtime = chunkGroupInfo.runtime;
|
740
743
|
|
@@ -800,9 +803,8 @@ const visitModules = (
|
|
800
803
|
if (!availableModules.has(m) && !availableModules.plus.has(m)) {
|
801
804
|
// We can't remove modules from the plus part
|
802
805
|
// so we need to merge plus into the normal part to allow modifying it
|
803
|
-
const iterator =
|
804
|
-
Symbol.iterator
|
805
|
-
]();
|
806
|
+
const iterator =
|
807
|
+
cachedMinAvailableModules.plus[Symbol.iterator]();
|
806
808
|
// fast forward add all modules until m
|
807
809
|
/** @type {IteratorResult<Module>} */
|
808
810
|
let it;
|
@@ -951,13 +953,12 @@ const visitModules = (
|
|
951
953
|
statForkedMergedModulesCountPlus += availableModules.plus.size;
|
952
954
|
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
953
955
|
// we already know that all modules directly from cachedMinAvailableModules are in availableModules too
|
954
|
-
const newSet = /** @type {ModuleSetPlus} */ (
|
955
|
-
cachedMinAvailableModules
|
956
|
-
)
|
956
|
+
const newSet = /** @type {ModuleSetPlus} */ (
|
957
|
+
new Set(cachedMinAvailableModules)
|
958
|
+
);
|
957
959
|
newSet.plus = EMPTY_SET;
|
958
|
-
const iterator =
|
959
|
-
Symbol.iterator
|
960
|
-
]();
|
960
|
+
const iterator =
|
961
|
+
cachedMinAvailableModules.plus[Symbol.iterator]();
|
961
962
|
// fast forward add all modules until m
|
962
963
|
/** @type {IteratorResult<Module>} */
|
963
964
|
let it;
|
@@ -1018,9 +1019,8 @@ const visitModules = (
|
|
1018
1019
|
};
|
1019
1020
|
// combine minAvailableModules from all resultingAvailableModules
|
1020
1021
|
for (const source of info.availableSources) {
|
1021
|
-
const resultingAvailableModules =
|
1022
|
-
source
|
1023
|
-
);
|
1022
|
+
const resultingAvailableModules =
|
1023
|
+
calculateResultingAvailableModules(source);
|
1024
1024
|
mergeSet(resultingAvailableModules);
|
1025
1025
|
mergeSet(resultingAvailableModules.plus);
|
1026
1026
|
}
|
@@ -1041,7 +1041,8 @@ class PackFileCacheStrategy {
|
|
1041
1041
|
if (newBuildDependencies)
|
1042
1042
|
this.newBuildDependencies.addAll(newBuildDependencies);
|
1043
1043
|
this.resolveResults = resolveResults;
|
1044
|
-
this.resolveBuildDependenciesSnapshot =
|
1044
|
+
this.resolveBuildDependenciesSnapshot =
|
1045
|
+
resolveBuildDependenciesSnapshot;
|
1045
1046
|
return pack;
|
1046
1047
|
}
|
1047
1048
|
return new Pack(logger, this.maxAge);
|
@@ -1163,10 +1164,11 @@ class PackFileCacheStrategy {
|
|
1163
1164
|
);
|
1164
1165
|
}
|
1165
1166
|
if (this.resolveBuildDependenciesSnapshot) {
|
1166
|
-
this.resolveBuildDependenciesSnapshot =
|
1167
|
-
this.
|
1168
|
-
|
1169
|
-
|
1167
|
+
this.resolveBuildDependenciesSnapshot =
|
1168
|
+
this.fileSystemInfo.mergeSnapshots(
|
1169
|
+
this.resolveBuildDependenciesSnapshot,
|
1170
|
+
snapshot
|
1171
|
+
);
|
1170
1172
|
} else {
|
1171
1173
|
this.resolveBuildDependenciesSnapshot = snapshot;
|
1172
1174
|
}
|
@@ -1194,10 +1196,11 @@ class PackFileCacheStrategy {
|
|
1194
1196
|
this.logger.debug("Captured build dependencies");
|
1195
1197
|
|
1196
1198
|
if (this.buildSnapshot) {
|
1197
|
-
this.buildSnapshot =
|
1198
|
-
this.
|
1199
|
-
|
1200
|
-
|
1199
|
+
this.buildSnapshot =
|
1200
|
+
this.fileSystemInfo.mergeSnapshots(
|
1201
|
+
this.buildSnapshot,
|
1202
|
+
snapshot
|
1203
|
+
);
|
1201
1204
|
} else {
|
1202
1205
|
this.buildSnapshot = snapshot;
|
1203
1206
|
}
|
package/lib/config/defaults.js
CHANGED
@@ -318,9 +318,10 @@ const applyCacheDefaults = (cache, { name, mode, development }) => {
|
|
318
318
|
const applySnapshotDefaults = (snapshot, { production }) => {
|
319
319
|
A(snapshot, "managedPaths", () => {
|
320
320
|
if (process.versions.pnp === "3") {
|
321
|
-
const match =
|
322
|
-
|
323
|
-
|
321
|
+
const match =
|
322
|
+
/^(.+?)[\\/]cache[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
|
323
|
+
require.resolve("watchpack")
|
324
|
+
);
|
324
325
|
if (match) {
|
325
326
|
return [path.resolve(match[1], "unplugged")];
|
326
327
|
}
|
@@ -337,16 +338,18 @@ const applySnapshotDefaults = (snapshot, { production }) => {
|
|
337
338
|
});
|
338
339
|
A(snapshot, "immutablePaths", () => {
|
339
340
|
if (process.versions.pnp === "1") {
|
340
|
-
const match =
|
341
|
-
|
342
|
-
|
341
|
+
const match =
|
342
|
+
/^(.+?[\\/]v4)[\\/]npm-watchpack-[^\\/]+-[\da-f]{40}[\\/]node_modules[\\/]/.exec(
|
343
|
+
require.resolve("watchpack")
|
344
|
+
);
|
343
345
|
if (match) {
|
344
346
|
return [match[1]];
|
345
347
|
}
|
346
348
|
} else if (process.versions.pnp === "3") {
|
347
|
-
const match =
|
348
|
-
|
349
|
-
|
349
|
+
const match =
|
350
|
+
/^(.+?)[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/.exec(
|
351
|
+
require.resolve("watchpack")
|
352
|
+
);
|
350
353
|
if (match) {
|
351
354
|
return [match[1]];
|
352
355
|
}
|
@@ -92,9 +92,9 @@ const keyedNestedConfig = (value, fn, customKeys) => {
|
|
92
92
|
? {}
|
93
93
|
: Object.keys(value).reduce(
|
94
94
|
(obj, key) => (
|
95
|
-
(obj[key] = (
|
96
|
-
? customKeys[key]
|
97
|
-
|
95
|
+
(obj[key] = (
|
96
|
+
customKeys && key in customKeys ? customKeys[key] : fn
|
97
|
+
)(value[key])),
|
98
98
|
obj
|
99
99
|
),
|
100
100
|
/** @type {Record<string, R>} */ ({})
|
@@ -163,10 +163,10 @@ const getNormalizedWebpackOptions = config => {
|
|
163
163
|
config.entry === undefined
|
164
164
|
? { main: {} }
|
165
165
|
: typeof config.entry === "function"
|
166
|
-
? (
|
167
|
-
|
168
|
-
|
169
|
-
)
|
166
|
+
? (
|
167
|
+
fn => () =>
|
168
|
+
Promise.resolve().then(fn).then(getNormalizedEntryStatic)
|
169
|
+
)(config.entry)
|
170
170
|
: getNormalizedEntryStatic(config.entry),
|
171
171
|
experiments: cloneObject(config.experiments),
|
172
172
|
externals: config.externals,
|
@@ -332,9 +332,10 @@ const interceptAllParserHooks = (moduleFactory, tracer) => {
|
|
332
332
|
const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => {
|
333
333
|
interceptAllHooksFor(
|
334
334
|
{
|
335
|
-
hooks:
|
336
|
-
|
337
|
-
|
335
|
+
hooks:
|
336
|
+
require("../javascript/JavascriptModulesPlugin").getCompilationHooks(
|
337
|
+
compilation
|
338
|
+
)
|
338
339
|
},
|
339
340
|
tracer,
|
340
341
|
"JavascriptModulesPlugin"
|
@@ -77,9 +77,9 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate extends (
|
|
77
77
|
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements }
|
78
78
|
) {
|
79
79
|
const dep = /** @type {AMDRequireDependency} */ (dependency);
|
80
|
-
const depBlock = /** @type {AsyncDependenciesBlock} */ (
|
81
|
-
dep
|
82
|
-
)
|
80
|
+
const depBlock = /** @type {AsyncDependenciesBlock} */ (
|
81
|
+
moduleGraph.getParentBlock(dep)
|
82
|
+
);
|
83
83
|
const promise = runtimeTemplate.blockPromise({
|
84
84
|
chunkGraph,
|
85
85
|
block: depBlock,
|
@@ -230,9 +230,8 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
230
230
|
if (name === "__esModule" && isNamespaceImport) {
|
231
231
|
exports.add(name);
|
232
232
|
} else if (importedExportsInfo) {
|
233
|
-
const importedExportInfo =
|
234
|
-
name
|
235
|
-
);
|
233
|
+
const importedExportInfo =
|
234
|
+
importedExportsInfo.getReadOnlyExportInfo(name);
|
236
235
|
if (importedExportInfo.provided === false) continue;
|
237
236
|
exports.add(name);
|
238
237
|
if (importedExportInfo.provided === true) continue;
|
@@ -192,7 +192,9 @@ class CommonJsExportsParserPlugin {
|
|
192
192
|
parser.hooks.call
|
193
193
|
.for("Object.defineProperty")
|
194
194
|
.tap("CommonJsExportsParserPlugin", expression => {
|
195
|
-
const expr = /** @type {import("estree").CallExpression} */ (
|
195
|
+
const expr = /** @type {import("estree").CallExpression} */ (
|
196
|
+
expression
|
197
|
+
);
|
196
198
|
if (!parser.isStatementLevelExpression(expr)) return;
|
197
199
|
if (expr.arguments.length !== 3) return;
|
198
200
|
if (expr.arguments[0].type === "SpreadElement") return;
|
@@ -182,10 +182,8 @@ class CommonJsImportsParserPlugin {
|
|
182
182
|
};
|
183
183
|
const createRequireHandler = callNew => expr => {
|
184
184
|
if (options.commonjsMagicComments) {
|
185
|
-
const {
|
186
|
-
|
187
|
-
errors: commentErrors
|
188
|
-
} = parser.parseCommentOptions(expr.range);
|
185
|
+
const { options: requireOptions, errors: commentErrors } =
|
186
|
+
parser.parseCommentOptions(expr.range);
|
189
187
|
|
190
188
|
if (commentErrors) {
|
191
189
|
for (const e of commentErrors) {
|
@@ -265,13 +265,14 @@ class NodeModuleDecoratorRuntimeModule extends RuntimeModule {
|
|
265
265
|
generate() {
|
266
266
|
const { runtimeTemplate } = this.compilation;
|
267
267
|
return Template.asString([
|
268
|
-
`${
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
268
|
+
`${RuntimeGlobals.nodeModuleDecorator} = ${runtimeTemplate.basicFunction(
|
269
|
+
"module",
|
270
|
+
[
|
271
|
+
"module.paths = [];",
|
272
|
+
"if (!module.children) module.children = [];",
|
273
|
+
"return module;"
|
274
|
+
]
|
275
|
+
)};`
|
275
276
|
]);
|
276
277
|
}
|
277
278
|
}
|
@@ -45,6 +45,7 @@ makeSerializable(
|
|
45
45
|
"webpack/lib/dependencies/CommonJsRequireContextDependency"
|
46
46
|
);
|
47
47
|
|
48
|
-
CommonJsRequireContextDependency.Template =
|
48
|
+
CommonJsRequireContextDependency.Template =
|
49
|
+
ContextDependencyTemplateAsRequireCall;
|
49
50
|
|
50
51
|
module.exports = CommonJsRequireContextDependency;
|
@@ -61,10 +61,11 @@ exports.create = (Dep, range, param, expr, options, contextOptions, parser) => {
|
|
61
61
|
|
62
62
|
const valueRange = param.range;
|
63
63
|
const { context, prefix } = splitContextFromPrefix(prefixRaw);
|
64
|
-
const {
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
const {
|
65
|
+
path: postfix,
|
66
|
+
query,
|
67
|
+
fragment
|
68
|
+
} = parseResource(postfixRaw, parser);
|
68
69
|
|
69
70
|
// When there are more than two quasis, the generated RegExp can be more precise
|
70
71
|
// We join the quasis with the expression regexp
|
@@ -160,10 +161,11 @@ exports.create = (Dep, range, param, expr, options, contextOptions, parser) => {
|
|
160
161
|
param.postfix && param.postfix.isString() ? param.postfix.range : null;
|
161
162
|
const valueRange = param.range;
|
162
163
|
const { context, prefix } = splitContextFromPrefix(prefixRaw);
|
163
|
-
const {
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
const {
|
165
|
+
path: postfix,
|
166
|
+
query,
|
167
|
+
fragment
|
168
|
+
} = parseResource(postfixRaw, parser);
|
167
169
|
const regExp = new RegExp(
|
168
170
|
`^${quoteMeta(prefix)}${options.wrappedContextRegExp.source}${quoteMeta(
|
169
171
|
postfix
|
@@ -411,9 +411,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
411
411
|
const ignoredExports = new Set(["default", ...this.activeExports]);
|
412
412
|
|
413
413
|
let hiddenExports = undefined;
|
414
|
-
const otherStarExports =
|
415
|
-
moduleGraph
|
416
|
-
);
|
414
|
+
const otherStarExports =
|
415
|
+
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
|
417
416
|
if (otherStarExports !== undefined) {
|
418
417
|
hiddenExports = new Set();
|
419
418
|
for (let i = 0; i < otherStarExports.namesSlice; i++) {
|
@@ -441,9 +440,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
441
440
|
const name = exportInfo.name;
|
442
441
|
if (ignoredExports.has(name)) continue;
|
443
442
|
if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;
|
444
|
-
const importedExportInfo =
|
445
|
-
name
|
446
|
-
);
|
443
|
+
const importedExportInfo =
|
444
|
+
importedExportsInfo.getReadOnlyExportInfo(name);
|
447
445
|
if (importedExportInfo.provided === false) continue;
|
448
446
|
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
449
447
|
hidden.add(name);
|
@@ -763,9 +761,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
763
761
|
`(reexported as '${this.name}')`
|
764
762
|
);
|
765
763
|
if (ids.length === 0 && this.name === null) {
|
766
|
-
const potentialConflicts =
|
767
|
-
moduleGraph
|
768
|
-
);
|
764
|
+
const potentialConflicts =
|
765
|
+
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
|
769
766
|
if (potentialConflicts && potentialConflicts.namesSlice > 0) {
|
770
767
|
const ownNames = new Set(
|
771
768
|
potentialConflicts.names.slice(
|
@@ -802,9 +799,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
802
799
|
conflictingModule,
|
803
800
|
exportInfo.name
|
804
801
|
);
|
805
|
-
const conflictingTarget =
|
806
|
-
moduleGraph
|
807
|
-
);
|
802
|
+
const conflictingTarget =
|
803
|
+
conflictingExportInfo.getTerminalBinding(moduleGraph);
|
808
804
|
if (!conflictingTarget) continue;
|
809
805
|
if (target === conflictingTarget) continue;
|
810
806
|
const list = conflicts.get(conflictingDependency.request);
|
@@ -882,7 +878,9 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
882
878
|
apply(dependency, source, templateContext) {
|
883
879
|
const { moduleGraph, runtime, concatenationScope } = templateContext;
|
884
880
|
|
885
|
-
const dep = /** @type {HarmonyExportImportedSpecifierDependency} */ (
|
881
|
+
const dep = /** @type {HarmonyExportImportedSpecifierDependency} */ (
|
882
|
+
dependency
|
883
|
+
);
|
886
884
|
|
887
885
|
const mode = dep.getMode(moduleGraph, runtime);
|
888
886
|
|
@@ -152,10 +152,8 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
152
152
|
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e));
|
153
153
|
return true;
|
154
154
|
});
|
155
|
-
const {
|
156
|
-
|
157
|
-
hotAcceptWithoutCallback
|
158
|
-
} = HotModuleReplacementPlugin.getParserHooks(parser);
|
155
|
+
const { hotAcceptCallback, hotAcceptWithoutCallback } =
|
156
|
+
HotModuleReplacementPlugin.getParserHooks(parser);
|
159
157
|
hotAcceptCallback.tap(
|
160
158
|
"HarmonyImportDependencyParserPlugin",
|
161
159
|
(expr, requests) => {
|
@@ -243,12 +243,8 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
243
243
|
*/
|
244
244
|
apply(dependency, source, templateContext) {
|
245
245
|
const dep = /** @type {HarmonyImportSpecifierDependency} */ (dependency);
|
246
|
-
const {
|
247
|
-
|
248
|
-
module,
|
249
|
-
runtime,
|
250
|
-
concatenationScope
|
251
|
-
} = templateContext;
|
246
|
+
const { moduleGraph, module, runtime, concatenationScope } =
|
247
|
+
templateContext;
|
252
248
|
const connection = moduleGraph.getConnection(dep);
|
253
249
|
// Skip rendering depending when dependency is conditional
|
254
250
|
if (connection && !connection.isTargetActive(runtime)) return;
|
@@ -287,11 +283,8 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|
287
283
|
} else {
|
288
284
|
super.apply(dependency, source, templateContext);
|
289
285
|
|
290
|
-
const {
|
291
|
-
|
292
|
-
initFragments,
|
293
|
-
runtimeRequirements
|
294
|
-
} = templateContext;
|
286
|
+
const { runtimeTemplate, initFragments, runtimeRequirements } =
|
287
|
+
templateContext;
|
295
288
|
|
296
289
|
exportExpr = runtimeTemplate.exportFromImport({
|
297
290
|
moduleGraph,
|
@@ -81,9 +81,9 @@ ImportDependency.Template = class ImportDependencyTemplate extends (
|
|
81
81
|
{ runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements }
|
82
82
|
) {
|
83
83
|
const dep = /** @type {ImportDependency} */ (dependency);
|
84
|
-
const block = /** @type {AsyncDependenciesBlock} */ (
|
85
|
-
dep
|
86
|
-
)
|
84
|
+
const block = /** @type {AsyncDependenciesBlock} */ (
|
85
|
+
moduleGraph.getParentBlock(dep)
|
86
|
+
);
|
87
87
|
const content = runtimeTemplate.moduleNamespacePromise({
|
88
88
|
chunkGraph,
|
89
89
|
block: block,
|
@@ -36,10 +36,8 @@ class ImportParserPlugin {
|
|
36
36
|
/** @type {RawChunkGroupOptions} */
|
37
37
|
const groupOptions = {};
|
38
38
|
|
39
|
-
const {
|
40
|
-
|
41
|
-
errors: commentErrors
|
42
|
-
} = parser.parseCommentOptions(expr.range);
|
39
|
+
const { options: importOptions, errors: commentErrors } =
|
40
|
+
parser.parseCommentOptions(expr.range);
|
43
41
|
|
44
42
|
if (commentErrors) {
|
45
43
|
for (const e of commentErrors) {
|
@@ -46,9 +46,8 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
46
46
|
? dependenciesExpr.items
|
47
47
|
: [dependenciesExpr];
|
48
48
|
const successExpressionArg = expr.arguments[1];
|
49
|
-
const successExpression =
|
50
|
-
successExpressionArg
|
51
|
-
);
|
49
|
+
const successExpression =
|
50
|
+
getFunctionExpression(successExpressionArg);
|
52
51
|
|
53
52
|
if (successExpression) {
|
54
53
|
parser.walkExpressions(successExpression.expressions);
|
@@ -68,9 +68,9 @@ RequireEnsureDependency.Template = class RequireEnsureDependencyTemplate extends
|
|
68
68
|
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements }
|
69
69
|
) {
|
70
70
|
const dep = /** @type {RequireEnsureDependency} */ (dependency);
|
71
|
-
const depBlock = /** @type {AsyncDependenciesBlock} */ (
|
72
|
-
dep
|
73
|
-
)
|
71
|
+
const depBlock = /** @type {AsyncDependenciesBlock} */ (
|
72
|
+
moduleGraph.getParentBlock(dep)
|
73
|
+
);
|
74
74
|
const promise = runtimeTemplate.blockPromise({
|
75
75
|
chunkGraph,
|
76
76
|
block: depBlock,
|
@@ -62,12 +62,12 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
|
|
62
62
|
apply(dependency, source, templateContext) {
|
63
63
|
const { chunkGraph, moduleGraph, runtimeRequirements } = templateContext;
|
64
64
|
const dep = /** @type {WorkerDependency} */ (dependency);
|
65
|
-
const block = /** @type {AsyncDependenciesBlock} */ (
|
66
|
-
dependency
|
67
|
-
)
|
68
|
-
const entrypoint = /** @type {Entrypoint} */ (
|
69
|
-
block
|
70
|
-
)
|
65
|
+
const block = /** @type {AsyncDependenciesBlock} */ (
|
66
|
+
moduleGraph.getParentBlock(dependency)
|
67
|
+
);
|
68
|
+
const entrypoint = /** @type {Entrypoint} */ (
|
69
|
+
chunkGraph.getBlockChunkGroup(block)
|
70
|
+
);
|
71
71
|
const chunk = entrypoint.getEntrypointChunk();
|
72
72
|
|
73
73
|
runtimeRequirements.add(RuntimeGlobals.publicPath);
|
@@ -186,21 +186,18 @@ class WorkerPlugin {
|
|
186
186
|
spread: hasSpreadInOptions,
|
187
187
|
insertType,
|
188
188
|
insertLocation
|
189
|
-
} =
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
options: importOptions,
|
202
|
-
errors: commentErrors
|
203
|
-
} = parser.parseCommentOptions(expr.range);
|
189
|
+
} = arg2 && arg2.type === "ObjectExpression"
|
190
|
+
? parseObjectExpression(parser, arg2)
|
191
|
+
: {
|
192
|
+
expressions: {},
|
193
|
+
otherElements: [],
|
194
|
+
values: {},
|
195
|
+
spread: false,
|
196
|
+
insertType: arg2 ? "spread" : "argument",
|
197
|
+
insertLocation: arg2 ? arg2.range : arg1.range[1]
|
198
|
+
};
|
199
|
+
const { options: importOptions, errors: commentErrors } =
|
200
|
+
parser.parseCommentOptions(expr.range);
|
204
201
|
|
205
202
|
if (commentErrors) {
|
206
203
|
for (const e of commentErrors) {
|
@@ -280,9 +277,9 @@ class WorkerPlugin {
|
|
280
277
|
)}|${i}`;
|
281
278
|
const hash = createHash(compilation.outputOptions.hashFunction);
|
282
279
|
hash.update(name);
|
283
|
-
const digest = /** @type {string} */ (
|
284
|
-
compilation.outputOptions.hashDigest
|
285
|
-
)
|
280
|
+
const digest = /** @type {string} */ (
|
281
|
+
hash.digest(compilation.outputOptions.hashDigest)
|
282
|
+
);
|
286
283
|
entryOptions.runtime = digest.slice(
|
287
284
|
0,
|
288
285
|
compilation.outputOptions.hashDigestLength
|
@@ -368,7 +365,9 @@ class WorkerPlugin {
|
|
368
365
|
(call ? parser.hooks.call : parser.hooks.new)
|
369
366
|
.for(harmonySpecifierTag)
|
370
367
|
.tap("WorkerPlugin", expr => {
|
371
|
-
const settings = /** @type {HarmonySettings} */ (
|
368
|
+
const settings = /** @type {HarmonySettings} */ (
|
369
|
+
parser.currentTagData
|
370
|
+
);
|
372
371
|
if (
|
373
372
|
!settings ||
|
374
373
|
settings.source !== source ||
|
@@ -196,8 +196,9 @@ class LazyCompilationProxyModule extends Module {
|
|
196
196
|
const sources = new Map();
|
197
197
|
const runtimeRequirements = new Set();
|
198
198
|
runtimeRequirements.add(RuntimeGlobals.module);
|
199
|
-
const clientDep = /** @type {CommonJsRequireDependency} */ (
|
200
|
-
.dependencies[0]
|
199
|
+
const clientDep = /** @type {CommonJsRequireDependency} */ (
|
200
|
+
this.dependencies[0]
|
201
|
+
);
|
201
202
|
const clientModule = moduleGraph.getModule(clientDep);
|
202
203
|
const block = this.blocks[0];
|
203
204
|
const client = Template.asString([
|
@@ -290,8 +291,9 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
|
|
290
291
|
* @returns {void}
|
291
292
|
*/
|
292
293
|
create(data, callback) {
|
293
|
-
const dependency = /** @type {LazyCompilationDependency} */ (
|
294
|
-
.dependencies[0]
|
294
|
+
const dependency = /** @type {LazyCompilationDependency} */ (
|
295
|
+
data.dependencies[0]
|
296
|
+
);
|
295
297
|
callback(null, {
|
296
298
|
module: dependency.proxyModule.originalModule
|
297
299
|
});
|
@@ -63,9 +63,9 @@ class HashedModuleIdsPlugin {
|
|
63
63
|
const ident = getFullModuleName(module, context, compiler.root);
|
64
64
|
const hash = createHash(options.hashFunction);
|
65
65
|
hash.update(ident || "");
|
66
|
-
const hashId = /** @type {string} */ (
|
67
|
-
options.hashDigest
|
68
|
-
)
|
66
|
+
const hashId = /** @type {string} */ (
|
67
|
+
hash.digest(options.hashDigest)
|
68
|
+
);
|
69
69
|
let len = options.hashDigestLength;
|
70
70
|
while (usedIds.has(hashId.substr(0, len))) len++;
|
71
71
|
const moduleId = hashId.substr(0, len);
|
@@ -98,9 +98,8 @@ class OccurrenceModuleIdsPlugin {
|
|
98
98
|
connections
|
99
99
|
] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
|
100
100
|
if (!originModule) continue;
|
101
|
-
const chunkModules =
|
102
|
-
originModule
|
103
|
-
);
|
101
|
+
const chunkModules =
|
102
|
+
chunkGraph.getNumberOfModuleChunks(originModule);
|
104
103
|
for (const c of connections) {
|
105
104
|
if (!c.isTargetActive(undefined)) continue;
|
106
105
|
if (!c.dependency) continue;
|
package/lib/index.js
CHANGED
@@ -50,9 +50,11 @@ const memoize = require("./util/memoize");
|
|
50
50
|
*/
|
51
51
|
const lazyFunction = factory => {
|
52
52
|
const fac = memoize(factory);
|
53
|
-
const f = /** @type {any} */ (
|
54
|
-
|
55
|
-
|
53
|
+
const f = /** @type {any} */ (
|
54
|
+
(...args) => {
|
55
|
+
return fac()(...args);
|
56
|
+
}
|
57
|
+
);
|
56
58
|
return /** @type {T} */ (f);
|
57
59
|
};
|
58
60
|
|