webpack 5.107.1 → 5.108.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/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +52 -14
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +16 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +557 -77
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +9 -1
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +105 -30
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +88 -9
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +22 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +267 -154
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +20 -27
- package/lib/dependencies/HtmlInlineStyleDependency.js +62 -11
- package/lib/dependencies/HtmlSourceDependency.js +18 -0
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +40 -10
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +134 -6
- package/lib/html/HtmlGenerator.js +292 -50
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +287 -60
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +286 -159
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +54 -29
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +38 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +397 -78
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +16 -6
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +36 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1592 -314
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
|
@@ -9,12 +9,11 @@ const { SyncWaterfallHook } = require("tapable");
|
|
|
9
9
|
const Compilation = require("../Compilation");
|
|
10
10
|
const Generator = require("../Generator");
|
|
11
11
|
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
|
12
|
-
const NormalModule = require("../NormalModule");
|
|
13
12
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
14
13
|
const { tryRunOrWebpackError } = require("../errors/HookWebpackError");
|
|
15
14
|
const { compareModulesByFullName } = require("../util/comparators");
|
|
16
|
-
const makeSerializable = require("../util/makeSerializable");
|
|
17
15
|
const memoize = require("../util/memoize");
|
|
16
|
+
const AsyncWasmModule = require("./AsyncWasmModule");
|
|
18
17
|
|
|
19
18
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
19
|
/** @typedef {import("../Chunk")} Chunk */
|
|
@@ -23,13 +22,9 @@ const memoize = require("../util/memoize");
|
|
|
23
22
|
/** @typedef {import("../Compiler")} Compiler */
|
|
24
23
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
25
24
|
/** @typedef {import("../Module")} Module */
|
|
26
|
-
/** @typedef {import("../dependencies/ImportPhase").ImportPhaseName} ImportPhaseName */
|
|
27
|
-
/** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */
|
|
28
25
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
29
26
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
30
27
|
/** @typedef {import("../errors/WebpackError")} WebpackError */
|
|
31
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
32
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
33
28
|
|
|
34
29
|
const getAsyncWebAssemblyGenerator = memoize(() =>
|
|
35
30
|
require("./AsyncWebAssemblyGenerator")
|
|
@@ -41,96 +36,6 @@ const getAsyncWebAssemblyParser = memoize(() =>
|
|
|
41
36
|
require("./AsyncWebAssemblyParser")
|
|
42
37
|
);
|
|
43
38
|
|
|
44
|
-
/** @typedef {NormalModule & { phase: ImportPhaseName | undefined }} AsyncWasmModuleClass */
|
|
45
|
-
|
|
46
|
-
class AsyncWasmModule extends NormalModule {
|
|
47
|
-
/**
|
|
48
|
-
* @param {NormalModuleCreateData & { phase: ImportPhaseName | undefined }} options options object
|
|
49
|
-
*/
|
|
50
|
-
constructor(options) {
|
|
51
|
-
super(options);
|
|
52
|
-
this.phase = options.phase;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns the unique identifier used to reference this module.
|
|
57
|
-
* @returns {string} a unique identifier of the module
|
|
58
|
-
*/
|
|
59
|
-
identifier() {
|
|
60
|
-
let str = super.identifier();
|
|
61
|
-
|
|
62
|
-
if (this.phase) {
|
|
63
|
-
str = `${str}|${this.phase}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return str;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Assuming this module is in the cache. Update the (cached) module with
|
|
71
|
-
* the fresh module from the factory. Usually updates internal references
|
|
72
|
-
* and properties.
|
|
73
|
-
* @param {Module} module fresh module
|
|
74
|
-
* @returns {void}
|
|
75
|
-
*/
|
|
76
|
-
updateCacheModule(module) {
|
|
77
|
-
super.updateCacheModule(module);
|
|
78
|
-
const m = /** @type {AsyncWasmModule} */ (module);
|
|
79
|
-
this.phase = m.phase;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Serializes this instance into the provided serializer context.
|
|
84
|
-
* @param {ObjectSerializerContext} context context
|
|
85
|
-
*/
|
|
86
|
-
serialize(context) {
|
|
87
|
-
const { write } = context;
|
|
88
|
-
write(this.phase);
|
|
89
|
-
super.serialize(context);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @param {ObjectDeserializerContext} context context
|
|
94
|
-
* @returns {AsyncWasmModule} the deserialized object
|
|
95
|
-
*/
|
|
96
|
-
static deserialize(context) {
|
|
97
|
-
const obj = new AsyncWasmModule({
|
|
98
|
-
// will be deserialized by Module
|
|
99
|
-
layer: /** @type {EXPECTED_ANY} */ (null),
|
|
100
|
-
type: "",
|
|
101
|
-
// will be filled by updateCacheModule
|
|
102
|
-
resource: "",
|
|
103
|
-
context: "",
|
|
104
|
-
request: /** @type {EXPECTED_ANY} */ (null),
|
|
105
|
-
userRequest: /** @type {EXPECTED_ANY} */ (null),
|
|
106
|
-
rawRequest: /** @type {EXPECTED_ANY} */ (null),
|
|
107
|
-
loaders: /** @type {EXPECTED_ANY} */ (null),
|
|
108
|
-
matchResource: /** @type {EXPECTED_ANY} */ (null),
|
|
109
|
-
parser: /** @type {EXPECTED_ANY} */ (null),
|
|
110
|
-
parserOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
111
|
-
generator: /** @type {EXPECTED_ANY} */ (null),
|
|
112
|
-
generatorOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
113
|
-
resolveOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
114
|
-
extractSourceMap: /** @type {EXPECTED_ANY} */ (null),
|
|
115
|
-
phase: /** @type {EXPECTED_ANY} */ (null)
|
|
116
|
-
});
|
|
117
|
-
obj.deserialize(context);
|
|
118
|
-
return obj;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Restores this instance from the provided deserializer context.
|
|
123
|
-
* @param {ObjectDeserializerContext} context context
|
|
124
|
-
*/
|
|
125
|
-
deserialize(context) {
|
|
126
|
-
const { read } = context;
|
|
127
|
-
this.phase = read();
|
|
128
|
-
super.deserialize(context);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
makeSerializable(AsyncWasmModule, "webpack/lib/wasm-async/AsyncWasmModule");
|
|
133
|
-
|
|
134
39
|
/**
|
|
135
40
|
* Defines the web assembly render context type used by this module.
|
|
136
41
|
* @typedef {object} WebAssemblyRenderContext
|
|
@@ -12,7 +12,7 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency
|
|
|
12
12
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
13
13
|
const EnvironmentNotSupportAsyncWarning = require("../errors/EnvironmentNotSupportAsyncWarning");
|
|
14
14
|
|
|
15
|
-
/** @typedef {import("./
|
|
15
|
+
/** @typedef {import("./AsyncWasmModule")} AsyncWasmModule */
|
|
16
16
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
17
17
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
18
18
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
@@ -58,7 +58,7 @@ class UniversalCompileAsyncWasmPlugin {
|
|
|
58
58
|
*/
|
|
59
59
|
const generateBeforeLoadBinaryCode = (path) =>
|
|
60
60
|
Template.asString([
|
|
61
|
-
|
|
61
|
+
`var useFetch = ${compilation.runtimeTemplate.isWebLikePlatformExpression()};`,
|
|
62
62
|
`var wasmUrl = ${path};`
|
|
63
63
|
]);
|
|
64
64
|
/**
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const NormalModule = require("../NormalModule");
|
|
8
|
+
const makeSerializable = require("../util/makeSerializable");
|
|
9
|
+
|
|
10
|
+
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
11
|
+
/** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Defines the build meta properties specific to sync wasm modules.
|
|
15
|
+
* @typedef {object} KnownSyncWasmModuleBuildMeta
|
|
16
|
+
* @property {Record<string, string>=} jsIncompatibleExports
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @typedef {BuildMeta & KnownSyncWasmModuleBuildMeta} SyncWasmModuleBuildMeta */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Module class for `webassembly/sync` modules. Wasm-specific properties should live here instead of `NormalModule`.
|
|
23
|
+
*/
|
|
24
|
+
class SyncWasmModule extends NormalModule {
|
|
25
|
+
/**
|
|
26
|
+
* @param {NormalModuleCreateData} options options object
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
super(options);
|
|
30
|
+
|
|
31
|
+
// Redeclared with the sync wasm specific shape
|
|
32
|
+
/** @type {SyncWasmModuleBuildMeta | undefined} */
|
|
33
|
+
this.buildMeta = undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
makeSerializable(SyncWasmModule, "webpack/lib/wasm-sync/SyncWasmModule");
|
|
38
|
+
|
|
39
|
+
module.exports = SyncWasmModule;
|
|
@@ -239,8 +239,11 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
239
239
|
}) {
|
|
240
240
|
super("wasm chunk loading", RuntimeModule.STAGE_ATTACH);
|
|
241
241
|
this.generateLoadBinaryCode = generateLoadBinaryCode;
|
|
242
|
+
/** @type {boolean | undefined} */
|
|
242
243
|
this.supportsStreaming = supportsStreaming;
|
|
244
|
+
/** @type {boolean | undefined} */
|
|
243
245
|
this.mangleImports = mangleImports;
|
|
246
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
244
247
|
this._runtimeRequirements = runtimeRequirements;
|
|
245
248
|
}
|
|
246
249
|
|
|
@@ -254,7 +257,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
254
257
|
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
255
258
|
);
|
|
256
259
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
257
|
-
const { moduleGraph, outputOptions } = compilation;
|
|
260
|
+
const { moduleGraph, outputOptions, runtimeTemplate } = compilation;
|
|
258
261
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
259
262
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
260
263
|
const wasmModules = getAllWasmModules(moduleGraph, chunkGraph, chunk);
|
|
@@ -315,8 +318,8 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
315
318
|
return Template.asString([
|
|
316
319
|
"// object to store loaded and loading wasm modules",
|
|
317
320
|
`var installedWasmModules = ${
|
|
318
|
-
stateExpression ?
|
|
319
|
-
}
|
|
321
|
+
stateExpression ? runtimeTemplate.assignOr(stateExpression, "{}") : "{}"
|
|
322
|
+
};`,
|
|
320
323
|
"",
|
|
321
324
|
// This function is used to delay reading the installed wasm module promises
|
|
322
325
|
// by a microtask. Sorting them doesn't help because there are edge cases where
|
|
@@ -12,6 +12,7 @@ const UnsupportedWebAssemblyFeatureError = require("./UnsupportedWebAssemblyFeat
|
|
|
12
12
|
/** @typedef {import("../Dependency")} Dependency */
|
|
13
13
|
/** @typedef {import("../Module")} Module */
|
|
14
14
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
15
|
+
/** @typedef {import("./SyncWasmModule").SyncWasmModuleBuildMeta} SyncWasmModuleBuildMeta */
|
|
15
16
|
|
|
16
17
|
const PLUGIN_NAME = "WasmFinalizeExportsPlugin";
|
|
17
18
|
|
|
@@ -28,7 +29,7 @@ class WasmFinalizeExportsPlugin {
|
|
|
28
29
|
// 1. if a WebAssembly module
|
|
29
30
|
if (module.type.startsWith("webassembly") === true) {
|
|
30
31
|
const jsIncompatibleExports =
|
|
31
|
-
/** @type {
|
|
32
|
+
/** @type {SyncWasmModuleBuildMeta} */
|
|
32
33
|
(module.buildMeta).jsIncompatibleExports;
|
|
33
34
|
|
|
34
35
|
if (jsIncompatibleExports === undefined) {
|
|
@@ -27,6 +27,7 @@ const getWebAssemblyJavascriptGenerator = memoize(() =>
|
|
|
27
27
|
require("./WebAssemblyJavascriptGenerator")
|
|
28
28
|
);
|
|
29
29
|
const getWebAssemblyParser = memoize(() => require("./WebAssemblyParser"));
|
|
30
|
+
const getSyncWasmModule = memoize(() => require("./SyncWasmModule"));
|
|
30
31
|
|
|
31
32
|
const PLUGIN_NAME = "WebAssemblyModulesPlugin";
|
|
32
33
|
|
|
@@ -47,6 +48,7 @@ class WebAssemblyModulesPlugin {
|
|
|
47
48
|
* @param {WebAssemblyModulesPluginOptions} options options
|
|
48
49
|
*/
|
|
49
50
|
constructor(options) {
|
|
51
|
+
/** @type {WebAssemblyModulesPluginOptions} */
|
|
50
52
|
this.options = options;
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -71,6 +73,14 @@ class WebAssemblyModulesPlugin {
|
|
|
71
73
|
normalModuleFactory
|
|
72
74
|
);
|
|
73
75
|
|
|
76
|
+
normalModuleFactory.hooks.createModuleClass
|
|
77
|
+
.for(WEBASSEMBLY_MODULE_TYPE_SYNC)
|
|
78
|
+
.tap(PLUGIN_NAME, (createData, _resolveData) => {
|
|
79
|
+
const SyncWasmModule = getSyncWasmModule();
|
|
80
|
+
|
|
81
|
+
return new SyncWasmModule(createData);
|
|
82
|
+
});
|
|
83
|
+
|
|
74
84
|
normalModuleFactory.hooks.createParser
|
|
75
85
|
.for(WEBASSEMBLY_MODULE_TYPE_SYNC)
|
|
76
86
|
.tap(PLUGIN_NAME, () => {
|
|
@@ -16,6 +16,7 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe
|
|
|
16
16
|
/** @typedef {import("@webassemblyjs/ast").ModuleImport} ModuleImport */
|
|
17
17
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
18
18
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
19
|
+
/** @typedef {import("./SyncWasmModule").SyncWasmModuleBuildMeta} SyncWasmModuleBuildMeta */
|
|
19
20
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
20
21
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
|
21
22
|
|
|
@@ -39,7 +40,8 @@ const getJsIncompatibleType = (signature) => {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Same check for the other `@webassemblyjs` signature shape: imports carry the
|
|
44
|
+
* AST `Signature` node (above), the module context uses plain `FuncSignature`.
|
|
43
45
|
* @param {t.FuncSignature} signature the func signature
|
|
44
46
|
* @returns {null | string} the type incompatible with js types
|
|
45
47
|
*/
|
|
@@ -90,7 +92,9 @@ class WebAssemblyParser extends Parser {
|
|
|
90
92
|
// extract imports and exports
|
|
91
93
|
/** @type {string[]} */
|
|
92
94
|
const exports = [];
|
|
93
|
-
const buildMeta = /** @type {
|
|
95
|
+
const buildMeta = /** @type {SyncWasmModuleBuildMeta} */ (
|
|
96
|
+
state.module.buildMeta
|
|
97
|
+
);
|
|
94
98
|
/** @type {Record<string, string> | undefined} */
|
|
95
99
|
let jsIncompatibleExports = (buildMeta.jsIncompatibleExports = undefined);
|
|
96
100
|
|
|
@@ -114,7 +118,7 @@ class WebAssemblyParser extends Parser {
|
|
|
114
118
|
if (incompatibleType) {
|
|
115
119
|
if (jsIncompatibleExports === undefined) {
|
|
116
120
|
jsIncompatibleExports =
|
|
117
|
-
/** @type {
|
|
121
|
+
/** @type {SyncWasmModuleBuildMeta} */
|
|
118
122
|
(state.module.buildMeta).jsIncompatibleExports = {};
|
|
119
123
|
}
|
|
120
124
|
jsIncompatibleExports[node.name] = incompatibleType;
|
|
@@ -131,21 +131,24 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
131
131
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_jsonp`
|
|
132
132
|
: undefined;
|
|
133
133
|
|
|
134
|
+
const cst = runtimeTemplate.renderConst();
|
|
135
|
+
const lt = runtimeTemplate.renderLet();
|
|
136
|
+
const installedChunksObject = `{\n${Template.indent(
|
|
137
|
+
Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(
|
|
138
|
+
",\n"
|
|
139
|
+
)
|
|
140
|
+
)}\n}`;
|
|
134
141
|
return Template.asString([
|
|
135
142
|
withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
|
|
136
143
|
"",
|
|
137
144
|
"// object to store loaded and loading chunks",
|
|
138
145
|
"// undefined = chunk not loaded, null = chunk preloaded/prefetched",
|
|
139
146
|
"// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded",
|
|
140
|
-
|
|
141
|
-
stateExpression
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
",\n"
|
|
146
|
-
)
|
|
147
|
-
),
|
|
148
|
-
"};",
|
|
147
|
+
`${cst} installedChunks = ${
|
|
148
|
+
stateExpression
|
|
149
|
+
? runtimeTemplate.assignOr(stateExpression, installedChunksObject)
|
|
150
|
+
: installedChunksObject
|
|
151
|
+
};`,
|
|
149
152
|
"",
|
|
150
153
|
withLoading
|
|
151
154
|
? Template.asString([
|
|
@@ -154,7 +157,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
154
157
|
hasJsMatcher !== false
|
|
155
158
|
? Template.indent([
|
|
156
159
|
"// JSONP chunk loading for javascript",
|
|
157
|
-
|
|
160
|
+
`${lt} installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
|
|
158
161
|
'if(installedChunkData !== 0) { // 0 means "already installed".',
|
|
159
162
|
Template.indent([
|
|
160
163
|
"",
|
|
@@ -170,17 +173,17 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
170
173
|
: `if(${hasJsMatcher("chunkId")}) {`,
|
|
171
174
|
Template.indent([
|
|
172
175
|
"// setup Promise in chunk cache",
|
|
173
|
-
|
|
176
|
+
`${cst} promise = new Promise(${runtimeTemplate.expressionFunction(
|
|
174
177
|
"installedChunkData = installedChunks[chunkId] = [resolve, reject]",
|
|
175
178
|
"resolve, reject"
|
|
176
179
|
)});`,
|
|
177
180
|
"promises.push(installedChunkData[2] = promise);",
|
|
178
181
|
"",
|
|
179
182
|
"// start chunk loading",
|
|
180
|
-
|
|
183
|
+
`${cst} url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
|
|
181
184
|
"// create error before stack unwound to get useful stacktrace later",
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
`${cst} error = new Error();`,
|
|
186
|
+
`${cst} loadingEnded = ${runtimeTemplate.basicFunction(
|
|
184
187
|
"event",
|
|
185
188
|
[
|
|
186
189
|
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
|
|
@@ -189,8 +192,8 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
189
192
|
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
|
|
190
193
|
"if(installedChunkData) {",
|
|
191
194
|
Template.indent([
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
`${cst} errorType = event && (event.type === 'load' ? 'missing' : event.type);`,
|
|
196
|
+
`${cst} realSrc = event && event.target && event.target.src;`,
|
|
194
197
|
"error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
|
195
198
|
"error.name = 'ChunkLoadError';",
|
|
196
199
|
"error.type = errorType;",
|
|
@@ -234,7 +237,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
234
237
|
"installedChunks[chunkId] = null;",
|
|
235
238
|
linkPrefetch.call(
|
|
236
239
|
Template.asString([
|
|
237
|
-
|
|
240
|
+
`${cst} link = document.createElement('link');`,
|
|
238
241
|
charset ? "link.charset = 'utf-8';" : "",
|
|
239
242
|
crossOriginLoading
|
|
240
243
|
? `link.crossOrigin = ${JSON.stringify(
|
|
@@ -271,7 +274,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
271
274
|
"installedChunks[chunkId] = null;",
|
|
272
275
|
linkPreload.call(
|
|
273
276
|
Template.asString([
|
|
274
|
-
|
|
277
|
+
`${cst} link = document.createElement('link');`,
|
|
275
278
|
scriptType && scriptType !== "module"
|
|
276
279
|
? `link.type = ${JSON.stringify(scriptType)};`
|
|
277
280
|
: "",
|
|
@@ -310,8 +313,8 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
310
313
|
"",
|
|
311
314
|
withHmr
|
|
312
315
|
? Template.asString([
|
|
313
|
-
|
|
314
|
-
|
|
316
|
+
`${lt} currentUpdatedModulesList;`,
|
|
317
|
+
`${cst} waitingUpdateResolves = {};`,
|
|
315
318
|
"function loadUpdateChunk(chunkId, updatedModulesList) {",
|
|
316
319
|
Template.indent([
|
|
317
320
|
"currentUpdatedModulesList = updatedModulesList;",
|
|
@@ -320,23 +323,26 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
320
323
|
[
|
|
321
324
|
"waitingUpdateResolves[chunkId] = resolve;",
|
|
322
325
|
"// start update chunk loading",
|
|
323
|
-
|
|
326
|
+
`${cst} url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId);`,
|
|
324
327
|
"// create error before stack unwound to get useful stacktrace later",
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
"
|
|
328
|
-
|
|
329
|
-
"waitingUpdateResolves[chunkId]
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
328
|
+
`${cst} error = new Error();`,
|
|
329
|
+
`${cst} loadingEnded = ${runtimeTemplate.basicFunction(
|
|
330
|
+
"event",
|
|
331
|
+
[
|
|
332
|
+
"if(waitingUpdateResolves[chunkId]) {",
|
|
333
|
+
Template.indent([
|
|
334
|
+
"waitingUpdateResolves[chunkId] = undefined",
|
|
335
|
+
`${cst} errorType = event && (event.type === 'load' ? 'missing' : event.type);`,
|
|
336
|
+
`${cst} realSrc = event && event.target && event.target.src;`,
|
|
337
|
+
"error.message = 'Loading hot update chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
|
338
|
+
"error.name = 'ChunkLoadError';",
|
|
339
|
+
"error.type = errorType;",
|
|
340
|
+
"error.request = realSrc;",
|
|
341
|
+
"reject(error);"
|
|
342
|
+
]),
|
|
343
|
+
"}"
|
|
344
|
+
]
|
|
345
|
+
)};`,
|
|
340
346
|
`${RuntimeGlobals.loadScript}(url, loadingEnded);`
|
|
341
347
|
]
|
|
342
348
|
)});`
|
|
@@ -353,7 +359,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
353
359
|
`if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
|
|
354
360
|
Template.indent([
|
|
355
361
|
"currentUpdate[moduleId] = moreModules[moduleId];",
|
|
356
|
-
"
|
|
362
|
+
`${runtimeTemplate.optionalChaining("currentUpdatedModulesList", "push(moduleId)")};`
|
|
357
363
|
]),
|
|
358
364
|
"}"
|
|
359
365
|
]),
|
|
@@ -401,7 +407,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
401
407
|
withCallback || withLoading
|
|
402
408
|
? Template.asString([
|
|
403
409
|
"// install a JSONP callback for chunk loading",
|
|
404
|
-
|
|
410
|
+
`${cst} webpackJsonpCallback = ${runtimeTemplate.basicFunction(
|
|
405
411
|
"parentChunkLoadingFunction, data",
|
|
406
412
|
[
|
|
407
413
|
runtimeTemplate.destructureArray(
|
|
@@ -444,7 +450,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
444
450
|
]
|
|
445
451
|
)}`,
|
|
446
452
|
"",
|
|
447
|
-
|
|
453
|
+
`${cst} chunkLoadingGlobal = ${runtimeTemplate.assignOr(chunkLoadingGlobalExpr, "[]")};`,
|
|
448
454
|
"chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));",
|
|
449
455
|
"chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));"
|
|
450
456
|
])
|
|
@@ -100,6 +100,11 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
100
100
|
: undefined;
|
|
101
101
|
const runtimeTemplate = compilation.runtimeTemplate;
|
|
102
102
|
const { _withCreateScriptUrl: withCreateScriptUrl } = this;
|
|
103
|
+
const installedChunksObject = `{\n${Template.indent(
|
|
104
|
+
Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 1`).join(
|
|
105
|
+
",\n"
|
|
106
|
+
)
|
|
107
|
+
)}\n}`;
|
|
103
108
|
|
|
104
109
|
return Template.asString([
|
|
105
110
|
withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
|
|
@@ -107,14 +112,10 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
107
112
|
"// object to store loaded chunks",
|
|
108
113
|
'// "1" means "already loaded"',
|
|
109
114
|
`var installedChunks = ${
|
|
110
|
-
stateExpression
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
",\n"
|
|
115
|
-
)
|
|
116
|
-
),
|
|
117
|
-
"};",
|
|
115
|
+
stateExpression
|
|
116
|
+
? runtimeTemplate.assignOr(stateExpression, installedChunksObject)
|
|
117
|
+
: installedChunksObject
|
|
118
|
+
};`,
|
|
118
119
|
"",
|
|
119
120
|
withCallback || withLoading
|
|
120
121
|
? Template.asString([
|
|
@@ -168,7 +169,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
168
169
|
)};`
|
|
169
170
|
: "",
|
|
170
171
|
"",
|
|
171
|
-
`var chunkLoadingGlobal = ${chunkLoadingGlobalExpr
|
|
172
|
+
`var chunkLoadingGlobal = ${runtimeTemplate.assignOr(chunkLoadingGlobalExpr, "[]")};`,
|
|
172
173
|
"var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);",
|
|
173
174
|
"chunkLoadingGlobal.push = installChunk;"
|
|
174
175
|
])
|
|
@@ -187,7 +188,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
187
188
|
`if(${RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
|
|
188
189
|
Template.indent([
|
|
189
190
|
"currentUpdate[moduleId] = moreModules[moduleId];",
|
|
190
|
-
"
|
|
191
|
+
`${runtimeTemplate.optionalChaining("updatedModulesList", "push(moduleId)")};`
|
|
191
192
|
]),
|
|
192
193
|
"}"
|
|
193
194
|
]),
|