webpack 5.104.1 → 5.105.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.
- package/bin/webpack.js +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +13 -1
- package/lib/AsyncDependencyToInitialChunkError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +2 -0
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +8 -4
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +2 -0
- package/lib/CleanPlugin.js +4 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +280 -236
- package/lib/Compiler.js +3 -2
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +3 -3
- package/lib/ContextModule.js +248 -111
- package/lib/ContextModuleFactory.js +14 -2
- package/lib/DefinePlugin.js +3 -1
- package/lib/DelegatedModule.js +6 -0
- package/lib/DelegatedModuleFactoryPlugin.js +2 -0
- package/lib/Dependency.js +6 -1
- package/lib/DependencyTemplates.js +3 -2
- package/lib/DllModule.js +2 -0
- package/lib/DllReferencePlugin.js +1 -0
- package/lib/DotenvPlugin.js +11 -5
- package/lib/DynamicEntryPlugin.js +1 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +17 -13
- package/lib/ExportsInfo.js +8 -4
- package/lib/ExternalModule.js +16 -0
- package/lib/FalseIIFEUmdWarning.js +1 -0
- package/lib/FileSystemInfo.js +49 -25
- package/lib/FlagDependencyExportsPlugin.js +8 -1
- package/lib/FlagDependencyUsagePlugin.js +9 -7
- package/lib/HarmonyLinkingError.js +1 -0
- package/lib/HookWebpackError.js +2 -0
- package/lib/HotModuleReplacementPlugin.js +16 -2
- package/lib/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +4 -1
- package/lib/Module.js +7 -4
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +2 -1
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -1
- package/lib/ModuleHashingError.js +2 -0
- package/lib/ModuleInfoHeaderPlugin.js +6 -1
- package/lib/ModuleNotFoundError.js +1 -0
- package/lib/ModuleParseError.js +5 -1
- package/lib/ModuleProfile.js +1 -1
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleSourceTypeConstants.js +1 -11
- package/lib/ModuleStoreError.js +2 -0
- package/lib/ModuleWarning.js +3 -1
- package/lib/MultiCompiler.js +11 -7
- package/lib/MultiWatching.js +2 -2
- package/lib/NoModeWarning.js +1 -0
- package/lib/NodeStuffInWebError.js +1 -0
- package/lib/NormalModule.js +26 -5
- package/lib/NormalModuleFactory.js +20 -4
- package/lib/OptionsApply.js +3 -1
- package/lib/ProgressPlugin.js +4 -0
- package/lib/RawModule.js +2 -0
- package/lib/RuntimeModule.js +10 -0
- package/lib/RuntimePlugin.js +7 -9
- package/lib/RuntimeTemplate.js +14 -7
- package/lib/SourceMapDevToolPlugin.js +30 -23
- package/lib/Template.js +10 -5
- package/lib/TemplatedPathPlugin.js +4 -2
- package/lib/UnhandledSchemeError.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -1
- package/lib/Watching.js +5 -0
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsApply.js +60 -40
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +9 -3
- package/lib/asset/AssetModulesPlugin.js +33 -2
- package/lib/asset/AssetSourceGenerator.js +1 -0
- package/lib/asset/RawDataUrlModule.js +4 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +31 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +41 -8
- package/lib/cache/getLazyHashedEtag.js +13 -4
- package/lib/cache/mergeEtags.js +3 -1
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +65 -44
- package/lib/config/normalization.js +96 -0
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/RemoteModule.js +19 -0
- package/lib/css/CssGenerator.js +31 -4
- package/lib/css/CssModulesPlugin.js +26 -30
- package/lib/css/CssParser.js +12 -9
- package/lib/debug/ProfilingPlugin.js +1 -0
- package/lib/dependencies/AMDDefineDependency.js +3 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
- package/lib/dependencies/AMDPlugin.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
- package/lib/dependencies/CachedConstDependency.js +1 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
- package/lib/dependencies/ConstDependency.js +1 -0
- package/lib/dependencies/ContextDependencyHelpers.js +11 -4
- package/lib/dependencies/ContextElementDependency.js +1 -0
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +5 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
- package/lib/dependencies/CssUrlDependency.js +2 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
- package/lib/dependencies/ImportDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +53 -11
- package/lib/dependencies/ImportParserPlugin.js +7 -12
- package/lib/dependencies/LoaderPlugin.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
- package/lib/dependencies/ProvidedDependency.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +9 -3
- package/lib/dependencies/WorkerPlugin.js +1 -0
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/errors/BuildCycleError.js +4 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
- package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +5 -0
- package/lib/hmr/lazyCompilationBackend.js +3 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
- package/lib/ids/SyncModuleIdsPlugin.js +5 -1
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
- package/lib/javascript/JavascriptModulesPlugin.js +29 -8
- package/lib/javascript/JavascriptParser.js +47 -14
- package/lib/json/JsonParser.js +6 -0
- package/lib/library/AbstractLibraryPlugin.js +4 -1
- package/lib/library/AmdLibraryPlugin.js +2 -1
- package/lib/library/AssignLibraryPlugin.js +6 -2
- package/lib/library/EnableLibraryPlugin.js +1 -0
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +130 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +4 -3
- package/lib/logging/createConsoleLogger.js +3 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
- package/lib/optimize/ConcatenatedModule.js +33 -19
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
- package/lib/optimize/InnerGraph.js +5 -3
- package/lib/optimize/InnerGraphPlugin.js +25 -25
- package/lib/optimize/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
- package/lib/optimize/RealContentHashPlugin.js +35 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +14 -3
- package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
- package/lib/performance/NoAsyncChunksWarning.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +2 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
- package/lib/rules/RuleSetCompiler.js +2 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +27 -7
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/BinaryMiddleware.js +4 -0
- package/lib/serialization/FileMiddleware.js +9 -4
- package/lib/serialization/ObjectMiddleware.js +34 -11
- package/lib/serialization/PlainObjectSerializer.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +60 -0
- package/lib/sharing/ConsumeSharedPlugin.js +5 -4
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +24 -25
- package/lib/sharing/resolveMatchedConfigs.js +2 -2
- package/lib/sharing/utils.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +4 -3
- package/lib/util/AppendOnlyStackedSet.js +57 -0
- package/lib/util/Hash.js +1 -0
- package/lib/util/IterableHelpers.js +1 -0
- package/lib/util/LazyBucketSortedSet.js +1 -0
- package/lib/util/LazySet.js +1 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/SortableSet.js +1 -0
- package/lib/util/StringXor.js +1 -0
- package/lib/util/binarySearchBounds.js +15 -8
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +6 -1
- package/lib/util/comparators.js +21 -1
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +3 -2
- package/lib/util/conventions.js +3 -2
- package/lib/util/deterministicGrouping.js +13 -1
- package/lib/util/extractSourceMap.js +12 -13
- package/lib/util/fs.js +15 -19
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/BulkUpdateHash.js +7 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +16 -1
- package/lib/util/identifier.js +7 -2
- package/lib/util/magicComment.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -0
- package/lib/util/runtime.js +15 -1
- package/lib/util/semver.js +1 -0
- package/lib/util/serialization.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/webpack.js +13 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/package.json +20 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +71 -5
- package/types.d.ts +339 -93
|
@@ -28,6 +28,7 @@ const propertyAccess = require("../util/propertyAccess");
|
|
|
28
28
|
const ConstDependency = require("./ConstDependency");
|
|
29
29
|
|
|
30
30
|
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
|
31
|
+
/** @typedef {import("estree").Identifier} Identifier */
|
|
31
32
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
32
33
|
/** @typedef {import("../Compiler")} Compiler */
|
|
33
34
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
@@ -44,18 +45,24 @@ const getCriticalDependencyWarning = memoize(() =>
|
|
|
44
45
|
|
|
45
46
|
const PLUGIN_NAME = "ImportMetaPlugin";
|
|
46
47
|
|
|
48
|
+
/** @type {WeakMap<Compilation, { stringify: string, env: Record<string, string> }>} */
|
|
49
|
+
const compilationMetaEnvMap = new WeakMap();
|
|
50
|
+
|
|
47
51
|
/**
|
|
48
52
|
* Collect import.meta.env definitions from DefinePlugin and build JSON string
|
|
49
53
|
* @param {Compilation} compilation the compilation
|
|
50
|
-
* @returns {string} env object as JSON string
|
|
54
|
+
* @returns {{ stringify: string, env: Record<string, string> }} env object as JSON string
|
|
51
55
|
*/
|
|
52
56
|
const collectImportMetaEnvDefinitions = (compilation) => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return "{}";
|
|
57
|
+
const cached = compilationMetaEnvMap.get(compilation);
|
|
58
|
+
if (cached) {
|
|
59
|
+
return cached;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
const definePluginHooks = DefinePlugin.getCompilationHooks(compilation);
|
|
63
|
+
const definitions = definePluginHooks.definitions.call({});
|
|
64
|
+
/** @type {Record<string, string>} */
|
|
65
|
+
const env = {};
|
|
59
66
|
/** @type {string[]} */
|
|
60
67
|
const pairs = [];
|
|
61
68
|
for (const key of Object.keys(definitions)) {
|
|
@@ -63,10 +70,12 @@ const collectImportMetaEnvDefinitions = (compilation) => {
|
|
|
63
70
|
const envKey = key.slice("import.meta.env.".length);
|
|
64
71
|
const value = definitions[key];
|
|
65
72
|
pairs.push(`${JSON.stringify(envKey)}:${value}`);
|
|
73
|
+
env[envKey] = /** @type {string} */ (value);
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
const result = { stringify: `{${pairs.join(",")}}`, env };
|
|
77
|
+
compilationMetaEnvMap.set(compilation, result);
|
|
78
|
+
return result;
|
|
70
79
|
};
|
|
71
80
|
|
|
72
81
|
/**
|
|
@@ -148,10 +157,15 @@ class ImportMetaPlugin {
|
|
|
148
157
|
* @param {Members} members members
|
|
149
158
|
* @returns {string} error message
|
|
150
159
|
*/
|
|
151
|
-
const importMetaUnknownProperty = (members) =>
|
|
152
|
-
|
|
160
|
+
const importMetaUnknownProperty = (members) => {
|
|
161
|
+
if (importMeta === "preserve-unknown") {
|
|
162
|
+
return `import.meta${propertyAccess(members, 0)}`;
|
|
163
|
+
}
|
|
164
|
+
return `${Template.toNormalComment(
|
|
153
165
|
`unsupported import.meta.${members.join(".")}`
|
|
154
166
|
)} undefined${propertyAccess(members, 1)}`;
|
|
167
|
+
};
|
|
168
|
+
|
|
155
169
|
parser.hooks.typeof
|
|
156
170
|
.for("import.meta")
|
|
157
171
|
.tap(
|
|
@@ -223,6 +237,9 @@ class ImportMetaPlugin {
|
|
|
223
237
|
RuntimeGlobals.module
|
|
224
238
|
);
|
|
225
239
|
break;
|
|
240
|
+
case "env":
|
|
241
|
+
str += `env: ${collectImportMetaEnvDefinitions(compilation).stringify},`;
|
|
242
|
+
break;
|
|
226
243
|
default:
|
|
227
244
|
str += `[${JSON.stringify(
|
|
228
245
|
prop.id
|
|
@@ -327,12 +344,31 @@ class ImportMetaPlugin {
|
|
|
327
344
|
PLUGIN_NAME,
|
|
328
345
|
toConstantDependency(parser, JSON.stringify("object"))
|
|
329
346
|
);
|
|
347
|
+
parser.hooks.expressionMemberChain
|
|
348
|
+
.for("import.meta")
|
|
349
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
350
|
+
if (members[0] === "env" && members[1]) {
|
|
351
|
+
const name = members[1];
|
|
352
|
+
const { env } = collectImportMetaEnvDefinitions(compilation);
|
|
353
|
+
if (!Object.prototype.hasOwnProperty.call(env, name)) {
|
|
354
|
+
const dep = new ConstDependency(
|
|
355
|
+
"undefined",
|
|
356
|
+
/** @type {Range} */ (expr.range)
|
|
357
|
+
);
|
|
358
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
359
|
+
parser.state.module.addPresentationalDependency(dep);
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
330
364
|
parser.hooks.expression
|
|
331
365
|
.for("import.meta.env")
|
|
332
366
|
.tap(PLUGIN_NAME, (expr) => {
|
|
333
|
-
const
|
|
367
|
+
const { stringify } =
|
|
368
|
+
collectImportMetaEnvDefinitions(compilation);
|
|
369
|
+
|
|
334
370
|
const dep = new ConstDependency(
|
|
335
|
-
|
|
371
|
+
stringify,
|
|
336
372
|
/** @type {Range} */ (expr.range)
|
|
337
373
|
);
|
|
338
374
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
@@ -355,6 +391,11 @@ class ImportMetaPlugin {
|
|
|
355
391
|
parser.hooks.unhandledExpressionMemberChain
|
|
356
392
|
.for("import.meta")
|
|
357
393
|
.tap(PLUGIN_NAME, (expr, members) => {
|
|
394
|
+
// unknown import.meta properties should be determined at runtime
|
|
395
|
+
if (importMeta === "preserve-unknown") {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
|
|
358
399
|
// keep import.meta.env unknown property
|
|
359
400
|
// don't evaluate import.meta.env.UNKNOWN_PROPERTY -> undefined.UNKNOWN_PROPERTY
|
|
360
401
|
// `dirname` and `filename` logic in NodeStuffPlugin
|
|
@@ -373,6 +414,7 @@ class ImportMetaPlugin {
|
|
|
373
414
|
parser.state.module.addPresentationalDependency(dep);
|
|
374
415
|
return true;
|
|
375
416
|
});
|
|
417
|
+
|
|
376
418
|
parser.hooks.evaluate
|
|
377
419
|
.for("MemberExpression")
|
|
378
420
|
.tap(PLUGIN_NAME, (expression) => {
|
|
@@ -17,7 +17,7 @@ const ContextDependencyHelpers = require("./ContextDependencyHelpers");
|
|
|
17
17
|
const ImportContextDependency = require("./ImportContextDependency");
|
|
18
18
|
const ImportDependency = require("./ImportDependency");
|
|
19
19
|
const ImportEagerDependency = require("./ImportEagerDependency");
|
|
20
|
-
const {
|
|
20
|
+
const { createGetImportPhase } = require("./ImportPhase");
|
|
21
21
|
const ImportWeakDependency = require("./ImportWeakDependency");
|
|
22
22
|
|
|
23
23
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
@@ -262,11 +262,14 @@ class ImportParserPlugin {
|
|
|
262
262
|
parser.hooks.importCall.tap(PLUGIN_NAME, (expr, importThen) => {
|
|
263
263
|
const param = parser.evaluateExpression(expr.source);
|
|
264
264
|
|
|
265
|
+
/** @type {null | string} */
|
|
265
266
|
let chunkName = null;
|
|
266
267
|
let mode = /** @type {ContextMode} */ (this.options.dynamicImportMode);
|
|
268
|
+
/** @type {null | RegExp} */
|
|
267
269
|
let include = null;
|
|
270
|
+
/** @type {null | RegExp} */
|
|
268
271
|
let exclude = null;
|
|
269
|
-
/** @type {
|
|
272
|
+
/** @type {null | RawReferencedExports} */
|
|
270
273
|
let exports = null;
|
|
271
274
|
/** @type {RawChunkGroupOptions} */
|
|
272
275
|
const groupOptions = {};
|
|
@@ -557,15 +560,6 @@ class ImportParserPlugin {
|
|
|
557
560
|
mode = "async-weak";
|
|
558
561
|
}
|
|
559
562
|
|
|
560
|
-
if (ImportPhaseUtils.isDefer(phase)) {
|
|
561
|
-
parser.state.module.addWarning(
|
|
562
|
-
new UnsupportedFeatureWarning(
|
|
563
|
-
"import.defer() is not yet supported for ContextModule (the import path is a dynamic expression).",
|
|
564
|
-
/** @type {DependencyLocation} */ (expr.loc)
|
|
565
|
-
)
|
|
566
|
-
);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
563
|
const dep = ContextDependencyHelpers.create(
|
|
570
564
|
ImportContextDependency,
|
|
571
565
|
/** @type {Range} */ (expr.range),
|
|
@@ -586,7 +580,8 @@ class ImportParserPlugin {
|
|
|
586
580
|
typePrefix: "import()",
|
|
587
581
|
category: "esm",
|
|
588
582
|
referencedExports: exports,
|
|
589
|
-
attributes: getImportAttributes(expr)
|
|
583
|
+
attributes: getImportAttributes(expr),
|
|
584
|
+
phase
|
|
590
585
|
},
|
|
591
586
|
parser
|
|
592
587
|
);
|
|
@@ -10,6 +10,7 @@ const LazySet = require("../util/LazySet");
|
|
|
10
10
|
const LoaderDependency = require("./LoaderDependency");
|
|
11
11
|
const LoaderImportDependency = require("./LoaderImportDependency");
|
|
12
12
|
|
|
13
|
+
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
|
|
13
14
|
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
|
14
15
|
/** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */
|
|
15
16
|
/** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */
|
|
@@ -116,7 +117,9 @@ class LoaderPlugin {
|
|
|
116
117
|
)
|
|
117
118
|
);
|
|
118
119
|
}
|
|
120
|
+
/** @type {null | RawSourceMap} */
|
|
119
121
|
let map;
|
|
122
|
+
/** @type {string | Buffer | undefined} */
|
|
120
123
|
let source;
|
|
121
124
|
if (moduleSource.sourceAndMap) {
|
|
122
125
|
const sourceAndMap = moduleSource.sourceAndMap();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Natsu @xiaoxiaojx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const InitFragment = require("../InitFragment");
|
|
9
|
+
const makeSerializable = require("../util/makeSerializable");
|
|
10
|
+
const NullDependency = require("./NullDependency");
|
|
11
|
+
|
|
12
|
+
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
13
|
+
/** @typedef {import("../Dependency")} Dependency */
|
|
14
|
+
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
17
|
+
/**
|
|
18
|
+
* A dependency that adds an init fragment to the module
|
|
19
|
+
*/
|
|
20
|
+
class ModuleInitFragmentDependency extends NullDependency {
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} initCode the initialization code
|
|
23
|
+
* @param {string[]} runtimeRequirements runtime requirements
|
|
24
|
+
* @param {string=} key unique key to avoid emitting the same initialization code twice
|
|
25
|
+
*/
|
|
26
|
+
constructor(initCode, runtimeRequirements, key) {
|
|
27
|
+
super();
|
|
28
|
+
this.initCode = initCode;
|
|
29
|
+
this.runtimeRequirements = runtimeRequirements;
|
|
30
|
+
this.key = key;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {ObjectSerializerContext} context context
|
|
35
|
+
*/
|
|
36
|
+
serialize(context) {
|
|
37
|
+
const { write } = context;
|
|
38
|
+
write(this.initCode);
|
|
39
|
+
write(this.runtimeRequirements);
|
|
40
|
+
write(this.key);
|
|
41
|
+
super.serialize(context);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {ObjectDeserializerContext} context context
|
|
46
|
+
*/
|
|
47
|
+
deserialize(context) {
|
|
48
|
+
const { read } = context;
|
|
49
|
+
this.initCode = read();
|
|
50
|
+
this.runtimeRequirements = read();
|
|
51
|
+
this.key = read();
|
|
52
|
+
super.deserialize(context);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
makeSerializable(
|
|
57
|
+
ModuleInitFragmentDependency,
|
|
58
|
+
"webpack/lib/dependencies/ModuleInitFragmentDependency"
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
ModuleInitFragmentDependency.Template = class ModuleInitFragmentDependencyTemplate extends (
|
|
62
|
+
NullDependency.Template
|
|
63
|
+
) {
|
|
64
|
+
/**
|
|
65
|
+
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
66
|
+
* @param {ReplaceSource} source the current replace source which can be modified
|
|
67
|
+
* @param {DependencyTemplateContext} templateContext the context object
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
apply(dependency, source, { initFragments, runtimeRequirements }) {
|
|
71
|
+
const dep = /** @type {ModuleInitFragmentDependency} */ (dependency);
|
|
72
|
+
for (const req of dep.runtimeRequirements) {
|
|
73
|
+
runtimeRequirements.add(req);
|
|
74
|
+
}
|
|
75
|
+
initFragments.push(
|
|
76
|
+
new InitFragment(
|
|
77
|
+
dep.initCode,
|
|
78
|
+
InitFragment.STAGE_CONSTANTS,
|
|
79
|
+
0,
|
|
80
|
+
dep.key,
|
|
81
|
+
undefined
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
module.exports = ModuleInitFragmentDependency;
|
|
@@ -10,11 +10,14 @@ const RequireEnsureDependency = require("./RequireEnsureDependency");
|
|
|
10
10
|
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
|
11
11
|
const getFunctionExpression = require("./getFunctionExpression");
|
|
12
12
|
|
|
13
|
+
/** @typedef {import("estree").Expression} Expression */
|
|
14
|
+
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
13
15
|
/** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */
|
|
14
16
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
15
17
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
16
18
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
17
19
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
20
|
+
/** @typedef {import("./getFunctionExpression").FunctionExpressionResult} FunctionExpressionResult */
|
|
18
21
|
|
|
19
22
|
const PLUGIN_NAME = "RequireEnsureDependenciesBlockParserPlugin";
|
|
20
23
|
|
|
@@ -27,8 +30,10 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
|
27
30
|
parser.hooks.call.for("require.ensure").tap(PLUGIN_NAME, (expr) => {
|
|
28
31
|
/** @type {string | GroupOptions | null} */
|
|
29
32
|
let chunkName = null;
|
|
30
|
-
|
|
31
|
-
let
|
|
33
|
+
/** @type {undefined | Expression | SpreadElement} */
|
|
34
|
+
let errorExpressionArg;
|
|
35
|
+
/** @type {undefined | FunctionExpressionResult} */
|
|
36
|
+
let errorExpression;
|
|
32
37
|
switch (expr.arguments.length) {
|
|
33
38
|
case 4: {
|
|
34
39
|
const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
|
|
@@ -23,20 +23,26 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
23
23
|
/** @typedef {import("../util/Hash")} Hash */
|
|
24
24
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {object} WorkerDependencyOptions
|
|
28
|
+
* @property {string=} publicPath public path for the worker
|
|
29
|
+
* @property {boolean=} needNewUrl true when need generate `new URL(...)`, otherwise false
|
|
30
|
+
*/
|
|
31
|
+
|
|
26
32
|
class WorkerDependency extends ModuleDependency {
|
|
27
33
|
/**
|
|
28
34
|
* @param {string} request request
|
|
29
35
|
* @param {Range} range range
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {string=} workerDependencyOptions.publicPath public path for the worker
|
|
32
|
-
* @param {boolean=} workerDependencyOptions.needNewUrl need generate `new URL(...)`
|
|
36
|
+
* @param {WorkerDependencyOptions} workerDependencyOptions options
|
|
33
37
|
*/
|
|
34
38
|
constructor(request, range, workerDependencyOptions) {
|
|
35
39
|
super(request);
|
|
36
40
|
this.range = range;
|
|
37
41
|
// If options are updated, don't forget to update the hash and serialization functions
|
|
42
|
+
/** @type {WorkerDependencyOptions} */
|
|
38
43
|
this.options = workerDependencyOptions;
|
|
39
44
|
/** Cache the hash */
|
|
45
|
+
/** @type {undefined | string} */
|
|
40
46
|
this._hashUpdate = undefined;
|
|
41
47
|
}
|
|
42
48
|
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
|
11
11
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
12
12
|
|
|
13
|
+
/** @typedef {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined }} FunctionExpressionResult */
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* @param {Expression | SpreadElement} expr expressions
|
|
15
|
-
* @returns {
|
|
17
|
+
* @returns {FunctionExpressionResult | undefined} function expression with additional information
|
|
16
18
|
*/
|
|
17
19
|
module.exports = (expr) => {
|
|
18
20
|
// <FunctionExpression>
|
|
@@ -11,7 +11,7 @@ const WebpackError = require("../WebpackError");
|
|
|
11
11
|
|
|
12
12
|
class BuildCycleError extends WebpackError {
|
|
13
13
|
/**
|
|
14
|
-
* Creates an instance of
|
|
14
|
+
* Creates an instance of BuildCycleError.
|
|
15
15
|
* @param {Module} module the module starting the cycle
|
|
16
16
|
*/
|
|
17
17
|
constructor(module) {
|
|
@@ -19,9 +19,12 @@ class BuildCycleError extends WebpackError {
|
|
|
19
19
|
"There is a circular build dependency, which makes it impossible to create this module"
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
+
/** @type {string} */
|
|
22
23
|
this.name = "BuildCycleError";
|
|
24
|
+
/** @type {Module} */
|
|
23
25
|
this.module = module;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
/** @type {typeof BuildCycleError} */
|
|
27
30
|
module.exports = BuildCycleError;
|
|
@@ -212,6 +212,7 @@ class ModuleChunkFormatPlugin {
|
|
|
212
212
|
)}\n`
|
|
213
213
|
);
|
|
214
214
|
|
|
215
|
+
/** @type {Set<Chunk>} */
|
|
215
216
|
const loadedChunks = new Set();
|
|
216
217
|
for (let i = 0; i < entries.length; i++) {
|
|
217
218
|
const [module, entrypoint] = entries[i];
|
|
@@ -225,13 +226,14 @@ class ModuleChunkFormatPlugin {
|
|
|
225
226
|
/** @type {Chunk} */ (runtimeChunk),
|
|
226
227
|
undefined
|
|
227
228
|
);
|
|
229
|
+
/** @type {Set<Chunk>} */
|
|
228
230
|
const processChunks = new Set();
|
|
229
|
-
for (const
|
|
230
|
-
if (loadedChunks.has(
|
|
231
|
+
for (const chunk of chunks) {
|
|
232
|
+
if (loadedChunks.has(chunk)) {
|
|
231
233
|
continue;
|
|
232
234
|
}
|
|
233
|
-
loadedChunks.add(
|
|
234
|
-
processChunks.add(
|
|
235
|
+
loadedChunks.add(chunk);
|
|
236
|
+
processChunks.add(chunk);
|
|
235
237
|
}
|
|
236
238
|
const sourceWithDependentChunks = withDependentChunks(
|
|
237
239
|
processChunks,
|
|
@@ -60,6 +60,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
60
60
|
*/
|
|
61
61
|
constructor(runtimeRequirements) {
|
|
62
62
|
super("import chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
63
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
63
64
|
this._runtimeRequirements = runtimeRequirements;
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -33,6 +33,8 @@ const { registerNotSerializable } = require("../util/serialization");
|
|
|
33
33
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
34
34
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
35
35
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
36
|
+
/** @typedef {import("../Module").Sources} Sources */
|
|
37
|
+
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
36
38
|
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
|
|
37
39
|
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
|
38
40
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
@@ -225,7 +227,9 @@ class LazyCompilationProxyModule extends Module {
|
|
|
225
227
|
* @returns {CodeGenerationResult} result
|
|
226
228
|
*/
|
|
227
229
|
codeGeneration({ runtimeTemplate, chunkGraph, moduleGraph }) {
|
|
230
|
+
/** @type {Sources} */
|
|
228
231
|
const sources = new Map();
|
|
232
|
+
/** @type {RuntimeRequirements} */
|
|
229
233
|
const runtimeRequirements = new Set();
|
|
230
234
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
231
235
|
const clientDep = /** @type {CommonJsRequireDependency} */ (
|
|
@@ -247,6 +251,7 @@ class LazyCompilationProxyModule extends Module {
|
|
|
247
251
|
Boolean(block)
|
|
248
252
|
)}, module: module, onError: onError });`
|
|
249
253
|
]);
|
|
254
|
+
/** @type {string} */
|
|
250
255
|
let source;
|
|
251
256
|
if (block) {
|
|
252
257
|
const dep = block.dependencies[0];
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
/** @typedef {() => Server} CreateServerFunction */
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
|
|
22
|
+
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]> }} options additional options for the backend
|
|
23
23
|
* @returns {BackendHandler} backend
|
|
24
24
|
*/
|
|
25
25
|
module.exports = (options) => (compiler, callback) => {
|
|
26
26
|
const logger = compiler.getInfrastructureLogger("LazyCompilationBackend");
|
|
27
|
+
/** @type {Map<string, number>} */
|
|
27
28
|
const activeModules = new Map();
|
|
28
29
|
const prefix = "/lazy-compilation-using-";
|
|
29
30
|
|
|
@@ -152,7 +153,7 @@ module.exports = (options) => (compiler, callback) => {
|
|
|
152
153
|
const key = `${encodeURIComponent(
|
|
153
154
|
originalModule.identifier().replace(/\\/g, "/").replace(/@/g, "_")
|
|
154
155
|
).replace(/%(2F|3A|24|26|2B|2C|3B|3D)/g, decodeURIComponent)}`;
|
|
155
|
-
const active = activeModules.get(key) > 0;
|
|
156
|
+
const active = /** @type {number} */ (activeModules.get(key)) > 0;
|
|
156
157
|
return {
|
|
157
158
|
client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`,
|
|
158
159
|
data: key,
|
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
|
|
14
14
|
/** @typedef {import("../Compiler")} Compiler */
|
|
15
15
|
/** @typedef {import("../Module")} Module */
|
|
16
|
+
/** @typedef {import("../ChunkGraph").ModuleComparator} ModuleComparator */
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @typedef {object} ChunkModuleIdRangePluginOptions
|
|
@@ -56,6 +57,7 @@ class ChunkModuleIdRangePlugin {
|
|
|
56
57
|
/** @type {Module[]} */
|
|
57
58
|
let chunkModules;
|
|
58
59
|
if (options.order) {
|
|
60
|
+
/** @type {ModuleComparator} */
|
|
59
61
|
let cmpFn;
|
|
60
62
|
switch (options.order) {
|
|
61
63
|
case "index":
|
package/lib/ids/IdHelpers.js
CHANGED
|
@@ -13,14 +13,14 @@ const numberHash = require("../util/numberHash");
|
|
|
13
13
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
14
14
|
/** @typedef {import("../Compilation")} Compilation */
|
|
15
15
|
/** @typedef {import("../Module")} Module */
|
|
16
|
-
/** @typedef {
|
|
16
|
+
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
17
17
|
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
18
18
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @param {string} str string to hash
|
|
22
22
|
* @param {number} len max length of the hash
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
24
24
|
* @returns {string} hash
|
|
25
25
|
*/
|
|
26
26
|
const getHash = (str, len, hashFunction) => {
|
|
@@ -56,12 +56,12 @@ const avoidNumber = (str) => {
|
|
|
56
56
|
* @returns {string} id representation
|
|
57
57
|
*/
|
|
58
58
|
const requestToId = (request) =>
|
|
59
|
-
request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-
|
|
59
|
+
request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-z0-9_-])+/gi, "_");
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param {string} string the string
|
|
63
63
|
* @param {string} delimiter separator for string and hash
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
65
65
|
* @returns {string} string with limited max length to 100 chars
|
|
66
66
|
*/
|
|
67
67
|
const shortenLongString = (string, delimiter, hashFunction) => {
|
|
@@ -95,7 +95,7 @@ const getShortModuleName = (module, context, associatedObjectForCache) => {
|
|
|
95
95
|
* @param {string} shortName the short name
|
|
96
96
|
* @param {Module} module the module
|
|
97
97
|
* @param {string} context context directory
|
|
98
|
-
* @param {
|
|
98
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
99
99
|
* @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
|
|
100
100
|
* @returns {string} long module name
|
|
101
101
|
*/
|
|
@@ -124,7 +124,7 @@ const getFullModuleName = (module, context, associatedObjectForCache) =>
|
|
|
124
124
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
125
125
|
* @param {string} context context directory
|
|
126
126
|
* @param {string} delimiter delimiter for names
|
|
127
|
-
* @param {
|
|
127
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
128
128
|
* @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
|
|
129
129
|
* @returns {string} short chunk name
|
|
130
130
|
*/
|
|
@@ -152,7 +152,7 @@ const getShortChunkName = (
|
|
|
152
152
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
153
153
|
* @param {string} context context directory
|
|
154
154
|
* @param {string} delimiter delimiter for names
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
156
156
|
* @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
|
|
157
157
|
* @returns {string} short chunk name
|
|
158
158
|
*/
|
|
@@ -231,7 +231,7 @@ const addToMapOfItems = (map, key, value) => {
|
|
|
231
231
|
*/
|
|
232
232
|
const getUsedModuleIdsAndModules = (compilation, filter) => {
|
|
233
233
|
const chunkGraph = compilation.chunkGraph;
|
|
234
|
-
|
|
234
|
+
/** @type {Module[]} */
|
|
235
235
|
const modules = [];
|
|
236
236
|
|
|
237
237
|
/** @type {UsedModuleIds} */
|
|
@@ -402,6 +402,7 @@ const assignDeterministicIds = (
|
|
|
402
402
|
|
|
403
403
|
for (const item of items) {
|
|
404
404
|
const ident = getName(item);
|
|
405
|
+
/** @type {number} */
|
|
405
406
|
let id;
|
|
406
407
|
let i = salt;
|
|
407
408
|
do {
|
|
@@ -420,6 +421,7 @@ const assignAscendingModuleIds = (usedIds, modules, compilation) => {
|
|
|
420
421
|
const chunkGraph = compilation.chunkGraph;
|
|
421
422
|
|
|
422
423
|
let nextId = 0;
|
|
424
|
+
/** @type {(mod: Module) => void} */
|
|
423
425
|
let assignId;
|
|
424
426
|
if (usedIds.size > 0) {
|
|
425
427
|
/**
|