webpack 5.85.0 → 5.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +5 -2
- package/lib/APIPlugin.js +150 -99
- package/lib/AsyncDependenciesBlock.js +3 -3
- package/lib/BannerPlugin.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +35 -17
- package/lib/ChunkGraph.js +4 -4
- package/lib/ChunkGroup.js +20 -9
- package/lib/CompatibilityPlugin.js +50 -30
- package/lib/Compilation.js +2 -1
- package/lib/Compiler.js +10 -9
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +73 -32
- package/lib/ContextModule.js +8 -3
- package/lib/ContextModuleFactory.js +1 -0
- package/lib/ContextReplacementPlugin.js +13 -0
- package/lib/DelegatedModule.js +15 -3
- package/lib/DelegatedModuleFactoryPlugin.js +6 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/Dependency.js +11 -5
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllEntryPlugin.js +11 -1
- package/lib/DllModule.js +6 -0
- package/lib/DllReferencePlugin.js +13 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/ErrorHelpers.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +6 -1
- package/lib/ExportsInfo.js +22 -4
- package/lib/ExportsInfoApiPlugin.js +14 -5
- package/lib/ExternalModule.js +20 -8
- package/lib/FileSystemInfo.js +52 -24
- package/lib/FlagAllModulesAsUsedPlugin.js +6 -1
- package/lib/FlagDependencyUsagePlugin.js +3 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/Generator.js +7 -0
- package/lib/HotModuleReplacementPlugin.js +8 -0
- package/lib/InitFragment.js +28 -5
- package/lib/JavascriptMetaInfoPlugin.js +11 -6
- package/lib/LibManifestPlugin.js +20 -4
- package/lib/Module.js +14 -3
- package/lib/ModuleDependencyError.js +4 -2
- package/lib/ModuleDependencyWarning.js +4 -2
- package/lib/ModuleGraph.js +31 -24
- package/lib/ModuleGraphConnection.js +19 -6
- package/lib/ModuleInfoHeaderPlugin.js +9 -2
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleProfile.js +1 -0
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +7 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/NodeStuffPlugin.js +32 -6
- package/lib/ProgressPlugin.js +71 -15
- package/lib/ProvidePlugin.js +13 -4
- package/lib/RawModule.js +3 -1
- package/lib/RequireJsStuffPlugin.js +7 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +3 -3
- package/lib/RuntimePlugin.js +6 -3
- package/lib/RuntimeTemplate.js +22 -4
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +7 -2
- package/lib/UseStrictPlugin.js +10 -3
- package/lib/Watching.js +62 -25
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackIsIncludedPlugin.js +6 -4
- package/lib/WebpackOptionsApply.js +4 -2
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/asset/AssetGenerator.js +2 -1
- package/lib/asset/AssetParser.js +11 -6
- package/lib/asset/AssetSourceParser.js +8 -3
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/buildChunkGraph.js +37 -21
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/PackFileCacheStrategy.js +53 -22
- package/lib/config/browserslistTargetHandler.js +7 -7
- package/lib/config/defaults.js +43 -26
- package/lib/container/RemoteRuntimeModule.js +1 -1
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +43 -19
- package/lib/css/CssModulesPlugin.js +42 -14
- package/lib/css/CssParser.js +22 -0
- package/lib/dependencies/AMDDefineDependency.js +34 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +5 -0
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +14 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +169 -59
- package/lib/dependencies/CommonJsPlugin.js +13 -8
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +7 -2
- package/lib/dependencies/CssImportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +5 -0
- package/lib/dependencies/CssUrlDependency.js +3 -3
- package/lib/dependencies/DllEntryDependency.js +5 -0
- package/lib/dependencies/DynamicExports.js +10 -6
- package/lib/dependencies/ExportsInfoDependency.js +14 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +2 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExports.js +9 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +40 -27
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +31 -21
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
- package/lib/dependencies/ImportDependency.js +5 -3
- package/lib/dependencies/ImportEagerDependency.js +5 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
- package/lib/dependencies/ImportMetaPlugin.js +31 -15
- package/lib/dependencies/ImportParserPlugin.js +62 -25
- package/lib/dependencies/ImportWeakDependency.js +5 -3
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ProvidedDependency.js +4 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +13 -5
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +5 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +6 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +26 -5
- package/lib/dependencies/RequireResolveHeaderDependency.js +9 -0
- package/lib/dependencies/SystemPlugin.js +17 -5
- package/lib/dependencies/SystemRuntimeModule.js +1 -1
- package/lib/dependencies/URLDependency.js +2 -2
- package/lib/dependencies/URLPlugin.js +9 -4
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +59 -22
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -0
- package/lib/javascript/BasicEvaluatedExpression.js +28 -19
- package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
- package/lib/javascript/JavascriptModulesPlugin.js +25 -5
- package/lib/javascript/JavascriptParser.js +157 -85
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/json/JsonData.js +2 -2
- package/lib/json/JsonParser.js +25 -12
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +13 -1
- package/lib/library/EnableLibraryPlugin.js +4 -0
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +20 -2
- package/lib/logging/runtime.js +1 -1
- package/lib/logging/truncateArgs.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -6
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +10 -6
- package/lib/optimize/AggressiveMergingPlugin.js +8 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +2 -1
- package/lib/optimize/LimitChunkCountPlugin.js +29 -4
- package/lib/optimize/MangleExportsPlugin.js +1 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
- package/lib/optimize/RealContentHashPlugin.js +80 -30
- package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
- package/lib/optimize/RuntimeChunkPlugin.js +9 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
- package/lib/optimize/SplitChunksPlugin.js +71 -31
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +6 -3
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -2
- package/lib/rules/BasicEffectRulePlugin.js +4 -0
- package/lib/rules/BasicMatcherRulePlugin.js +5 -0
- package/lib/rules/RuleSetCompiler.js +3 -3
- package/lib/rules/UseEffectRulePlugin.js +6 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +8 -5
- package/lib/runtime/AutoPublicPathRuntimeModule.js +4 -2
- package/lib/runtime/BaseUriRuntimeModule.js +3 -3
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
- package/lib/runtime/CompatRuntimeModule.js +7 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/CreateScriptRuntimeModule.js +4 -2
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +4 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +5 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +15 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -10
- package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
- package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -2
- package/lib/runtime/GlobalRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +64 -48
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/NonceRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
- package/lib/runtime/PublicPathRuntimeModule.js +4 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -3
- package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -2
- package/lib/runtime/SystemContextRuntimeModule.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +143 -1
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/ObjectMiddleware.js +9 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +14 -5
- package/lib/sharing/ProvideSharedDependency.js +11 -0
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +22 -21
- package/lib/sharing/ShareRuntimeModule.js +12 -5
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/sharing/utils.js +32 -5
- package/lib/util/AsyncQueue.js +4 -2
- package/lib/util/ParallelismFactorCalculator.js +10 -0
- package/lib/util/Semaphore.js +1 -1
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/createHash.js +30 -9
- package/lib/util/deprecation.js +10 -3
- package/lib/util/deterministicGrouping.js +50 -11
- package/lib/util/findGraphRoots.js +4 -2
- package/lib/util/memoize.js +3 -3
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +84 -21
- package/lib/util/semver.js +1 -0
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +6 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +14 -7
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyParser.js +6 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +14 -4
- package/lib/webpack.js +11 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +15 -16
- package/module.d.ts +1 -0
- package/package.json +5 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +52 -6
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +606 -292
@@ -9,6 +9,9 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
9
|
const RuntimeModule = require("../RuntimeModule");
|
10
10
|
const Template = require("../Template");
|
11
11
|
|
12
|
+
/** @typedef {import("../Chunk")} Chunk */
|
13
|
+
/** @typedef {import("../Compilation")} Compilation */
|
14
|
+
|
12
15
|
/**
|
13
16
|
* @typedef {Object} AsyncWasmLoadingRuntimeModuleOptions
|
14
17
|
* @property {function(string): string} generateLoadBinaryCode
|
@@ -26,10 +29,11 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
26
29
|
}
|
27
30
|
|
28
31
|
/**
|
29
|
-
* @returns {string} runtime code
|
32
|
+
* @returns {string | null} runtime code
|
30
33
|
*/
|
31
34
|
generate() {
|
32
|
-
const
|
35
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
36
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
33
37
|
const { outputOptions, runtimeTemplate } = compilation;
|
34
38
|
const fn = RuntimeGlobals.instantiateWasm;
|
35
39
|
const wasmModuleSrcPath = compilation.getPath(
|
@@ -11,6 +11,8 @@ const Parser = require("../Parser");
|
|
11
11
|
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
12
12
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
13
13
|
|
14
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
15
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
14
16
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
15
17
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
16
18
|
|
@@ -43,9 +45,11 @@ class WebAssemblyParser extends Parser {
|
|
43
45
|
}
|
44
46
|
|
45
47
|
// flag it as async module
|
46
|
-
state.module.buildInfo
|
47
|
-
|
48
|
-
state.module.buildMeta
|
48
|
+
const buildInfo = /** @type {BuildInfo} */ (state.module.buildInfo);
|
49
|
+
buildInfo.strict = true;
|
50
|
+
const BuildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
|
51
|
+
BuildMeta.exportsType = "namespace";
|
52
|
+
BuildMeta.async = true;
|
49
53
|
|
50
54
|
// parse it
|
51
55
|
const program = decode(source, decoderOpts);
|
@@ -10,6 +10,7 @@ const Template = require("../Template");
|
|
10
10
|
const { compareModulesByIdentifier } = require("../util/comparators");
|
11
11
|
const WebAssemblyUtils = require("./WebAssemblyUtils");
|
12
12
|
|
13
|
+
/** @typedef {import("@webassemblyjs/ast").Signature} Signature */
|
13
14
|
/** @typedef {import("../Chunk")} Chunk */
|
14
15
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
15
16
|
/** @typedef {import("../Compilation")} Compilation */
|
@@ -91,9 +92,11 @@ const generateImportObject = (
|
|
91
92
|
value: `${instanceVar}[${JSON.stringify(usedName)}]`
|
92
93
|
});
|
93
94
|
} else {
|
94
|
-
const params =
|
95
|
-
|
96
|
-
|
95
|
+
const params =
|
96
|
+
/** @type {Signature} */
|
97
|
+
(description.signature).params.map(
|
98
|
+
(param, k) => "p" + k + param.valtype
|
99
|
+
);
|
97
100
|
|
98
101
|
const mod = `${RuntimeGlobals.moduleCache}[${JSON.stringify(
|
99
102
|
chunkGraph.getModuleId(importedModule)
|
@@ -130,6 +133,7 @@ const generateImportObject = (
|
|
130
133
|
"};"
|
131
134
|
];
|
132
135
|
} else {
|
136
|
+
/** @type {Map<string, Array<{ name: string, value: string }>>} */
|
133
137
|
const propertiesByModule = new Map();
|
134
138
|
for (const p of properties) {
|
135
139
|
let list = propertiesByModule.get(p.module);
|
@@ -222,23 +226,26 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
222
226
|
}
|
223
227
|
|
224
228
|
/**
|
225
|
-
* @returns {string} runtime code
|
229
|
+
* @returns {string | null} runtime code
|
226
230
|
*/
|
227
231
|
generate() {
|
228
|
-
const { chunkGraph, compilation, chunk, mangleImports } = this;
|
229
|
-
const { moduleGraph, outputOptions } = compilation;
|
230
232
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
231
233
|
const withHmr = this._runtimeRequirements.has(
|
232
234
|
RuntimeGlobals.hmrDownloadUpdateHandlers
|
233
235
|
);
|
236
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
237
|
+
const { moduleGraph, outputOptions } = compilation;
|
238
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
239
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
234
240
|
const wasmModules = getAllWasmModules(moduleGraph, chunkGraph, chunk);
|
241
|
+
const { mangleImports } = this;
|
235
242
|
/** @type {string[]} */
|
236
243
|
const declarations = [];
|
237
244
|
const importObjects = wasmModules.map(module => {
|
238
245
|
return generateImportObject(
|
239
246
|
chunkGraph,
|
240
247
|
module,
|
241
|
-
|
248
|
+
mangleImports,
|
242
249
|
declarations,
|
243
250
|
chunk.runtime
|
244
251
|
);
|
@@ -11,6 +11,7 @@ const UnsupportedWebAssemblyFeatureError = require("./UnsupportedWebAssemblyFeat
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
12
12
|
/** @typedef {import("../Dependency")} Dependency */
|
13
13
|
/** @typedef {import("../Module")} Module */
|
14
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
14
15
|
|
15
16
|
class WasmFinalizeExportsPlugin {
|
16
17
|
/**
|
@@ -27,7 +28,8 @@ class WasmFinalizeExportsPlugin {
|
|
27
28
|
// 1. if a WebAssembly module
|
28
29
|
if (module.type.startsWith("webassembly") === true) {
|
29
30
|
const jsIncompatibleExports =
|
30
|
-
|
31
|
+
/** @type {BuildMeta} */
|
32
|
+
(module.buildMeta).jsIncompatibleExports;
|
31
33
|
|
32
34
|
if (jsIncompatibleExports === undefined) {
|
33
35
|
continue;
|
@@ -174,6 +174,7 @@ const createDefaultInitForGlobal = globalType => {
|
|
174
174
|
*/
|
175
175
|
const rewriteImportedGlobals = state => bin => {
|
176
176
|
const additionalInitCode = state.additionalInitCode;
|
177
|
+
/** @type {Array<t.Global>} */
|
177
178
|
const newGlobals = [];
|
178
179
|
|
179
180
|
bin = editWithAST(state.ast, bin, {
|
@@ -14,6 +14,8 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
|
|
14
14
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
15
15
|
|
16
16
|
/** @typedef {import("../Module")} Module */
|
17
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
18
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
17
19
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
18
20
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
19
21
|
|
@@ -81,8 +83,10 @@ class WebAssemblyParser extends Parser {
|
|
81
83
|
}
|
82
84
|
|
83
85
|
// flag it as ESM
|
84
|
-
|
85
|
-
state.module.
|
86
|
+
/** @type {BuildInfo} */
|
87
|
+
(state.module.buildInfo).strict = true;
|
88
|
+
/** @type {BuildMeta} */
|
89
|
+
(state.module.buildMeta).exportsType = "namespace";
|
86
90
|
|
87
91
|
// parse it
|
88
92
|
const program = decode(source, decoderOpts);
|
@@ -14,6 +14,7 @@ const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
|
14
14
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
15
15
|
|
16
16
|
/** @typedef {import("../Chunk")} Chunk */
|
17
|
+
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
17
18
|
|
18
19
|
/**
|
19
20
|
* @typedef {Object} JsonpCompilationPluginHooks
|
@@ -69,10 +70,10 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
69
70
|
}
|
70
71
|
|
71
72
|
/**
|
72
|
-
* @returns {string} runtime code
|
73
|
+
* @returns {string | null} runtime code
|
73
74
|
*/
|
74
75
|
generate() {
|
75
|
-
const
|
76
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
76
77
|
const {
|
77
78
|
runtimeTemplate,
|
78
79
|
outputOptions: {
|
@@ -108,9 +109,14 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
108
109
|
const withPreload = this._runtimeRequirements.has(
|
109
110
|
RuntimeGlobals.preloadChunkHandlers
|
110
111
|
);
|
112
|
+
const withFetchPriority = this._runtimeRequirements.has(
|
113
|
+
RuntimeGlobals.hasFetchPriority
|
114
|
+
);
|
111
115
|
const chunkLoadingGlobalExpr = `${globalObject}[${JSON.stringify(
|
112
116
|
chunkLoadingGlobal
|
113
117
|
)}]`;
|
118
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
119
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
114
120
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
115
121
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
116
122
|
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
@@ -138,7 +144,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
138
144
|
withLoading
|
139
145
|
? Template.asString([
|
140
146
|
`${fn}.j = ${runtimeTemplate.basicFunction(
|
141
|
-
|
147
|
+
`chunkId, promises${withFetchPriority ? ", fetchPriority" : ""}`,
|
142
148
|
hasJsMatcher !== false
|
143
149
|
? Template.indent([
|
144
150
|
"// JSONP chunk loading for javascript",
|
@@ -190,7 +196,11 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
190
196
|
"}"
|
191
197
|
]
|
192
198
|
)};`,
|
193
|
-
`${
|
199
|
+
`${
|
200
|
+
RuntimeGlobals.loadScript
|
201
|
+
}(url, loadingEnded, "chunk-" + chunkId, chunkId${
|
202
|
+
withFetchPriority ? ", fetchPriority" : ""
|
203
|
+
});`
|
194
204
|
]),
|
195
205
|
hasJsMatcher === true
|
196
206
|
? "}"
|
package/lib/webpack.js
CHANGED
@@ -61,7 +61,10 @@ const createMultiCompiler = (childOptions, options) => {
|
|
61
61
|
const createCompiler = rawOptions => {
|
62
62
|
const options = getNormalizedWebpackOptions(rawOptions);
|
63
63
|
applyWebpackOptionsBaseDefaults(options);
|
64
|
-
const compiler = new Compiler(
|
64
|
+
const compiler = new Compiler(
|
65
|
+
/** @type {string} */ (options.context),
|
66
|
+
options
|
67
|
+
);
|
65
68
|
new NodeEnvironmentPlugin({
|
66
69
|
infrastructureLogging: options.infrastructureLogging
|
67
70
|
}).apply(compiler);
|
@@ -69,7 +72,7 @@ const createCompiler = rawOptions => {
|
|
69
72
|
for (const plugin of options.plugins) {
|
70
73
|
if (typeof plugin === "function") {
|
71
74
|
plugin.call(compiler, compiler);
|
72
|
-
} else {
|
75
|
+
} else if (plugin) {
|
73
76
|
plugin.apply(compiler);
|
74
77
|
}
|
75
78
|
}
|
@@ -96,6 +99,11 @@ const createCompiler = rawOptions => {
|
|
96
99
|
* @returns {MultiCompiler} the multi compiler object
|
97
100
|
*/
|
98
101
|
|
102
|
+
/**
|
103
|
+
* @template T
|
104
|
+
* @param {Array<T> | T} options options
|
105
|
+
* @returns {Array<T>} array of options
|
106
|
+
*/
|
99
107
|
const asArray = options =>
|
100
108
|
Array.isArray(options) ? Array.from(options) : [options];
|
101
109
|
|
@@ -117,6 +125,7 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
|
117
125
|
}
|
118
126
|
/** @type {MultiCompiler|Compiler} */
|
119
127
|
let compiler;
|
128
|
+
/** @type {boolean | undefined} */
|
120
129
|
let watch = false;
|
121
130
|
/** @type {WatchOptions|WatchOptions[]} */
|
122
131
|
let watchOptions;
|
@@ -16,6 +16,8 @@ const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
16
16
|
const { getUndoPath } = require("../util/identifier");
|
17
17
|
|
18
18
|
/** @typedef {import("../Chunk")} Chunk */
|
19
|
+
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
20
|
+
/** @typedef {import("../Compilation")} Compilation */
|
19
21
|
|
20
22
|
class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
21
23
|
/**
|
@@ -38,8 +40,9 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
38
40
|
if (options && options.baseUri) {
|
39
41
|
return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
|
40
42
|
}
|
41
|
-
const
|
42
|
-
|
43
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
44
|
+
const outputName = compilation.getPath(
|
45
|
+
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
43
46
|
{
|
44
47
|
chunk,
|
45
48
|
contentHashType: "javascript"
|
@@ -47,7 +50,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
47
50
|
);
|
48
51
|
const rootOutputDir = getUndoPath(
|
49
52
|
outputName,
|
50
|
-
/** @type {string} */ (
|
53
|
+
/** @type {string} */ (compilation.outputOptions.path),
|
51
54
|
false
|
52
55
|
);
|
53
56
|
return `${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
|
@@ -56,19 +59,10 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
56
59
|
}
|
57
60
|
|
58
61
|
/**
|
59
|
-
* @returns {string} runtime code
|
62
|
+
* @returns {string | null} runtime code
|
60
63
|
*/
|
61
64
|
generate() {
|
62
|
-
const {
|
63
|
-
chunk,
|
64
|
-
chunkGraph,
|
65
|
-
compilation: {
|
66
|
-
runtimeTemplate,
|
67
|
-
outputOptions: { chunkLoadingGlobal, hotUpdateGlobal }
|
68
|
-
},
|
69
|
-
_withCreateScriptUrl: withCreateScriptUrl
|
70
|
-
} = this;
|
71
|
-
const globalObject = runtimeTemplate.globalObject;
|
65
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
72
66
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
73
67
|
const withBaseURI = this.runtimeRequirements.has(RuntimeGlobals.baseURI);
|
74
68
|
const withLoading = this.runtimeRequirements.has(
|
@@ -80,9 +74,12 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
80
74
|
const withHmrManifest = this.runtimeRequirements.has(
|
81
75
|
RuntimeGlobals.hmrDownloadManifest
|
82
76
|
);
|
77
|
+
const globalObject = compilation.runtimeTemplate.globalObject;
|
83
78
|
const chunkLoadingGlobalExpr = `${globalObject}[${JSON.stringify(
|
84
|
-
chunkLoadingGlobal
|
79
|
+
compilation.outputOptions.chunkLoadingGlobal
|
85
80
|
)}]`;
|
81
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
82
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
86
83
|
const hasJsMatcher = compileBooleanMatcher(
|
87
84
|
chunkGraph.getChunkConditionMap(chunk, chunkHasJs)
|
88
85
|
);
|
@@ -91,6 +88,8 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
91
88
|
const stateExpression = withHmr
|
92
89
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_importScripts`
|
93
90
|
: undefined;
|
91
|
+
const runtimeTemplate = compilation.runtimeTemplate;
|
92
|
+
const { _withCreateScriptUrl: withCreateScriptUrl } = this;
|
94
93
|
|
95
94
|
return Template.asString([
|
96
95
|
withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
|
@@ -169,7 +168,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
169
168
|
Template.indent([
|
170
169
|
"var success = false;",
|
171
170
|
`${globalObject}[${JSON.stringify(
|
172
|
-
hotUpdateGlobal
|
171
|
+
compilation.outputOptions.hotUpdateGlobal
|
173
172
|
)}] = ${runtimeTemplate.basicFunction("_, moreModules, runtime", [
|
174
173
|
"for(var moduleId in moreModules) {",
|
175
174
|
Template.indent([
|
package/module.d.ts
CHANGED
@@ -174,6 +174,7 @@ interface ImportMeta {
|
|
174
174
|
exclude?: RegExp;
|
175
175
|
preload?: boolean | number;
|
176
176
|
prefetch?: boolean | number;
|
177
|
+
fetchPriority?: "low" | "high" | "auto";
|
177
178
|
chunkName?: string;
|
178
179
|
exports?: string | string[][];
|
179
180
|
mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.88.1",
|
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",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"acorn-import-assertions": "^1.9.0",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
17
|
-
"enhanced-resolve": "^5.
|
17
|
+
"enhanced-resolve": "^5.15.0",
|
18
18
|
"es-module-lexer": "^1.2.1",
|
19
19
|
"eslint-scope": "5.1.1",
|
20
20
|
"events": "^3.2.0",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"loader-runner": "^4.2.0",
|
25
25
|
"mime-types": "^2.1.27",
|
26
26
|
"neo-async": "^2.6.2",
|
27
|
-
"schema-utils": "^3.
|
27
|
+
"schema-utils": "^3.2.0",
|
28
28
|
"tapable": "^2.1.1",
|
29
29
|
"terser-webpack-plugin": "^5.3.7",
|
30
30
|
"watchpack": "^2.4.0",
|
@@ -39,6 +39,7 @@
|
|
39
39
|
"@babel/core": "^7.21.4",
|
40
40
|
"@babel/preset-react": "^7.18.6",
|
41
41
|
"@types/jest": "^29.5.0",
|
42
|
+
"@types/mime-types": "^2.1.1",
|
42
43
|
"@types/node": "^20.1.7",
|
43
44
|
"assemblyscript": "^0.27.2",
|
44
45
|
"babel-loader": "^8.1.0",
|
@@ -97,7 +98,7 @@
|
|
97
98
|
"style-loader": "^2.0.0",
|
98
99
|
"terser": "^5.17.0",
|
99
100
|
"toml": "^3.0.0",
|
100
|
-
"tooling": "webpack/tooling#v1.
|
101
|
+
"tooling": "webpack/tooling#v1.23.0",
|
101
102
|
"ts-loader": "^9.4.2",
|
102
103
|
"typescript": "^5.0.4",
|
103
104
|
"url-loader": "^4.1.0",
|