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
package/lib/util/semver.js
CHANGED
|
@@ -9,7 +9,7 @@ const memoize = require("./memoize");
|
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../serialization/BinaryMiddleware").MEASURE_END_OPERATION_TYPE} MEASURE_END_OPERATION */
|
|
11
11
|
/** @typedef {import("../serialization/BinaryMiddleware").MEASURE_START_OPERATION_TYPE} MEASURE_START_OPERATION */
|
|
12
|
-
/** @typedef {
|
|
12
|
+
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
|
13
13
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -111,7 +111,7 @@ module.exports = {
|
|
|
111
111
|
/**
|
|
112
112
|
* @template D, S, C
|
|
113
113
|
* @param {IntermediateFileSystem} fs filesystem
|
|
114
|
-
* @param {
|
|
114
|
+
* @param {HashFunction} hashFunction hash function to use
|
|
115
115
|
* @returns {Serializer<D, S, C>} file serializer
|
|
116
116
|
*/
|
|
117
117
|
createFileSerializer: (fs, hashFunction) => {
|
|
@@ -12,11 +12,15 @@ const Template = require("../Template");
|
|
|
12
12
|
/** @typedef {import("../Chunk")} Chunk */
|
|
13
13
|
/** @typedef {import("../Compilation")} Compilation */
|
|
14
14
|
|
|
15
|
+
/** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */
|
|
16
|
+
/** @typedef {(wasmModuleSrcPath: string) => string} GenerateLoadBinaryCode */
|
|
17
|
+
/** @typedef {() => string} GenerateBeforeInstantiateStreaming */
|
|
18
|
+
|
|
15
19
|
/**
|
|
16
20
|
* @typedef {object} AsyncWasmLoadingRuntimeModuleOptions
|
|
17
|
-
* @property {
|
|
18
|
-
* @property {
|
|
19
|
-
* @property {
|
|
21
|
+
* @property {GenerateLoadBinaryCode} generateLoadBinaryCode
|
|
22
|
+
* @property {GenerateBeforeLoadBinaryCode=} generateBeforeLoadBinaryCode
|
|
23
|
+
* @property {GenerateBeforeInstantiateStreaming=} generateBeforeInstantiateStreaming
|
|
20
24
|
* @property {boolean} supportsStreaming
|
|
21
25
|
*/
|
|
22
26
|
|
|
@@ -31,10 +35,14 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
31
35
|
supportsStreaming
|
|
32
36
|
}) {
|
|
33
37
|
super("wasm loading", RuntimeModule.STAGE_NORMAL);
|
|
38
|
+
/** @type {GenerateLoadBinaryCode} */
|
|
34
39
|
this.generateLoadBinaryCode = generateLoadBinaryCode;
|
|
40
|
+
/** @type {generateBeforeLoadBinaryCode | undefined} */
|
|
35
41
|
this.generateBeforeLoadBinaryCode = generateBeforeLoadBinaryCode;
|
|
42
|
+
/** @type {generateBeforeInstantiateStreaming | undefined} */
|
|
36
43
|
this.generateBeforeInstantiateStreaming =
|
|
37
44
|
generateBeforeInstantiateStreaming;
|
|
45
|
+
/** @type {boolean} */
|
|
38
46
|
this.supportsStreaming = supportsStreaming;
|
|
39
47
|
}
|
|
40
48
|
|
|
@@ -11,7 +11,7 @@ const Generator = require("../Generator");
|
|
|
11
11
|
const { tryRunOrWebpackError } = require("../HookWebpackError");
|
|
12
12
|
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
|
13
13
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
14
|
-
const {
|
|
14
|
+
const { compareModulesByFullName } = require("../util/comparators");
|
|
15
15
|
const memoize = require("../util/memoize");
|
|
16
16
|
|
|
17
17
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
@@ -89,6 +89,7 @@ class AsyncWebAssemblyModulesPlugin {
|
|
|
89
89
|
* @param {AsyncWebAssemblyModulesPluginOptions} options options
|
|
90
90
|
*/
|
|
91
91
|
constructor(options) {
|
|
92
|
+
/** @type {AsyncWebAssemblyModulesPluginOptions} */
|
|
92
93
|
this.options = options;
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -139,7 +140,7 @@ class AsyncWebAssemblyModulesPlugin {
|
|
|
139
140
|
|
|
140
141
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
|
141
142
|
chunk,
|
|
142
|
-
|
|
143
|
+
compareModulesByFullName(compiler)
|
|
143
144
|
)) {
|
|
144
145
|
if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
|
|
145
146
|
const filenameTemplate = outputOptions.webassemblyModuleFilename;
|
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|
const WebpackError = require("../WebpackError");
|
|
8
8
|
|
|
9
9
|
module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} message Error message
|
|
12
|
+
*/
|
|
11
13
|
constructor(message) {
|
|
12
14
|
super(message);
|
|
15
|
+
|
|
16
|
+
/** @type {string} */
|
|
13
17
|
this.name = "UnsupportedWebAssemblyFeatureError";
|
|
14
18
|
this.hideStack = true;
|
|
15
19
|
}
|
|
@@ -31,6 +31,7 @@ const WebAssemblyUtils = require("./WebAssemblyUtils");
|
|
|
31
31
|
*/
|
|
32
32
|
const getAllWasmModules = (moduleGraph, chunkGraph, chunk) => {
|
|
33
33
|
const wasmModules = chunk.getAllAsyncChunks();
|
|
34
|
+
/** @type {Module[]} */
|
|
34
35
|
const array = [];
|
|
35
36
|
for (const chunk of wasmModules) {
|
|
36
37
|
for (const m of chunkGraph.getOrderedChunkModulesIterable(
|
|
@@ -67,6 +68,7 @@ const generateImportObject = (
|
|
|
67
68
|
const moduleGraph = chunkGraph.moduleGraph;
|
|
68
69
|
/** @type {Map<string, ModuleId>} */
|
|
69
70
|
const waitForInstances = new Map();
|
|
71
|
+
/** @type {{ module: string, name: string, value: string }[]} */
|
|
70
72
|
const properties = [];
|
|
71
73
|
const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies(
|
|
72
74
|
moduleGraph,
|
|
@@ -136,6 +138,7 @@ const generateImportObject = (
|
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
/** @type {string[]} */
|
|
139
142
|
let importObject;
|
|
140
143
|
if (mangle) {
|
|
141
144
|
importObject = [
|
|
@@ -102,6 +102,8 @@ Add an async split point (i. e. import()) somewhere between your entrypoint and
|
|
|
102
102
|
${moduleChains.map((s) => `* ${s}`).join("\n")}`;
|
|
103
103
|
|
|
104
104
|
super(message);
|
|
105
|
+
|
|
106
|
+
/** @type {string} */
|
|
105
107
|
this.name = "WebAssemblyInInitialChunkError";
|
|
106
108
|
this.hideStack = true;
|
|
107
109
|
this.module = module;
|
|
@@ -60,17 +60,21 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
60
60
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
61
61
|
|
|
62
62
|
let needExportsCopy = false;
|
|
63
|
+
/** @typedef {{ dependency: ModuleDependency | undefined, importVar: string, index: number, request: string | undefined, names: Set<string>, reexports: string[] }} ImportData */
|
|
64
|
+
/** @type {Map<Module, ImportData>} */
|
|
63
65
|
const importedModules = new Map();
|
|
66
|
+
/** @type {string[]} */
|
|
64
67
|
const initParams = [];
|
|
65
68
|
let index = 0;
|
|
66
69
|
for (const dep of module.dependencies) {
|
|
67
70
|
const moduleDep =
|
|
68
71
|
dep && dep instanceof ModuleDependency ? dep : undefined;
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
const mod = moduleGraph.getModule(dep);
|
|
73
|
+
if (mod) {
|
|
74
|
+
let importData = importedModules.get(mod);
|
|
71
75
|
if (importData === undefined) {
|
|
72
76
|
importedModules.set(
|
|
73
|
-
|
|
77
|
+
mod,
|
|
74
78
|
(importData = {
|
|
75
79
|
dependency: moduleDep,
|
|
76
80
|
importVar: `m${index}`,
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
|
|
14
14
|
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
|
|
15
15
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
16
|
-
const {
|
|
16
|
+
const { compareModulesByFullName } = require("../util/comparators");
|
|
17
17
|
const memoize = require("../util/memoize");
|
|
18
18
|
const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
|
|
19
19
|
|
|
@@ -89,7 +89,7 @@ class WebAssemblyModulesPlugin {
|
|
|
89
89
|
|
|
90
90
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
|
91
91
|
chunk,
|
|
92
|
-
|
|
92
|
+
compareModulesByFullName(compiler)
|
|
93
93
|
)) {
|
|
94
94
|
if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
|
|
95
95
|
const filenameTemplate = outputOptions.webassemblyModuleFilename;
|
|
@@ -92,7 +92,8 @@ class WebAssemblyParser extends Parser {
|
|
|
92
92
|
/** @type {Record<string, string> | undefined} */
|
|
93
93
|
let jsIncompatibleExports = (buildMeta.jsIncompatibleExports = undefined);
|
|
94
94
|
|
|
95
|
-
/** @
|
|
95
|
+
/** @typedef {ModuleImport | null} ImportNode */
|
|
96
|
+
/** @type {ImportNode[]} */
|
|
96
97
|
const importedGlobals = [];
|
|
97
98
|
|
|
98
99
|
t.traverse(module, {
|
|
@@ -139,6 +140,7 @@ class WebAssemblyParser extends Parser {
|
|
|
139
140
|
Global({ node }) {
|
|
140
141
|
const init = node.init[0];
|
|
141
142
|
|
|
143
|
+
/** @type {ImportNode} */
|
|
142
144
|
let importNode = null;
|
|
143
145
|
|
|
144
146
|
if (init.id === "get_global") {
|
|
@@ -56,6 +56,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
56
56
|
*/
|
|
57
57
|
constructor(runtimeRequirements) {
|
|
58
58
|
super("jsonp chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
59
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
59
60
|
this._runtimeRequirements = runtimeRequirements;
|
|
60
61
|
}
|
|
61
62
|
|
package/lib/webpack.js
CHANGED
|
@@ -15,13 +15,17 @@ const {
|
|
|
15
15
|
applyWebpackOptionsBaseDefaults,
|
|
16
16
|
applyWebpackOptionsDefaults
|
|
17
17
|
} = require("./config/defaults");
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
applyWebpackOptionsInterception,
|
|
20
|
+
getNormalizedWebpackOptions
|
|
21
|
+
} = require("./config/normalization");
|
|
19
22
|
const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
|
|
20
23
|
const memoize = require("./util/memoize");
|
|
21
24
|
|
|
22
25
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
|
23
26
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
|
24
27
|
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptionsNormalizedWithDefaults */
|
|
28
|
+
/** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */
|
|
25
29
|
/** @typedef {import("./Compiler").WatchOptions} WatchOptions */
|
|
26
30
|
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
|
|
27
31
|
/** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiWebpackOptions */
|
|
@@ -68,8 +72,13 @@ const createMultiCompiler = (childOptions, options) => {
|
|
|
68
72
|
* @returns {Compiler} a compiler
|
|
69
73
|
*/
|
|
70
74
|
const createCompiler = (rawOptions, compilerIndex) => {
|
|
71
|
-
|
|
75
|
+
let options = getNormalizedWebpackOptions(rawOptions);
|
|
72
76
|
applyWebpackOptionsBaseDefaults(options);
|
|
77
|
+
|
|
78
|
+
/** @type {WebpackOptionsInterception=} */
|
|
79
|
+
let interception;
|
|
80
|
+
({ options, interception } = applyWebpackOptionsInterception(options));
|
|
81
|
+
|
|
73
82
|
const compiler = new Compiler(
|
|
74
83
|
/** @type {string} */ (options.context),
|
|
75
84
|
options
|
|
@@ -99,7 +108,8 @@ const createCompiler = (rawOptions, compilerIndex) => {
|
|
|
99
108
|
new WebpackOptionsApply().process(
|
|
100
109
|
/** @type {WebpackOptionsNormalizedWithDefaults} */
|
|
101
110
|
(options),
|
|
102
|
-
compiler
|
|
111
|
+
compiler,
|
|
112
|
+
interception
|
|
103
113
|
);
|
|
104
114
|
compiler.hooks.initialize.call();
|
|
105
115
|
return compiler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.105.0",
|
|
4
4
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
|
5
5
|
"homepage": "https://github.com/webpack/webpack",
|
|
6
6
|
"bugs": "https://github.com/webpack/webpack/issues",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"lint:types-module-test": "tsc -p tsconfig.module.test.json",
|
|
43
43
|
"lint:yarn": "yarn-deduplicate --fail --list -s highest yarn.lock",
|
|
44
44
|
"lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
|
|
45
|
-
"report:types": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
|
|
46
45
|
"validate:types": "tsc -p tsconfig.validation.json",
|
|
47
46
|
"fmt": "yarn fmt:base --log-level warn --write",
|
|
48
47
|
"fmt:check": "yarn fmt:base --check",
|
|
@@ -55,25 +54,26 @@
|
|
|
55
54
|
"benchmark": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
|
|
56
55
|
"pretest": "yarn lint",
|
|
57
56
|
"test": "yarn test:base",
|
|
58
|
-
"test:
|
|
57
|
+
"test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
|
|
59
58
|
"test:basic": "yarn test:base --testMatch \"<rootDir>/test/*.basictest.js\"",
|
|
60
59
|
"test:basic:deno": "yarn test:base:deno --testMatch \"<rootDir>/test/*.basictest.js\"",
|
|
61
60
|
"test:unit": "yarn test:base --testMatch \"<rootDir>/test/*.unittest.js\"",
|
|
62
61
|
"test:integration": "yarn test:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
|
|
63
62
|
"test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --logHeapUsage",
|
|
64
|
-
"test:
|
|
65
|
-
"cover": "
|
|
66
|
-
"cover:clean": "rimraf .nyc_output coverage",
|
|
63
|
+
"test:update-snapshots": "yarn test:base -u",
|
|
64
|
+
"report:cover": "nyc report --reporter=lcov --reporter=text -t coverage",
|
|
65
|
+
"report:cover:clean": "rimraf .nyc_output coverage",
|
|
66
|
+
"report:cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
|
|
67
|
+
"types:cover": "node node_modules/tooling/type-coverage",
|
|
68
|
+
"types:cover:report": "rimraf coverage && yarn types:cover && yarn report:cover && open-cli coverage/lcov-report/index.html",
|
|
69
|
+
"cover": "yarn cover:all && yarn report:cover",
|
|
70
|
+
"cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage",
|
|
67
71
|
"cover:all": "yarn cover:base --coverage",
|
|
68
72
|
"cover:unit": "yarn cover:base --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
|
|
69
73
|
"cover:basic": "yarn cover:base --testMatch \"<rootDir>/test/*.basictest.js\" --coverage",
|
|
70
74
|
"cover:integration": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" --coverage",
|
|
71
75
|
"cover:integration:a": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage",
|
|
72
|
-
"cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage"
|
|
73
|
-
"cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage",
|
|
74
|
-
"cover:types": "node node_modules/tooling/type-coverage",
|
|
75
|
-
"cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
|
|
76
|
-
"cover:report": "nyc report --reporter=lcov --reporter=text -t coverage"
|
|
76
|
+
"cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage"
|
|
77
77
|
},
|
|
78
78
|
"lint-staged": {
|
|
79
79
|
"*.{js,cjs,mjs}": [
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"acorn-import-phases": "^1.0.3",
|
|
96
96
|
"browserslist": "^4.28.1",
|
|
97
97
|
"chrome-trace-event": "^1.0.2",
|
|
98
|
-
"enhanced-resolve": "^5.
|
|
98
|
+
"enhanced-resolve": "^5.19.0",
|
|
99
99
|
"es-module-lexer": "^2.0.0",
|
|
100
100
|
"eslint-scope": "5.1.1",
|
|
101
101
|
"events": "^3.2.0",
|
|
@@ -108,22 +108,21 @@
|
|
|
108
108
|
"schema-utils": "^4.3.3",
|
|
109
109
|
"tapable": "^2.3.0",
|
|
110
110
|
"terser-webpack-plugin": "^5.3.16",
|
|
111
|
-
"watchpack": "^2.
|
|
111
|
+
"watchpack": "^2.5.1",
|
|
112
112
|
"webpack-sources": "^3.3.3"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@babel/core": "^7.27.1",
|
|
116
116
|
"@babel/preset-react": "^7.27.1",
|
|
117
117
|
"@changesets/cli": "^2.29.8",
|
|
118
|
+
"@changesets/get-github-info": "^0.7.0",
|
|
118
119
|
"@codspeed/core": "^5.0.1",
|
|
119
|
-
"@eslint/js": "^9.39.0",
|
|
120
|
-
"@eslint/markdown": "^7.4.0",
|
|
121
|
-
"@stylistic/eslint-plugin": "^5.6.0",
|
|
122
120
|
"@types/glob-to-regexp": "^0.4.4",
|
|
123
121
|
"@types/graceful-fs": "^4.1.9",
|
|
124
122
|
"@types/jest": "^30.0.0",
|
|
125
123
|
"@types/mime-types": "^2.1.4",
|
|
126
|
-
"@types/
|
|
124
|
+
"@types/neo-async": "^2.6.7",
|
|
125
|
+
"@types/node": "^25.1.0",
|
|
127
126
|
"@types/xxhashjs": "^0.2.4",
|
|
128
127
|
"assemblyscript": "^0.28.9",
|
|
129
128
|
"babel-loader": "^10.0.0",
|
|
@@ -137,17 +136,10 @@
|
|
|
137
136
|
"es5-ext": "^0.10.53",
|
|
138
137
|
"es6-promise-polyfill": "^1.2.0",
|
|
139
138
|
"eslint": "^9.39.2",
|
|
140
|
-
"eslint-config-
|
|
141
|
-
"eslint-config-webpack": "^4.7.3",
|
|
142
|
-
"eslint-plugin-import": "^2.32.0",
|
|
143
|
-
"eslint-plugin-jest": "^29.5.0",
|
|
144
|
-
"eslint-plugin-jsdoc": "^61.5.0",
|
|
145
|
-
"eslint-plugin-n": "^17.23.1",
|
|
146
|
-
"eslint-plugin-prettier": "^5.5.0",
|
|
147
|
-
"eslint-plugin-unicorn": "^62.0.0",
|
|
139
|
+
"eslint-config-webpack": "^4.9.1",
|
|
148
140
|
"file-loader": "^6.0.0",
|
|
149
141
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
150
|
-
"globals": "^
|
|
142
|
+
"globals": "^17.0.0",
|
|
151
143
|
"hash-wasm": "^4.9.0",
|
|
152
144
|
"husky": "^9.0.11",
|
|
153
145
|
"istanbul": "^0.4.5",
|
|
@@ -187,9 +179,9 @@
|
|
|
187
179
|
"style-loader": "^4.0.0",
|
|
188
180
|
"terser": "^5.43.1",
|
|
189
181
|
"three": "^0.182.0",
|
|
190
|
-
"tinybench": "^
|
|
182
|
+
"tinybench": "^6.0.0",
|
|
191
183
|
"toml": "^3.0.0",
|
|
192
|
-
"tooling": "webpack/tooling#v1.24.
|
|
184
|
+
"tooling": "webpack/tooling#v1.24.4",
|
|
193
185
|
"ts-loader": "^9.5.4",
|
|
194
186
|
"typescript": "^5.9.3",
|
|
195
187
|
"url-loader": "^4.1.0",
|