webpack 5.97.1 → 5.99.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/README.md +345 -392
- package/lib/AsyncDependenciesBlock.js +3 -1
- package/lib/BannerPlugin.js +1 -1
- package/lib/Cache.js +9 -7
- package/lib/CacheFacade.js +5 -5
- package/lib/Chunk.js +2 -2
- package/lib/ChunkGraph.js +21 -16
- package/lib/ChunkTemplate.js +6 -6
- package/lib/CleanPlugin.js +10 -10
- package/lib/CodeGenerationResults.js +4 -3
- package/lib/CompatibilityPlugin.js +4 -1
- package/lib/Compilation.js +343 -167
- package/lib/Compiler.js +13 -18
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +4 -2
- package/lib/ContextModuleFactory.js +3 -3
- package/lib/ContextReplacementPlugin.js +43 -16
- package/lib/DefinePlugin.js +25 -24
- package/lib/DelegatedModule.js +4 -2
- package/lib/DelegatedModuleFactoryPlugin.js +2 -1
- package/lib/Dependency.js +19 -13
- package/lib/DependencyTemplates.js +4 -3
- package/lib/DllModule.js +4 -2
- package/lib/DllModuleFactory.js +2 -2
- package/lib/DllReferencePlugin.js +2 -1
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/ExportsInfo.js +72 -40
- package/lib/ExternalModule.js +14 -5
- package/lib/ExternalModuleFactoryPlugin.js +24 -12
- package/lib/FileSystemInfo.js +129 -94
- package/lib/FlagDependencyExportsPlugin.js +6 -4
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +29 -1
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +3 -9
- package/lib/IgnoreErrorModuleFactory.js +2 -2
- package/lib/IgnorePlugin.js +0 -5
- package/lib/InitFragment.js +1 -1
- package/lib/LoaderOptionsPlugin.js +8 -5
- package/lib/MainTemplate.js +7 -7
- package/lib/Module.js +44 -21
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +4 -3
- package/lib/ModuleDependencyWarning.js +4 -3
- package/lib/ModuleFactory.js +9 -3
- package/lib/ModuleFilenameHelpers.js +21 -39
- package/lib/ModuleGraph.js +20 -14
- package/lib/ModuleGraphConnection.js +7 -13
- package/lib/ModuleNotFoundError.js +1 -1
- package/lib/ModuleParseError.js +2 -1
- package/lib/ModuleSourceTypesConstants.js +11 -0
- package/lib/ModuleTemplate.js +5 -5
- package/lib/ModuleTypeConstants.js +15 -0
- package/lib/MultiCompiler.js +4 -4
- package/lib/MultiStats.js +1 -1
- package/lib/NormalModule.js +101 -54
- package/lib/NormalModuleFactory.js +38 -33
- package/lib/NormalModuleReplacementPlugin.js +3 -2
- package/lib/NullFactory.js +2 -2
- package/lib/Parser.js +4 -3
- package/lib/ProgressPlugin.js +1 -2
- package/lib/RawModule.js +4 -2
- package/lib/RecordIdsPlugin.js +6 -2
- package/lib/RequestShortener.js +3 -1
- package/lib/ResolverFactory.js +12 -9
- package/lib/RuntimeModule.js +4 -2
- package/lib/RuntimeTemplate.js +2 -1
- package/lib/SelfModuleFactory.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +0 -8
- package/lib/Template.js +6 -5
- package/lib/TemplatedPathPlugin.js +15 -12
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +237 -170
- package/lib/asset/AssetModulesPlugin.js +52 -10
- package/lib/asset/AssetSourceGenerator.js +18 -0
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/buildChunkGraph.js +14 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +137 -121
- package/lib/cache/ResolverCachePlugin.js +15 -7
- package/lib/cache/getLazyHashedEtag.js +4 -3
- package/lib/cli.js +23 -15
- package/lib/config/defaults.js +104 -28
- package/lib/config/normalization.js +14 -13
- package/lib/config/target.js +8 -8
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerEntryModuleFactory.js +2 -2
- package/lib/container/FallbackModule.js +4 -2
- package/lib/container/FallbackModuleFactory.js +2 -2
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/options.js +5 -5
- package/lib/css/CssGenerator.js +71 -9
- package/lib/css/CssLoadingRuntimeModule.js +5 -2
- package/lib/css/CssModulesPlugin.js +41 -9
- package/lib/css/CssParser.js +37 -17
- package/lib/css/walkCssTokens.js +17 -17
- package/lib/debug/ProfilingPlugin.js +98 -38
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
- package/lib/dependencies/AMDPlugin.js +5 -2
- package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
- package/lib/dependencies/AMDRequireContextDependency.js +2 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
- package/lib/dependencies/AMDRuntimeModules.js +3 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsImportsParserPlugin.js +38 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +13 -6
- package/lib/dependencies/CssIcssExportDependency.js +15 -12
- package/lib/dependencies/CssIcssImportDependency.js +4 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +18 -15
- package/lib/dependencies/ExportsInfoDependency.js +6 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +8 -6
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
- package/lib/dependencies/ImportContextDependency.js +2 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
- package/lib/dependencies/JsonExportsDependency.js +49 -27
- package/lib/dependencies/LoaderPlugin.js +4 -14
- package/lib/dependencies/RequireContextDependency.js +2 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
- package/lib/dependencies/RequireResolveContextDependency.js +1 -1
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
- package/lib/dependencies/WorkerDependency.js +6 -3
- package/lib/dependencies/WorkerPlugin.js +100 -41
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +3 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +32 -24
- package/lib/hmr/lazyCompilationBackend.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/ids/IdHelpers.js +15 -14
- package/lib/ids/SyncModuleIdsPlugin.js +9 -5
- package/lib/index.js +5 -5
- package/lib/javascript/BasicEvaluatedExpression.js +6 -6
- package/lib/javascript/JavascriptGenerator.js +11 -1
- package/lib/javascript/JavascriptModulesPlugin.js +54 -34
- package/lib/javascript/JavascriptParser.js +272 -188
- package/lib/javascript/JavascriptParserHelpers.js +10 -9
- package/lib/javascript/StartupHelpers.js +4 -1
- package/lib/json/JsonData.js +4 -4
- package/lib/json/JsonGenerator.js +54 -22
- package/lib/json/JsonModulesPlugin.js +16 -3
- package/lib/json/JsonParser.js +10 -4
- package/lib/library/AbstractLibraryPlugin.js +7 -3
- package/lib/library/AssignLibraryPlugin.js +29 -1
- package/lib/library/EnableLibraryPlugin.js +7 -10
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +121 -15
- package/lib/logging/Logger.js +2 -2
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/node/NodeEnvironmentPlugin.js +6 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
- package/lib/node/nodeConsole.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +19 -12
- package/lib/optimize/InnerGraph.js +3 -2
- package/lib/optimize/InnerGraphPlugin.js +13 -7
- package/lib/optimize/LimitChunkCountPlugin.js +20 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
- package/lib/optimize/RealContentHashPlugin.js +8 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
- package/lib/optimize/SplitChunksPlugin.js +90 -65
- package/lib/rules/BasicEffectRulePlugin.js +9 -1
- package/lib/rules/BasicMatcherRulePlugin.js +15 -4
- package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
- package/lib/rules/RuleSetCompiler.js +25 -14
- package/lib/rules/UseEffectRulePlugin.js +47 -17
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
- package/lib/schemes/HttpUriPlugin.js +38 -17
- package/lib/serialization/BinaryMiddleware.js +52 -19
- package/lib/serialization/FileMiddleware.js +78 -48
- package/lib/serialization/ObjectMiddleware.js +78 -29
- package/lib/serialization/PlainObjectSerializer.js +1 -1
- package/lib/serialization/Serializer.js +15 -10
- package/lib/serialization/SerializerMiddleware.js +80 -41
- package/lib/serialization/SingleItemMiddleware.js +10 -7
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
- package/lib/sharing/utils.js +2 -2
- package/lib/stats/DefaultStatsFactoryPlugin.js +81 -79
- package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
- package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
- package/lib/stats/StatsFactory.js +11 -11
- package/lib/stats/StatsPrinter.js +7 -7
- package/lib/util/ArrayHelpers.js +2 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +41 -23
- package/lib/util/LazySet.js +3 -2
- package/lib/util/MapHelpers.js +1 -1
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Semaphore.js +3 -3
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/SortableSet.js +9 -7
- package/lib/util/TupleQueue.js +9 -8
- package/lib/util/TupleSet.js +2 -2
- package/lib/util/WeakTupleMap.js +12 -11
- package/lib/util/binarySearchBounds.js +2 -1
- package/lib/util/cleverMerge.js +84 -54
- package/lib/util/comparators.js +22 -21
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +6 -4
- package/lib/util/create-schema-validation.js +4 -4
- package/lib/util/createHash.js +2 -2
- package/lib/util/deprecation.js +35 -33
- package/lib/util/deterministicGrouping.js +6 -6
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +39 -39
- package/lib/util/hash/wasm-hash.js +2 -2
- package/lib/util/identifier.js +15 -18
- package/lib/util/makeSerializable.js +1 -1
- package/lib/util/memoize.js +4 -1
- package/lib/util/objectToMap.js +3 -2
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +0 -1
- package/lib/util/registerExternalSerializer.js +15 -18
- package/lib/util/removeBOM.js +25 -0
- package/lib/util/runtime.js +34 -27
- package/lib/util/semver.js +18 -8
- package/lib/util/serialization.js +5 -16
- package/lib/util/smartGrouping.js +3 -3
- package/lib/validateSchema.js +4 -7
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
- package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +9 -4
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -2
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
- package/package.json +27 -26
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +48 -13
- package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
- package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
- package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
- package/schemas/plugins/JsonModulesPluginParser.check.js +1 -1
- package/schemas/plugins/JsonModulesPluginParser.json +4 -0
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/types.d.ts +888 -583
- package/lib/library/ModernModuleLibraryPlugin.js +0 -144
@@ -30,6 +30,8 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
|
|
30
30
|
/** @typedef {import("@webassemblyjs/ast").ModuleImport} ModuleImport */
|
31
31
|
/** @typedef {import("@webassemblyjs/ast").ModuleExport} ModuleExport */
|
32
32
|
/** @typedef {import("@webassemblyjs/ast").Global} Global */
|
33
|
+
/** @typedef {import("@webassemblyjs/ast").AST} AST */
|
34
|
+
/** @typedef {import("@webassemblyjs/ast").GlobalType} GlobalType */
|
33
35
|
/**
|
34
36
|
* @template T
|
35
37
|
* @typedef {import("@webassemblyjs/ast").NodePath<T>} NodePath
|
@@ -42,7 +44,7 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
|
|
42
44
|
/**
|
43
45
|
* @template T
|
44
46
|
* @param {((prev: ArrayBuffer) => ArrayBuffer)[]} fns transforms
|
45
|
-
* @returns {
|
47
|
+
* @returns {ArrayBufferTransform} composed transform
|
46
48
|
*/
|
47
49
|
const compose = (...fns) =>
|
48
50
|
fns.reduce(
|
@@ -53,7 +55,7 @@ const compose = (...fns) =>
|
|
53
55
|
/**
|
54
56
|
* Removes the start instruction
|
55
57
|
* @param {object} state state
|
56
|
-
* @param {
|
58
|
+
* @param {AST} state.ast Module's ast
|
57
59
|
* @returns {ArrayBufferTransform} transform
|
58
60
|
*/
|
59
61
|
const removeStartFunc = state => bin =>
|
@@ -65,7 +67,7 @@ const removeStartFunc = state => bin =>
|
|
65
67
|
|
66
68
|
/**
|
67
69
|
* Get imported globals
|
68
|
-
* @param {
|
70
|
+
* @param {AST} ast Module's AST
|
69
71
|
* @returns {t.ModuleImport[]} - nodes
|
70
72
|
*/
|
71
73
|
const getImportedGlobals = ast => {
|
@@ -85,7 +87,7 @@ const getImportedGlobals = ast => {
|
|
85
87
|
|
86
88
|
/**
|
87
89
|
* Get the count for imported func
|
88
|
-
* @param {
|
90
|
+
* @param {AST} ast Module's AST
|
89
91
|
* @returns {number} - count
|
90
92
|
*/
|
91
93
|
const getCountImportedFunc = ast => {
|
@@ -104,7 +106,7 @@ const getCountImportedFunc = ast => {
|
|
104
106
|
|
105
107
|
/**
|
106
108
|
* Get next type index
|
107
|
-
* @param {
|
109
|
+
* @param {AST} ast Module's AST
|
108
110
|
* @returns {t.Index} - index
|
109
111
|
*/
|
110
112
|
const getNextTypeIndex = ast => {
|
@@ -122,7 +124,7 @@ const getNextTypeIndex = ast => {
|
|
122
124
|
* The Func section metadata provide information for implemented funcs
|
123
125
|
* in order to have the correct index we shift the index by number of external
|
124
126
|
* functions.
|
125
|
-
* @param {
|
127
|
+
* @param {AST} ast Module's AST
|
126
128
|
* @param {number} countImportedFunc number of imported funcs
|
127
129
|
* @returns {t.Index} - index
|
128
130
|
*/
|
@@ -168,7 +170,7 @@ const createDefaultInitForGlobal = globalType => {
|
|
168
170
|
*
|
169
171
|
* Note that globals will become mutable.
|
170
172
|
* @param {object} state transformation state
|
171
|
-
* @param {
|
173
|
+
* @param {AST} state.ast Module's ast
|
172
174
|
* @param {t.Instruction[]} state.additionalInitCode list of addition instructions for the init function
|
173
175
|
* @returns {ArrayBufferTransform} transform
|
174
176
|
*/
|
@@ -180,7 +182,9 @@ const rewriteImportedGlobals = state => bin => {
|
|
180
182
|
bin = editWithAST(state.ast, bin, {
|
181
183
|
ModuleImport(path) {
|
182
184
|
if (t.isGlobalType(path.node.descr)) {
|
183
|
-
const globalType =
|
185
|
+
const globalType =
|
186
|
+
/** @type {GlobalType} */
|
187
|
+
(path.node.descr);
|
184
188
|
|
185
189
|
globalType.mutability = "var";
|
186
190
|
|
@@ -238,7 +242,7 @@ const rewriteImportedGlobals = state => bin => {
|
|
238
242
|
/**
|
239
243
|
* Rewrite the export names
|
240
244
|
* @param {object} state state
|
241
|
-
* @param {
|
245
|
+
* @param {AST} state.ast Module's ast
|
242
246
|
* @param {Module} state.module Module
|
243
247
|
* @param {ModuleGraph} state.moduleGraph module graph
|
244
248
|
* @param {Set<string>} state.externalExports Module
|
@@ -272,7 +276,7 @@ const rewriteExportNames =
|
|
272
276
|
/**
|
273
277
|
* Mangle import names and modules
|
274
278
|
* @param {object} state state
|
275
|
-
* @param {
|
279
|
+
* @param {AST} state.ast Module's ast
|
276
280
|
* @param {Map<string, UsedWasmDependency>} state.usedDependencyMap mappings to mangle names
|
277
281
|
* @returns {ArrayBufferTransform} transform
|
278
282
|
*/
|
@@ -300,7 +304,7 @@ const rewriteImports =
|
|
300
304
|
*
|
301
305
|
* The init function fills the globals given input arguments.
|
302
306
|
* @param {object} state transformation state
|
303
|
-
* @param {
|
307
|
+
* @param {AST} state.ast Module's ast
|
304
308
|
* @param {t.Identifier} state.initFuncId identifier of the init function
|
305
309
|
* @param {t.Index} state.startAtFuncOffset index of the start function
|
306
310
|
* @param {t.ModuleImport[]} state.importedGlobals list of imported globals
|
@@ -442,7 +446,9 @@ class WebAssemblyGenerator extends Generator {
|
|
442
446
|
* @returns {Source | null} generated code
|
443
447
|
*/
|
444
448
|
generate(module, { moduleGraph, runtime }) {
|
445
|
-
const bin =
|
449
|
+
const bin =
|
450
|
+
/** @type {Buffer} */
|
451
|
+
(/** @type {Source} */ (module.originalSource()).source());
|
446
452
|
|
447
453
|
const initFuncId = t.identifier("");
|
448
454
|
|
@@ -515,6 +521,16 @@ class WebAssemblyGenerator extends Generator {
|
|
515
521
|
|
516
522
|
return new RawSource(newBuf);
|
517
523
|
}
|
524
|
+
|
525
|
+
/**
|
526
|
+
* @param {Error} error the error
|
527
|
+
* @param {NormalModule} module module for which the code should be generated
|
528
|
+
* @param {GenerateContext} generateContext context for generate
|
529
|
+
* @returns {Source | null} generated code
|
530
|
+
*/
|
531
|
+
generateError(error, module, generateContext) {
|
532
|
+
return new RawSource(error.message);
|
533
|
+
}
|
518
534
|
}
|
519
535
|
|
520
536
|
module.exports = WebAssemblyGenerator;
|
@@ -212,6 +212,16 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
212
212
|
);
|
213
213
|
return InitFragment.addToSource(source, initFragments, generateContext);
|
214
214
|
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
* @param {Error} error the error
|
218
|
+
* @param {NormalModule} module module for which the code should be generated
|
219
|
+
* @param {GenerateContext} generateContext context for generate
|
220
|
+
* @returns {Source | null} generated code
|
221
|
+
*/
|
222
|
+
generateError(error, module, generateContext) {
|
223
|
+
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
|
224
|
+
}
|
215
225
|
}
|
216
226
|
|
217
227
|
module.exports = WebAssemblyJavascriptGenerator;
|
@@ -9,7 +9,7 @@ const Generator = require("../Generator");
|
|
9
9
|
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
|
10
10
|
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
|
11
11
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
12
|
-
const {
|
12
|
+
const { compareModulesByIdOrIdentifier } = require("../util/comparators");
|
13
13
|
const memoize = require("../util/memoize");
|
14
14
|
const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
|
15
15
|
|
@@ -89,7 +89,7 @@ class WebAssemblyModulesPlugin {
|
|
89
89
|
|
90
90
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
91
91
|
chunk,
|
92
|
-
|
92
|
+
compareModulesByIdOrIdentifier(chunkGraph)
|
93
93
|
)) {
|
94
94
|
if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
|
95
95
|
const filenameTemplate =
|
@@ -13,6 +13,8 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency
|
|
13
13
|
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
|
14
14
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
15
15
|
|
16
|
+
/** @typedef {import("@webassemblyjs/ast").ModuleImport} ModuleImport */
|
17
|
+
/** @typedef {import("@webassemblyjs/ast").NumberLiteral} NumberLiteral */
|
16
18
|
/** @typedef {import("../Module")} Module */
|
17
19
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
18
20
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
@@ -101,8 +103,9 @@ class WebAssemblyParser extends Parser {
|
|
101
103
|
/** @type {Record<string, string> | undefined} */
|
102
104
|
let jsIncompatibleExports = (buildMeta.jsIncompatibleExports = undefined);
|
103
105
|
|
104
|
-
/** @type {
|
106
|
+
/** @type {(ModuleImport | null)[]} */
|
105
107
|
const importedGlobals = [];
|
108
|
+
|
106
109
|
t.traverse(module, {
|
107
110
|
ModuleExport({ node }) {
|
108
111
|
const descriptor = node.descr;
|
@@ -130,13 +133,14 @@ class WebAssemblyParser extends Parser {
|
|
130
133
|
|
131
134
|
if (node.descr && node.descr.exportType === "Global") {
|
132
135
|
const refNode =
|
133
|
-
importedGlobals[/** @type {
|
136
|
+
importedGlobals[/** @type {NumberLiteral} */ (node.descr.id).value];
|
134
137
|
if (refNode) {
|
135
138
|
const dep = new WebAssemblyExportImportedDependency(
|
136
139
|
node.name,
|
137
140
|
refNode.module,
|
138
141
|
refNode.name,
|
139
|
-
|
142
|
+
/** @type {string} */
|
143
|
+
(refNode.descr.valtype)
|
140
144
|
);
|
141
145
|
|
142
146
|
state.module.addDependency(dep);
|
@@ -170,7 +174,8 @@ class WebAssemblyParser extends Parser {
|
|
170
174
|
onlyDirectImport = "Table";
|
171
175
|
} else if (t.isFuncImportDescr(node.descr) === true) {
|
172
176
|
const incompatibleType = getJsIncompatibleType(
|
173
|
-
/** @type {t.Signature} */
|
177
|
+
/** @type {t.Signature} */
|
178
|
+
(node.descr.signature)
|
174
179
|
);
|
175
180
|
if (incompatibleType) {
|
176
181
|
onlyDirectImport = `Non-JS-compatible Func Signature (${incompatibleType})`;
|
@@ -80,7 +80,8 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
80
80
|
chunkLoadingGlobal,
|
81
81
|
hotUpdateGlobal,
|
82
82
|
crossOriginLoading,
|
83
|
-
scriptType
|
83
|
+
scriptType,
|
84
|
+
charset
|
84
85
|
}
|
85
86
|
} = compilation;
|
86
87
|
const globalObject = runtimeTemplate.globalObject;
|
@@ -229,6 +230,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
229
230
|
linkPrefetch.call(
|
230
231
|
Template.asString([
|
231
232
|
"var link = document.createElement('link');",
|
233
|
+
charset ? "link.charset = 'utf-8';" : "",
|
232
234
|
crossOriginLoading
|
233
235
|
? `link.crossOrigin = ${JSON.stringify(
|
234
236
|
crossOriginLoading
|
@@ -268,7 +270,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
268
270
|
scriptType && scriptType !== "module"
|
269
271
|
? `link.type = ${JSON.stringify(scriptType)};`
|
270
272
|
: "",
|
271
|
-
"link.charset = 'utf-8';",
|
273
|
+
charset ? "link.charset = 'utf-8';" : "",
|
272
274
|
`if (${RuntimeGlobals.scriptNonce}) {`,
|
273
275
|
Template.indent(
|
274
276
|
`link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
|
@@ -73,6 +73,9 @@ class ImportScriptsChunkLoadingPlugin {
|
|
73
73
|
compilation.hooks.runtimeRequirementInTree
|
74
74
|
.for(RuntimeGlobals.baseURI)
|
75
75
|
.tap("ImportScriptsChunkLoadingPlugin", handler);
|
76
|
+
compilation.hooks.runtimeRequirementInTree
|
77
|
+
.for(RuntimeGlobals.onChunksLoaded)
|
78
|
+
.tap("ImportScriptsChunkLoadingPlugin", handler);
|
76
79
|
|
77
80
|
compilation.hooks.runtimeRequirementInTree
|
78
81
|
.for(RuntimeGlobals.ensureChunkHandlers)
|
@@ -69,6 +69,9 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
69
69
|
const withLoading = this.runtimeRequirements.has(
|
70
70
|
RuntimeGlobals.ensureChunkHandlers
|
71
71
|
);
|
72
|
+
const withCallback = this.runtimeRequirements.has(
|
73
|
+
RuntimeGlobals.chunkCallback
|
74
|
+
);
|
72
75
|
const withHmr = this.runtimeRequirements.has(
|
73
76
|
RuntimeGlobals.hmrDownloadUpdateHandlers
|
74
77
|
);
|
@@ -107,7 +110,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
107
110
|
),
|
108
111
|
"};",
|
109
112
|
"",
|
110
|
-
withLoading
|
113
|
+
withCallback || withLoading
|
111
114
|
? Template.asString([
|
112
115
|
"// importScripts chunk loading",
|
113
116
|
`var installChunk = ${runtimeTemplate.basicFunction("data", [
|
@@ -131,31 +134,33 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
131
134
|
])};`
|
132
135
|
])
|
133
136
|
: "// no chunk install function needed",
|
134
|
-
withLoading
|
137
|
+
withCallback || withLoading
|
135
138
|
? Template.asString([
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
139
|
+
withLoading
|
140
|
+
? `${fn}.i = ${runtimeTemplate.basicFunction(
|
141
|
+
"chunkId, promises",
|
142
|
+
hasJsMatcher !== false
|
143
|
+
? [
|
144
|
+
'// "1" is the signal for "already loaded"',
|
145
|
+
"if(!installedChunks[chunkId]) {",
|
146
|
+
Template.indent([
|
147
|
+
hasJsMatcher === true
|
148
|
+
? "if(true) { // all chunks have JS"
|
149
|
+
: `if(${hasJsMatcher("chunkId")}) {`,
|
150
|
+
Template.indent(
|
151
|
+
`importScripts(${
|
152
|
+
withCreateScriptUrl
|
153
|
+
? `${RuntimeGlobals.createScriptUrl}(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId))`
|
154
|
+
: `${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId)`
|
155
|
+
});`
|
156
|
+
),
|
157
|
+
"}"
|
158
|
+
]),
|
159
|
+
"}"
|
160
|
+
]
|
161
|
+
: "installedChunks[chunkId] = 1;"
|
162
|
+
)};`
|
163
|
+
: "",
|
159
164
|
"",
|
160
165
|
`var chunkLoadingGlobal = ${chunkLoadingGlobalExpr} = ${chunkLoadingGlobalExpr} || [];`,
|
161
166
|
"var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.99.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"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.",
|
6
6
|
"license": "MIT",
|
@@ -23,9 +23,9 @@
|
|
23
23
|
"loader-runner": "^4.2.0",
|
24
24
|
"mime-types": "^2.1.27",
|
25
25
|
"neo-async": "^2.6.2",
|
26
|
-
"schema-utils": "^3.
|
26
|
+
"schema-utils": "^4.3.0",
|
27
27
|
"tapable": "^2.1.1",
|
28
|
-
"terser-webpack-plugin": "^5.3.
|
28
|
+
"terser-webpack-plugin": "^5.3.11",
|
29
29
|
"watchpack": "^2.4.1",
|
30
30
|
"webpack-sources": "^3.2.3"
|
31
31
|
},
|
@@ -35,16 +35,16 @@
|
|
35
35
|
}
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
-
"@babel/core": "^7.
|
38
|
+
"@babel/core": "^7.26.8",
|
39
39
|
"@babel/preset-react": "^7.25.7",
|
40
|
-
"@eslint/js": "^9.
|
41
|
-
"@stylistic/eslint-plugin": "^2.
|
40
|
+
"@eslint/js": "^9.21.0",
|
41
|
+
"@stylistic/eslint-plugin": "^4.2.0",
|
42
42
|
"@types/glob-to-regexp": "^0.4.4",
|
43
43
|
"@types/jest": "^29.5.11",
|
44
44
|
"@types/mime-types": "^2.1.4",
|
45
|
-
"@types/node": "^22.
|
46
|
-
"assemblyscript": "^0.27.
|
47
|
-
"babel-loader": "^
|
45
|
+
"@types/node": "^22.13.10",
|
46
|
+
"assemblyscript": "^0.27.34",
|
47
|
+
"babel-loader": "^10.0.0",
|
48
48
|
"benchmark": "^2.1.4",
|
49
49
|
"bundle-loader": "^0.5.6",
|
50
50
|
"coffee-loader": "^5.0.0",
|
@@ -55,19 +55,18 @@
|
|
55
55
|
"date-fns": "^4.0.0",
|
56
56
|
"es5-ext": "^0.10.53",
|
57
57
|
"es6-promise-polyfill": "^1.2.0",
|
58
|
-
"eslint": "^9.
|
59
|
-
"eslint-config-prettier": "^
|
58
|
+
"eslint": "^9.21.0",
|
59
|
+
"eslint-config-prettier": "^10.1.1",
|
60
60
|
"eslint-plugin-jest": "^28.6.0",
|
61
|
-
"eslint-plugin-jsdoc": "^
|
62
|
-
"eslint-plugin-n": "^17.
|
61
|
+
"eslint-plugin-jsdoc": "^50.6.3",
|
62
|
+
"eslint-plugin-n": "^17.16.2",
|
63
63
|
"eslint-plugin-prettier": "^5.1.3",
|
64
|
-
"eslint-plugin-unicorn": "^
|
64
|
+
"eslint-plugin-unicorn": "^58.0.0",
|
65
65
|
"file-loader": "^6.0.0",
|
66
66
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
67
|
-
"globals": "^
|
67
|
+
"globals": "^16.0.0",
|
68
68
|
"hash-wasm": "^4.9.0",
|
69
69
|
"husky": "^9.0.11",
|
70
|
-
"is-ci": "^3.0.0",
|
71
70
|
"istanbul": "^0.4.5",
|
72
71
|
"jest": "^29.7.0",
|
73
72
|
"jest-circus": "^29.7.0",
|
@@ -87,28 +86,28 @@
|
|
87
86
|
"mini-svg-data-uri": "^1.2.3",
|
88
87
|
"nyc": "^17.1.0",
|
89
88
|
"open-cli": "^8.0.0",
|
90
|
-
"prettier": "^3.
|
89
|
+
"prettier": "^3.5.1",
|
91
90
|
"prettier-2": "npm:prettier@^2",
|
92
91
|
"pretty-format": "^29.5.0",
|
93
92
|
"pug": "^3.0.3",
|
94
93
|
"pug-loader": "^2.4.0",
|
95
94
|
"raw-loader": "^4.0.1",
|
96
|
-
"react": "^
|
97
|
-
"react-dom": "^
|
95
|
+
"react": "^19.0.0",
|
96
|
+
"react-dom": "^19.0.0",
|
98
97
|
"rimraf": "^3.0.2",
|
99
98
|
"script-loader": "^0.7.2",
|
100
99
|
"simple-git": "^3.27.0",
|
101
100
|
"strip-ansi": "^6.0.0",
|
102
101
|
"style-loader": "^4.0.0",
|
103
|
-
"terser": "^5.
|
102
|
+
"terser": "^5.38.1",
|
104
103
|
"toml": "^3.0.0",
|
105
|
-
"tooling": "webpack/tooling#v1.23.
|
104
|
+
"tooling": "webpack/tooling#v1.23.7",
|
106
105
|
"ts-loader": "^9.5.1",
|
107
|
-
"typescript": "^5.
|
106
|
+
"typescript": "^5.8.2",
|
108
107
|
"url-loader": "^4.1.0",
|
109
108
|
"wast-loader": "^1.12.1",
|
110
109
|
"webassembly-feature": "1.3.0",
|
111
|
-
"webpack-cli": "^
|
110
|
+
"webpack-cli": "^6.0.1",
|
112
111
|
"xxhashjs": "^0.2.2",
|
113
112
|
"yamljs": "^0.3.0",
|
114
113
|
"yarn-deduplicate": "^6.0.1"
|
@@ -153,8 +152,9 @@
|
|
153
152
|
"pretest": "yarn lint",
|
154
153
|
"prelint": "yarn setup",
|
155
154
|
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-test && yarn module-typings-test && yarn yarn-lint && yarn pretty-lint && yarn spellcheck",
|
156
|
-
"code-lint": "eslint --cache .",
|
155
|
+
"code-lint": "node node_modules/eslint/bin/eslint.js --cache .",
|
157
156
|
"type-lint": "tsc",
|
157
|
+
"type-validate": "tsc -p tsconfig.validation.json",
|
158
158
|
"typings-test": "tsc -p tsconfig.types.test.json",
|
159
159
|
"module-typings-test": "tsc -p tsconfig.module.test.json",
|
160
160
|
"spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
|
@@ -182,11 +182,12 @@
|
|
182
182
|
},
|
183
183
|
"lint-staged": {
|
184
184
|
"*.{js,cjs,mjs}": [
|
185
|
-
"eslint --cache --fix"
|
185
|
+
"node node_modules/eslint/bin/eslint.js --cache --fix"
|
186
186
|
],
|
187
187
|
"*": [
|
188
188
|
"node node_modules/prettier/bin/prettier.cjs --cache --write --ignore-unknown",
|
189
189
|
"cspell --cache --no-must-find-files"
|
190
190
|
]
|
191
|
-
}
|
191
|
+
},
|
192
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
192
193
|
}
|