@depup/webpack 5.110.1-depup.0 → 5.111.1-depup.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 +7 -8
- package/changes.json +7 -11
- package/lib/APIPlugin.js +26 -11
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/Cache.js +8 -3
- package/lib/CacheFacade.js +1 -1
- package/lib/ChunkGraph.js +20 -18
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +337 -338
- package/lib/Compiler.js +213 -51
- package/lib/ConcatenationScope.js +25 -35
- package/lib/ConstPlugin.js +16 -132
- package/lib/CopyPlugin.js +1054 -0
- package/lib/DefinePlugin.js +24 -8
- package/lib/DependencyTemplate.js +2 -1
- package/lib/DotenvPlugin.js +64 -40
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +30 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +17 -15
- package/lib/Generator.js +24 -2
- package/lib/HotModuleReplacementPlugin.js +55 -7
- package/lib/IgnorePlugin.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +5 -3
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/MainTemplate.js +5 -1
- package/lib/Module.js +19 -10
- package/lib/ModuleGraph.js +6 -9
- package/lib/MultiCompiler.js +7 -17
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +148 -70
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +33 -3
- package/lib/RuntimeTemplate.js +1147 -847
- package/lib/SourceMapDevToolPlugin.js +54 -104
- package/lib/TemplatedPathPlugin.js +16 -59
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +84 -91
- package/lib/asset/AssetBytesGenerator.js +7 -1
- package/lib/asset/AssetGenerator.js +50 -24
- package/lib/asset/AssetModule.js +3 -0
- package/lib/asset/AssetSourceGenerator.js +7 -1
- package/lib/asset/WebManifestParser.js +7 -5
- package/lib/async-modules/AsyncModuleHelpers.js +10 -4
- package/lib/buildChunkGraph.js +11 -15
- package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/MemoryCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
- package/lib/cache/PackFileCacheStrategy.js +17 -19
- package/lib/cache/getLazyHashedEtag.js +3 -5
- package/lib/config/browserslistTargetHandler.js +17 -4
- package/lib/config/defaults.js +162 -142
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +100 -20
- package/lib/config/target.js +13 -4
- package/lib/container/ContainerReferencePlugin.js +6 -0
- package/lib/container/RemoteRuntimeModule.js +9 -0
- package/lib/container/declaredRemotes.js +39 -0
- package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
- package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
- package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
- package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
- package/lib/css/CssGenerator.js +27 -11
- package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
- package/lib/css/CssLoadingRuntimeModule.js +92 -15
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +3 -10
- package/lib/css/CssParser.js +162 -31
- package/lib/css/CssServerStylesRuntimeModule.js +9 -0
- package/lib/css/cssMinify.js +43 -32
- package/lib/css/data.js +3526 -871
- package/lib/css/syntax.js +6455 -1237
- package/lib/debug/ProfilingPlugin.js +7 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
- package/lib/dependencies/AMDRuntimeModules.js +18 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
- package/lib/dependencies/CommonJsPlugin.js +19 -3
- package/lib/dependencies/CommonJsRequireDependency.js +32 -9
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +13 -9
- package/lib/dependencies/CssIcssImportDependency.js +3 -6
- package/lib/dependencies/CssUrlDependency.js +3 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +217 -34
- package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
- package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
- package/lib/dependencies/HarmonyImportDependency.js +99 -41
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +198 -25
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +117 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +136 -104
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportContextDependency.js +43 -3
- package/lib/dependencies/ImportDependency.js +8 -29
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
- package/lib/dependencies/ImportMetaMainDependency.js +104 -0
- package/lib/dependencies/ImportMetaPlugin.js +67 -25
- package/lib/dependencies/ImportParserPlugin.js +25 -15
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireHeaderDependency.js +20 -21
- package/lib/dependencies/SystemRuntimeModule.js +9 -0
- package/lib/dependencies/URLContextDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +6 -5
- package/lib/dependencies/WorkerAndWorkletPlugin.js +16 -21
- package/lib/dependencies/WorkerDependency.js +12 -18
- package/lib/dependencies/WorkletDependency.js +12 -20
- package/lib/dependencies/importOptionsCheck.js +47 -0
- package/lib/dll/DelegatedModule.js +18 -1
- package/lib/dll/DllReferencePlugin.js +11 -8
- package/lib/dll/LibManifestPlugin.js +1 -1
- package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
- package/lib/errors/DotenvFileError.js +29 -0
- package/lib/errors/DuplicateModulesWarning.js +12 -7
- package/lib/errors/EmptyCopyPatternWarning.js +26 -0
- package/lib/errors/ExternalStarReexportError.js +44 -0
- package/lib/errors/HookWebpackError.js +3 -2
- package/lib/errors/ImportedBindingAssignmentError.js +30 -0
- package/lib/errors/MissingSourceMapsWarning.js +36 -0
- package/lib/errors/ModuleParseError.js +2 -1
- package/lib/errors/UnusedAssetsWarning.js +36 -0
- package/lib/errors/UnusedFederationWarning.js +35 -0
- package/lib/errors/UnusedModulesWarning.js +38 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +21 -5
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +91 -53
- package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
- package/lib/hmr/LazyCompilationPlugin.js +3 -5
- package/lib/html/HtmlGenerator.js +72 -87
- package/lib/html/HtmlModulesPlugin.js +479 -215
- package/lib/html/HtmlParser.js +110 -147
- package/lib/html/builtinEmbeddedRenderer.js +107 -0
- package/lib/html/data.js +142 -7
- package/lib/html/htmlMinify.js +92 -122
- package/lib/html/syntax.js +2031 -1556
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/index.js +49 -3
- package/lib/javascript/ChunkFormatHelpers.js +4 -3
- package/lib/javascript/JavascriptGenerator.js +8 -1
- package/lib/javascript/JavascriptModule.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +76 -80
- package/lib/javascript/JavascriptParser.js +1970 -900
- package/lib/javascript/StartupHelpers.js +27 -3
- package/lib/javascript/data.js +172 -0
- package/lib/javascript/grammar.js +5546 -0
- package/lib/javascript/parser.js +1500 -0
- package/lib/javascript/regexp.js +1762 -0
- package/lib/javascript/regexpData.js +51 -0
- package/lib/javascript/syntax.js +9061 -5262
- package/lib/json/JsonGenerator.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +171 -132
- package/lib/loaders/LoaderRunner.js +170 -14
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +222 -125
- package/lib/optimize/ConstExportsPlugin.js +50 -34
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -2
- package/lib/optimize/InnerGraphPlugin.js +7 -13
- package/lib/optimize/LimitChunkCountPlugin.js +5 -8
- package/lib/optimize/MangleExportsPlugin.js +13 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
- package/lib/optimize/RealContentHashPlugin.js +179 -44
- package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
- package/lib/optimize/SplitChunksPlugin.js +2 -4
- package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
- package/lib/performance/BroadContextsPlugin.js +1 -1
- package/lib/performance/CacheEffectivenessPlugin.js +7 -7
- package/lib/performance/DuplicateModulesPlugin.js +57 -13
- package/lib/performance/EvalUsagePlugin.js +5 -2
- package/lib/performance/MissingSourceMapsPlugin.js +115 -0
- package/lib/performance/PureAnnotationsPlugin.js +6 -3
- package/lib/performance/SizeLimitsPlugin.js +2 -4
- package/lib/performance/TopLevelThisPlugin.js +5 -4
- package/lib/performance/UnusedAssetsPlugin.js +109 -0
- package/lib/performance/UnusedFederationPlugin.js +147 -0
- package/lib/performance/UnusedModulesPlugin.js +141 -0
- package/lib/performance/UnusedReexportsPlugin.js +1 -55
- package/lib/performance/isOnlyReexported.js +65 -0
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ResourceHintPlugin.js +29 -35
- package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
- package/lib/rules/RuleSetCompiler.js +211 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +103 -67
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
- package/lib/runtime/BaseUriRuntimeModule.js +9 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
- package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
- package/lib/runtime/GlobalRuntimeModule.js +11 -4
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
- package/lib/runtime/HelperRuntimeModule.js +10 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +313 -222
- package/lib/runtime/NonceRuntimeModule.js +9 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
- package/lib/runtime/PublicPathRuntimeModule.js +9 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
- package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
- package/lib/runtime/SystemContextRuntimeModule.js +9 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
- package/lib/schemes/DataUriPlugin.js +3 -6
- package/lib/schemes/HttpUriPlugin.js +22 -5
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +31 -18
- package/lib/serialization/ObjectMiddleware.js +168 -139
- package/lib/sharing/ConsumeSharedPlugin.js +12 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
- package/lib/sharing/ShareRuntimeModule.js +9 -0
- package/lib/sharing/declaredShared.js +47 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
- package/lib/typescript/TypeScriptPlugin.js +10 -13
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/ArrayQueue.js +3 -3
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +115 -99
- package/lib/util/URLAbsoluteSpecifier.js +3 -1
- package/lib/util/async.js +292 -0
- package/lib/util/buildDiagnostics.js +69 -0
- package/lib/util/chainedImports.js +3 -4
- package/lib/util/concatenate.js +4 -4
- package/lib/util/conventions.js +5 -1
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/createMappings.js +25 -3
- package/lib/util/dataURL.js +2 -3
- package/lib/util/deterministicGrouping.js +8 -13
- package/lib/util/findGraphRoots.js +6 -13
- package/lib/util/fs.js +27 -1
- package/lib/util/globUtils.js +1 -1
- package/lib/util/handlerKeys.js +40 -0
- package/lib/util/hash/wasm-hash.js +3 -4
- package/lib/util/identifier.js +20 -0
- package/lib/util/internalSerializables.js +7 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/removeBOM.js +82 -1
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +14 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +14 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
- package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -6
- package/lib/web/FetchCompileWasmPlugin.js +4 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
- package/package.json +55 -46
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +388 -76
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/types.d.ts +1795 -608
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
const Hash = require("../Hash");
|
|
9
9
|
|
|
10
|
-
// 65536 is the size
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
|
10
|
+
// 65536 is a wasm memory page, 64 the largest chunk size any wasm hash
|
|
11
|
+
// implementation takes, 4 the most bytes utf-8 spends on one char, and `& ~3`
|
|
12
|
+
// keeps it a whole block of 4 chars so base64 never sees a partial encoding.
|
|
14
13
|
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
|
15
14
|
|
|
16
15
|
/**
|
package/lib/util/identifier.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
const path = require("path");
|
|
8
|
+
const { fileURLToPath } = require("url");
|
|
8
9
|
|
|
9
10
|
// Any absolute path: POSIX (/foo) and every Windows form — drive-letter (C:\,
|
|
10
11
|
// C:/), UNC (\\, //), rooted (\, /); equals posix||win32 isAbsolute.
|
|
@@ -15,6 +16,23 @@ const WINDOWS_ABS_PATH_REGEXP = /^[a-z]:[\\/]/i;
|
|
|
15
16
|
const SEGMENTS_SPLIT_REGEXP = /([|!])/;
|
|
16
17
|
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
17
18
|
const NODE_MODULES_REGEXP = /[\\/]node_modules[\\/]/i;
|
|
19
|
+
// A file URL, the form `import.meta.resolve()` returns a local module in.
|
|
20
|
+
// One slash after the scheme is enough, as Node's own URL parser needs.
|
|
21
|
+
const FILE_URL_REGEXP = /^file:\//i;
|
|
22
|
+
// What `import()` resolves as a place rather than as a package name: relative,
|
|
23
|
+
// rooted, or carrying a scheme.
|
|
24
|
+
const RESOLVABLE_SPECIFIER_REGEXP = /^(?:\.{0,2}\/|[a-zA-Z][\w+.-]*:)/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Converts a file URL to the path it names. Any other value is returned
|
|
28
|
+
* unchanged, so this is safe to apply to an option that also takes a path.
|
|
29
|
+
* @param {string} pathOrUrl an absolute path or a file URL
|
|
30
|
+
* @returns {string} an absolute path
|
|
31
|
+
*/
|
|
32
|
+
const fileUrlToPath = (pathOrUrl) => {
|
|
33
|
+
if (!FILE_URL_REGEXP.test(pathOrUrl)) return pathOrUrl;
|
|
34
|
+
return fileURLToPath(pathOrUrl);
|
|
35
|
+
};
|
|
18
36
|
|
|
19
37
|
/**
|
|
20
38
|
* Relative path to request.
|
|
@@ -568,12 +586,14 @@ const toJsStringLiteral = (str) =>
|
|
|
568
586
|
|
|
569
587
|
module.exports.ABSOLUTE_PATH_REGEXP = ABSOLUTE_PATH_REGEXP;
|
|
570
588
|
module.exports.NODE_MODULES_REGEXP = NODE_MODULES_REGEXP;
|
|
589
|
+
module.exports.RESOLVABLE_SPECIFIER_REGEXP = RESOLVABLE_SPECIFIER_REGEXP;
|
|
571
590
|
module.exports.WINDOWS_ABS_PATH_REGEXP = WINDOWS_ABS_PATH_REGEXP;
|
|
572
591
|
module.exports.WINDOWS_PATH_SEPARATOR_REGEXP = WINDOWS_PATH_SEPARATOR_REGEXP;
|
|
573
592
|
module.exports.absolutify = absolutify;
|
|
574
593
|
module.exports.contextify = contextify;
|
|
575
594
|
module.exports.contextifySourceUrl = contextifySourceUrl;
|
|
576
595
|
module.exports.escapeHashInPathRequest = escapeHashInPathRequest;
|
|
596
|
+
module.exports.fileUrlToPath = fileUrlToPath;
|
|
577
597
|
module.exports.getUndoPath = getUndoPath;
|
|
578
598
|
module.exports.makeCacheable = makeCacheable;
|
|
579
599
|
module.exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
|
|
@@ -31,6 +31,7 @@ module.exports = {
|
|
|
31
31
|
"container/RemoteModule": () => require("../container/RemoteModule"),
|
|
32
32
|
"container/RemoteToExternalDependency": () =>
|
|
33
33
|
require("../container/RemoteToExternalDependency"),
|
|
34
|
+
"context/ContextModule": () => require("../context/ContextModule"),
|
|
34
35
|
"dependencies/AMDDefineDependency": () =>
|
|
35
36
|
require("../dependencies/AMDDefineDependency"),
|
|
36
37
|
"dependencies/AMDRequireArrayDependency": () =>
|
|
@@ -113,6 +114,8 @@ module.exports = {
|
|
|
113
114
|
require("../dependencies/HarmonyExportImportedSpecifierDependency"),
|
|
114
115
|
"dependencies/HarmonyExportSpecifierDependency": () =>
|
|
115
116
|
require("../dependencies/HarmonyExportSpecifierDependency"),
|
|
117
|
+
"dependencies/HarmonyImportBareSideEffectDependency": () =>
|
|
118
|
+
require("../dependencies/HarmonyImportBareSideEffectDependency"),
|
|
116
119
|
"dependencies/HarmonyImportSideEffectDependency": () =>
|
|
117
120
|
require("../dependencies/HarmonyImportSideEffectDependency"),
|
|
118
121
|
"dependencies/HarmonyImportSpecifierDependency": () =>
|
|
@@ -141,6 +144,8 @@ module.exports = {
|
|
|
141
144
|
require("../dependencies/ImportMetaHotAcceptDependency"),
|
|
142
145
|
"dependencies/ImportMetaHotDeclineDependency": () =>
|
|
143
146
|
require("../dependencies/ImportMetaHotDeclineDependency"),
|
|
147
|
+
"dependencies/ImportMetaMainDependency": () =>
|
|
148
|
+
require("../dependencies/ImportMetaMainDependency"),
|
|
144
149
|
"dependencies/ImportMetaResolveDependency": () =>
|
|
145
150
|
require("../dependencies/ImportMetaResolveDependency"),
|
|
146
151
|
"dependencies/ImportWeakDependency": () =>
|
|
@@ -211,6 +216,8 @@ module.exports = {
|
|
|
211
216
|
"errors/EnvironmentNotSupportAsyncWarning": () =>
|
|
212
217
|
require("../errors/EnvironmentNotSupportAsyncWarning"),
|
|
213
218
|
"errors/HookWebpackError": () => require("../errors/HookWebpackError"),
|
|
219
|
+
"errors/ImportedBindingAssignmentError": () =>
|
|
220
|
+
require("../errors/ImportedBindingAssignmentError"),
|
|
214
221
|
"errors/InvalidDependenciesModuleWarning": () =>
|
|
215
222
|
require("../errors/InvalidDependenciesModuleWarning"),
|
|
216
223
|
"errors/JSONParseError": () => require("../errors/JSONParseError"),
|
|
@@ -255,7 +262,6 @@ module.exports = {
|
|
|
255
262
|
"wasm-async/AsyncWasmModule": () => require("../wasm-async/AsyncWasmModule"),
|
|
256
263
|
"wasm-sync/SyncWasmModule": () => require("../wasm-sync/SyncWasmModule"),
|
|
257
264
|
AsyncDependenciesBlock: () => require("../AsyncDependenciesBlock"),
|
|
258
|
-
ContextModule: () => require("../ContextModule"),
|
|
259
265
|
CssModule: () => require("../css/CssModule"),
|
|
260
266
|
DependenciesBlock: () => require("../DependenciesBlock"),
|
|
261
267
|
ExternalModule: () => require("../ExternalModule"),
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const Position = require("acorn").Position;
|
|
9
|
-
const SourceLocation = require("acorn").SourceLocation;
|
|
10
8
|
const ValidationError = require("schema-utils").ValidationError;
|
|
11
9
|
const {
|
|
12
10
|
CachedSource,
|
|
@@ -17,9 +15,10 @@ const {
|
|
|
17
15
|
ReplaceSource,
|
|
18
16
|
SourceMapSource
|
|
19
17
|
} = require("webpack-sources");
|
|
18
|
+
const ParserPosition = require("../javascript/syntax").ParserPosition;
|
|
20
19
|
const { register } = require("./serialization");
|
|
21
20
|
|
|
22
|
-
/** @import {
|
|
21
|
+
/** @import { SourcePosition } from "../Dependency" */
|
|
23
22
|
/**
|
|
24
23
|
* @import {
|
|
25
24
|
* ObjectDeserializerContext,
|
|
@@ -229,51 +228,13 @@ register(
|
|
|
229
228
|
);
|
|
230
229
|
|
|
231
230
|
register(
|
|
232
|
-
|
|
231
|
+
ParserPosition,
|
|
233
232
|
CURRENT_MODULE,
|
|
234
|
-
"
|
|
235
|
-
new (class
|
|
233
|
+
"webpack/ParserPosition",
|
|
234
|
+
new (class ParserPositionSerializer {
|
|
236
235
|
/**
|
|
237
236
|
* Serializes this instance into the provided serializer context.
|
|
238
|
-
* @param {
|
|
239
|
-
* @param {import("../serialization/ObjectMiddleware").ObjectSerializerContext<number[]>} context context
|
|
240
|
-
* @returns {void}
|
|
241
|
-
*/
|
|
242
|
-
serialize(loc, { write }) {
|
|
243
|
-
write(loc.start.line);
|
|
244
|
-
write(loc.start.column);
|
|
245
|
-
write(loc.end.line);
|
|
246
|
-
write(loc.end.column);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Restores this instance from the provided deserializer context.
|
|
251
|
-
* @param {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<number[]>} context context
|
|
252
|
-
* @returns {RealDependencyLocation} location
|
|
253
|
-
*/
|
|
254
|
-
deserialize({ read }) {
|
|
255
|
-
return {
|
|
256
|
-
start: {
|
|
257
|
-
line: read(),
|
|
258
|
-
column: read()
|
|
259
|
-
},
|
|
260
|
-
end: {
|
|
261
|
-
line: read(),
|
|
262
|
-
column: read()
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
})()
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
register(
|
|
270
|
-
Position,
|
|
271
|
-
CURRENT_MODULE,
|
|
272
|
-
"acorn/Position",
|
|
273
|
-
new (class PositionSerializer {
|
|
274
|
-
/**
|
|
275
|
-
* Serializes this instance into the provided serializer context.
|
|
276
|
-
* @param {Position} pos the position to be serialized
|
|
237
|
+
* @param {ParserPosition} pos the position to be serialized
|
|
277
238
|
* @param {import("../serialization/ObjectMiddleware").ObjectSerializerContext<number[]>} context context
|
|
278
239
|
* @returns {void}
|
|
279
240
|
*/
|
package/lib/util/removeBOM.js
CHANGED
|
@@ -5,12 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const { decodeVLQ, encodeVLQ } = require("./createMappings");
|
|
9
|
+
|
|
10
|
+
/** @import { RawSourceMap } from "webpack-sources" */
|
|
11
|
+
/** @import { Result } from "../NormalModule" */
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* Returns result without BOM.
|
|
10
15
|
* @param {string | Buffer} strOrBuffer string or buffer
|
|
11
16
|
* @returns {string | Buffer} result without BOM
|
|
12
17
|
*/
|
|
13
|
-
|
|
18
|
+
const removeBOM = (strOrBuffer) => {
|
|
14
19
|
if (typeof strOrBuffer === "string" && strOrBuffer.charCodeAt(0) === 0xfeff) {
|
|
15
20
|
return strOrBuffer.slice(1);
|
|
16
21
|
} else if (
|
|
@@ -24,3 +29,79 @@ module.exports = (strOrBuffer) => {
|
|
|
24
29
|
|
|
25
30
|
return strOrBuffer;
|
|
26
31
|
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A BOM occupies generated column 0 of the first line, so a map describing
|
|
35
|
+
* BOM-prefixed content starts that line at column 1 or later. Removing the BOM
|
|
36
|
+
* moves the line one column left; the segments after the first are encoded
|
|
37
|
+
* relative to it, so only the first is rewritten. A map already starting at
|
|
38
|
+
* column 0 describes the content without its BOM and is left alone.
|
|
39
|
+
* @param {string} mappings VLQ encoded `mappings` of a map for BOM-prefixed content
|
|
40
|
+
* @returns {string} `mappings` for the same content without its BOM
|
|
41
|
+
*/
|
|
42
|
+
const shiftMappings = (mappings) => {
|
|
43
|
+
const { value, end } = decodeVLQ(mappings, 0);
|
|
44
|
+
if (end === 0 || value <= 0) return mappings;
|
|
45
|
+
return encodeVLQ(value - 1) + mappings.slice(end);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Adjust a source map that accompanied BOM-prefixed content for the removal of
|
|
50
|
+
* that BOM. Anything without VLQ `mappings` is passed through untouched, as is
|
|
51
|
+
* a map declaring a version other than 3 — earlier versions spell `mappings`
|
|
52
|
+
* differently. A map that declares no version at all is taken as version 3.
|
|
53
|
+
* @param {(string | RawSourceMap)=} sourceMap the map, as an object or as JSON
|
|
54
|
+
* @returns {(string | RawSourceMap)=} the adjusted map
|
|
55
|
+
*/
|
|
56
|
+
const adjustSourceMapForRemovedBOM = (sourceMap) => {
|
|
57
|
+
if (!sourceMap) return sourceMap;
|
|
58
|
+
|
|
59
|
+
if (typeof sourceMap === "string") {
|
|
60
|
+
/** @type {RawSourceMap} */
|
|
61
|
+
let parsed;
|
|
62
|
+
try {
|
|
63
|
+
parsed = JSON.parse(sourceMap);
|
|
64
|
+
} catch (_err) {
|
|
65
|
+
return sourceMap;
|
|
66
|
+
}
|
|
67
|
+
const adjusted = adjustSourceMapForRemovedBOM(parsed);
|
|
68
|
+
return adjusted === parsed ? sourceMap : JSON.stringify(adjusted);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (sourceMap.version !== undefined && sourceMap.version !== 3) {
|
|
72
|
+
return sourceMap;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (typeof sourceMap.mappings !== "string") return sourceMap;
|
|
76
|
+
|
|
77
|
+
const mappings = shiftMappings(sourceMap.mappings);
|
|
78
|
+
|
|
79
|
+
return mappings === sourceMap.mappings
|
|
80
|
+
? sourceMap
|
|
81
|
+
: { ...sourceMap, mappings };
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {Result} result a loader result: content, an optional source map, extra info
|
|
86
|
+
* @returns {Result} the result with a leading BOM removed from its content and its source map kept in sync
|
|
87
|
+
*/
|
|
88
|
+
const removeBOMFromResult = (result) => {
|
|
89
|
+
const content = result[0];
|
|
90
|
+
const withoutBOM = removeBOM(content);
|
|
91
|
+
|
|
92
|
+
if (withoutBOM === content) return result;
|
|
93
|
+
|
|
94
|
+
// Copied rather than rebuilt, so a result carrying no source map keeps its
|
|
95
|
+
// arity.
|
|
96
|
+
const adjusted = /** @type {Result} */ ([...result]);
|
|
97
|
+
|
|
98
|
+
adjusted[0] = withoutBOM;
|
|
99
|
+
|
|
100
|
+
if (adjusted[1]) adjusted[1] = adjustSourceMapForRemovedBOM(adjusted[1]);
|
|
101
|
+
|
|
102
|
+
return adjusted;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports.adjustSourceMapForRemovedBOM = adjustSourceMapForRemovedBOM;
|
|
106
|
+
module.exports.removeBOM = removeBOM;
|
|
107
|
+
module.exports.removeBOMFromResult = removeBOMFromResult;
|
package/lib/util/semver.js
CHANGED
|
@@ -63,6 +63,7 @@ const versionLt = (a, b) => {
|
|
|
63
63
|
b = parseVersion(b);
|
|
64
64
|
var i = 0;
|
|
65
65
|
for (;;) {
|
|
66
|
+
// WHY: the ordering this loop implements, by the type of each side.
|
|
66
67
|
// a b EOA object undefined number string
|
|
67
68
|
// EOA a == b a < b b < a a < b a < b
|
|
68
69
|
// object b < a (0) b < a a < b a < b
|
|
@@ -185,6 +186,7 @@ module.exports.parseRange = (str) => {
|
|
|
185
186
|
* @returns {SemVerRange}
|
|
186
187
|
*/
|
|
187
188
|
const parseSimple = (str) => {
|
|
189
|
+
// WHY: the grammar this parses.
|
|
188
190
|
// simple ::= primitive | partial | tilde | caret
|
|
189
191
|
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | '!' ) ( ' ' ) * partial
|
|
190
192
|
// tilde ::= '~' ( ' ' ) * partial
|
|
@@ -399,7 +401,7 @@ const satisfy = (range, version) => {
|
|
|
399
401
|
for (var i = 0, j = 1, isEqual = true; ; j++, i++) {
|
|
400
402
|
// cspell:word nequal nequ
|
|
401
403
|
|
|
402
|
-
// when isEqual = true:
|
|
404
|
+
// WHY: the decision table this loop implements, when isEqual = true:
|
|
403
405
|
// range version: EOA/object undefined number string
|
|
404
406
|
// EOA equal block big-ver big-ver
|
|
405
407
|
// undefined bigger next big-ver big-ver
|
|
@@ -408,7 +410,7 @@ const satisfy = (range, version) => {
|
|
|
408
410
|
// string smaller block differ cmp
|
|
409
411
|
// fixed string smaller block small-cmp cmp-fix
|
|
410
412
|
|
|
411
|
-
// when isEqual = false:
|
|
413
|
+
// WHY: and when isEqual = false:
|
|
412
414
|
// range version: EOA/object undefined number string
|
|
413
415
|
// EOA nequal block next-ver next-ver
|
|
414
416
|
// undefined nequal block next-ver next-ver
|
|
@@ -417,7 +419,7 @@ const satisfy = (range, version) => {
|
|
|
417
419
|
// string nequal block next next
|
|
418
420
|
// fixed string nequal block next next (this never happens)
|
|
419
421
|
|
|
420
|
-
// EOA end of array
|
|
422
|
+
// WHY: EOA is end of array; what each cell of the two tables means:
|
|
421
423
|
// equal (version is equal range):
|
|
422
424
|
// when !negated: return true,
|
|
423
425
|
// when negated: return false
|
|
@@ -11,11 +11,12 @@ const Template = require("../Template");
|
|
|
11
11
|
const { fullHashPathData } = require("../wasm/wasmModuleFilename");
|
|
12
12
|
|
|
13
13
|
/** @import Chunk from "../Chunk" */
|
|
14
|
+
/** @import ChunkGraph from "../ChunkGraph" */
|
|
14
15
|
/** @import Compilation from "../Compilation" */
|
|
15
16
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
16
17
|
|
|
17
18
|
/** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */
|
|
18
|
-
/** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec) => string} GenerateLoadBinaryCode */
|
|
19
|
+
/** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec, analyzable: boolean) => string} GenerateLoadBinaryCode */
|
|
19
20
|
/** @typedef {() => string} GenerateBeforeCompileStreaming */
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -55,6 +56,15 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
|
|
|
55
56
|
this.supportsStreaming = supportsStreaming;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
61
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
62
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
63
|
+
*/
|
|
64
|
+
getInstalledChunkHandlers() {
|
|
65
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
/**
|
|
59
69
|
* Generates runtime code for this runtime module.
|
|
60
70
|
* @returns {string | null} runtime code
|
|
@@ -69,7 +79,7 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
|
|
|
69
79
|
// Analyzable output bakes the binary's URL into the call site instead.
|
|
70
80
|
const analyzable = runtimeTemplate.supportsAnalyzable(
|
|
71
81
|
"wasm",
|
|
72
|
-
|
|
82
|
+
/** @type {ChunkGraph} */ (this.chunkGraph),
|
|
73
83
|
undefined,
|
|
74
84
|
chunk.runtime
|
|
75
85
|
);
|
|
@@ -92,7 +102,8 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
|
|
|
92
102
|
|
|
93
103
|
const loader = this.generateLoadBinaryCode(
|
|
94
104
|
wasmModuleSrcPath,
|
|
95
|
-
chunk.runtime
|
|
105
|
+
chunk.runtime,
|
|
106
|
+
analyzable
|
|
96
107
|
);
|
|
97
108
|
|
|
98
109
|
// Fallback path: fetch -> arrayBuffer -> WebAssembly.compile
|
|
@@ -11,11 +11,12 @@ const Template = require("../Template");
|
|
|
11
11
|
const { fullHashPathData } = require("../wasm/wasmModuleFilename");
|
|
12
12
|
|
|
13
13
|
/** @import Chunk from "../Chunk" */
|
|
14
|
+
/** @import ChunkGraph from "../ChunkGraph" */
|
|
14
15
|
/** @import Compilation from "../Compilation" */
|
|
15
16
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
16
17
|
|
|
17
18
|
/** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */
|
|
18
|
-
/** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec) => string} GenerateLoadBinaryCode */
|
|
19
|
+
/** @typedef {(wasmModuleSrcPath: string, runtime: RuntimeSpec, analyzable: boolean) => string} GenerateLoadBinaryCode */
|
|
19
20
|
/** @typedef {() => string} GenerateBeforeInstantiateStreaming */
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -56,6 +57,15 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
56
57
|
this.supportsStreaming = supportsStreaming;
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
62
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
63
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
64
|
+
*/
|
|
65
|
+
getInstalledChunkHandlers() {
|
|
66
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
67
|
+
}
|
|
68
|
+
|
|
59
69
|
/**
|
|
60
70
|
* Generates runtime code for this runtime module.
|
|
61
71
|
* @returns {string | null} runtime code
|
|
@@ -70,7 +80,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
70
80
|
// Analyzable output bakes the binary's URL into the call site instead.
|
|
71
81
|
const analyzable = runtimeTemplate.supportsAnalyzable(
|
|
72
82
|
"wasm",
|
|
73
|
-
|
|
83
|
+
/** @type {ChunkGraph} */ (this.chunkGraph),
|
|
74
84
|
undefined,
|
|
75
85
|
chunk.runtime
|
|
76
86
|
);
|
|
@@ -93,7 +103,8 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
93
103
|
|
|
94
104
|
const loader = this.generateLoadBinaryCode(
|
|
95
105
|
wasmModuleSrcPath,
|
|
96
|
-
chunk.runtime
|
|
106
|
+
chunk.runtime,
|
|
107
|
+
analyzable
|
|
97
108
|
);
|
|
98
109
|
const fallback = [
|
|
99
110
|
`.then(${runtimeTemplate.returningFunction("x.arrayBuffer()", "x")})`,
|
|
@@ -72,7 +72,12 @@ class AsyncWebAssemblyGenerator extends Generator {
|
|
|
72
72
|
* @returns {Source | null} generated code
|
|
73
73
|
*/
|
|
74
74
|
generateError(error, module, generateContext) {
|
|
75
|
-
return new RawSource(
|
|
75
|
+
return new RawSource(
|
|
76
|
+
Generator.buildErrorMessage(
|
|
77
|
+
error,
|
|
78
|
+
generateContext.runtimeTemplate.requestShortener
|
|
79
|
+
)
|
|
80
|
+
);
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
|
|
@@ -303,7 +303,11 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
303
303
|
*/
|
|
304
304
|
generateError(error, module, generateContext) {
|
|
305
305
|
return new RawSource(
|
|
306
|
-
Generator.throwBuildErrorCode(
|
|
306
|
+
Generator.throwBuildErrorCode(
|
|
307
|
+
error,
|
|
308
|
+
"WebAssembly.CompileError",
|
|
309
|
+
generateContext.runtimeTemplate.requestShortener
|
|
310
|
+
)
|
|
307
311
|
);
|
|
308
312
|
}
|
|
309
313
|
}
|
|
@@ -67,31 +67,26 @@ class UniversalCompileAsyncWasmPlugin {
|
|
|
67
67
|
// per call: it depends on parse results, so it is not settled while the plugin
|
|
68
68
|
// is being applied.
|
|
69
69
|
/**
|
|
70
|
-
* @param {
|
|
70
|
+
* @param {boolean} analyzable whether the call site bakes a complete URL
|
|
71
71
|
* @returns {string} the argument to hand the reader
|
|
72
72
|
*/
|
|
73
|
-
const wasmUrlArg = (
|
|
74
|
-
|
|
75
|
-
"wasm",
|
|
76
|
-
undefined,
|
|
77
|
-
undefined,
|
|
78
|
-
runtime
|
|
79
|
-
)
|
|
73
|
+
const wasmUrlArg = (analyzable) =>
|
|
74
|
+
analyzable
|
|
80
75
|
? "wasmUrl"
|
|
81
76
|
: compilation.runtimeTemplate.importMetaUrl("wasmUrl");
|
|
82
77
|
/**
|
|
83
78
|
* Generates the runtime expression that fetches the binary in browsers
|
|
84
79
|
* or reads it from the filesystem in Node.js.
|
|
85
|
-
* @type {(path: string, runtime: RuntimeSpec) => string}
|
|
80
|
+
* @type {(path: string, runtime: RuntimeSpec, analyzable: boolean) => string}
|
|
86
81
|
*/
|
|
87
|
-
const generateLoadBinaryCode = (path, runtime) =>
|
|
82
|
+
const generateLoadBinaryCode = (path, runtime, analyzable) =>
|
|
88
83
|
Template.asString([
|
|
89
84
|
"(useFetch",
|
|
90
|
-
Template.indent([`? fetch(${wasmUrlArg(
|
|
85
|
+
Template.indent([`? fetch(${wasmUrlArg(analyzable)})`]),
|
|
91
86
|
Template.indent([
|
|
92
87
|
": Promise.all([import('fs'), import('url')]).then(([{ readFile }, { URL }]) => new Promise((resolve, reject) => {",
|
|
93
88
|
Template.indent([
|
|
94
|
-
`readFile(${wasmUrlArg(
|
|
89
|
+
`readFile(${wasmUrlArg(analyzable)}, (err, buffer) => {`,
|
|
95
90
|
Template.indent([
|
|
96
91
|
"if (err) return reject(err);",
|
|
97
92
|
"",
|
|
@@ -254,6 +254,15 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
254
254
|
this._runtimeRequirements = runtimeRequirements;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
/**
|
|
258
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
259
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
260
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
261
|
+
*/
|
|
262
|
+
getInstalledChunkHandlers() {
|
|
263
|
+
return [[RuntimeGlobals.ensureChunkHandlers, "wasm"]];
|
|
264
|
+
}
|
|
265
|
+
|
|
257
266
|
/**
|
|
258
267
|
* Generates runtime code for this runtime module.
|
|
259
268
|
* @returns {string | null} runtime code
|
|
@@ -330,10 +339,9 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
330
339
|
stateExpression ? runtimeTemplate.assignOr(stateExpression, "{}") : "{}"
|
|
331
340
|
};`,
|
|
332
341
|
"",
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
// So we not even trying and solve this by a microtask delay.
|
|
342
|
+
// Delays reading the installed wasm module promises by a microtask.
|
|
343
|
+
// Sorting them instead is not always possible — modules split across
|
|
344
|
+
// chunks have no order — so the delay is what is relied on.
|
|
337
345
|
"function promiseResolve() { return Promise.resolve(); }",
|
|
338
346
|
"",
|
|
339
347
|
Template.asString(declarations),
|
|
@@ -544,7 +544,12 @@ class WebAssemblyGenerator extends Generator {
|
|
|
544
544
|
* @returns {Source | null} generated code
|
|
545
545
|
*/
|
|
546
546
|
generateError(error, module, generateContext) {
|
|
547
|
-
return new RawSource(
|
|
547
|
+
return new RawSource(
|
|
548
|
+
Generator.buildErrorMessage(
|
|
549
|
+
error,
|
|
550
|
+
generateContext.runtimeTemplate.requestShortener
|
|
551
|
+
)
|
|
552
|
+
);
|
|
548
553
|
}
|
|
549
554
|
|
|
550
555
|
/**
|
|
@@ -232,7 +232,11 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
232
232
|
*/
|
|
233
233
|
generateError(error, module, generateContext) {
|
|
234
234
|
return new RawSource(
|
|
235
|
-
Generator.throwBuildErrorCode(
|
|
235
|
+
Generator.throwBuildErrorCode(
|
|
236
|
+
error,
|
|
237
|
+
"WebAssembly.CompileError",
|
|
238
|
+
generateContext.runtimeTemplate.requestShortener
|
|
239
|
+
)
|
|
236
240
|
);
|
|
237
241
|
}
|
|
238
242
|
}
|
|
@@ -42,10 +42,8 @@ const getUsedDependencies = (moduleGraph, module, mangle) => {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const exportName = dep.name;
|
|
45
|
-
// TODO
|
|
46
|
-
//
|
|
47
|
-
// const usedName = importedModule && moduleGraph.getExportsInfo(importedModule).getUsedName(exportName, runtime);
|
|
48
|
-
// if (usedName !== false) {
|
|
45
|
+
// TODO once ModuleExport can be removed, skip a dependency whose
|
|
46
|
+
// imported module reports `getUsedName(exportName, runtime) === false`.
|
|
49
47
|
if (mangle) {
|
|
50
48
|
array.push({
|
|
51
49
|
dependency: dep,
|
|
@@ -91,12 +91,14 @@ class FetchCompileAsyncWasmPlugin {
|
|
|
91
91
|
}
|
|
92
92
|
const baked = compilation.runtimeTemplate.supportsAnalyzable(
|
|
93
93
|
"wasm",
|
|
94
|
-
|
|
94
|
+
chunkGraph,
|
|
95
95
|
undefined,
|
|
96
96
|
chunk.runtime
|
|
97
97
|
);
|
|
98
|
-
const analyzable =
|
|
99
|
-
|
|
98
|
+
const analyzable = compilation.runtimeTemplate.supportsAnalyzable(
|
|
99
|
+
"wasm-relative",
|
|
100
|
+
chunkGraph
|
|
101
|
+
);
|
|
100
102
|
// A baked URL carries the public path already, and a settled one is written
|
|
101
103
|
// out below; only a path nothing but the global knows asks for it.
|
|
102
104
|
const constant =
|
|
@@ -151,12 +153,14 @@ class FetchCompileAsyncWasmPlugin {
|
|
|
151
153
|
}
|
|
152
154
|
const baked = compilation.runtimeTemplate.supportsAnalyzable(
|
|
153
155
|
"wasm",
|
|
154
|
-
|
|
156
|
+
chunkGraph,
|
|
155
157
|
undefined,
|
|
156
158
|
chunk.runtime
|
|
157
159
|
);
|
|
158
|
-
const analyzable =
|
|
159
|
-
|
|
160
|
+
const analyzable = compilation.runtimeTemplate.supportsAnalyzable(
|
|
161
|
+
"wasm-relative",
|
|
162
|
+
chunkGraph
|
|
163
|
+
);
|
|
160
164
|
// A baked URL carries the public path already, and a settled one is written
|
|
161
165
|
// out below; only a path nothing but the global knows asks for it.
|
|
162
166
|
const constant =
|
|
@@ -99,8 +99,10 @@ class FetchCompileWasmPlugin {
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
set.add(RuntimeGlobals.moduleCache);
|
|
102
|
-
const analyzable =
|
|
103
|
-
|
|
102
|
+
const analyzable = compilation.runtimeTemplate.supportsAnalyzable(
|
|
103
|
+
"wasm-relative",
|
|
104
|
+
chunkGraph
|
|
105
|
+
);
|
|
104
106
|
const constant = analyzable
|
|
105
107
|
? undefined
|
|
106
108
|
: compilation.runtimeTemplate.constantPublicPath();
|
|
@@ -38,6 +38,42 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
38
38
|
this._runtimeRequirements = runtimeRequirements;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
43
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
44
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
45
|
+
*/
|
|
46
|
+
getInstalledChunkHandlers() {
|
|
47
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
48
|
+
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
49
|
+
const runtimeRequirements = this._runtimeRequirements;
|
|
50
|
+
/** @type {[string, string][]} */
|
|
51
|
+
const handlers = [];
|
|
52
|
+
if (runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)) {
|
|
53
|
+
handlers.push([RuntimeGlobals.ensureChunkHandlers, "j"]);
|
|
54
|
+
}
|
|
55
|
+
// The hot update flow installs this one onto the same map while it runs.
|
|
56
|
+
if (runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)) {
|
|
57
|
+
handlers.push([RuntimeGlobals.ensureChunkHandlers, "jsonpHmr"]);
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
|
|
61
|
+
chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasJs)
|
|
62
|
+
) {
|
|
63
|
+
handlers.push([RuntimeGlobals.prefetchChunkHandlers, "j"]);
|
|
64
|
+
}
|
|
65
|
+
if (
|
|
66
|
+
runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
|
|
67
|
+
chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs)
|
|
68
|
+
) {
|
|
69
|
+
handlers.push([RuntimeGlobals.preloadChunkHandlers, "j"]);
|
|
70
|
+
}
|
|
71
|
+
if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
|
|
72
|
+
handlers.push([RuntimeGlobals.onChunksLoaded, "j"]);
|
|
73
|
+
}
|
|
74
|
+
return handlers;
|
|
75
|
+
}
|
|
76
|
+
|
|
41
77
|
/**
|
|
42
78
|
* @private
|
|
43
79
|
* @param {Chunk} chunk chunk
|