@depup/webpack 5.110.3-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/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +336 -337
- package/lib/Compiler.js +213 -51
- 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 +24 -28
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +20 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +9 -13
- 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 +135 -50
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +30 -3
- package/lib/RuntimeTemplate.js +813 -518
- 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/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 +138 -128
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +82 -12
- 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 +94 -36
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +7 -6
- 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 +3514 -869
- package/lib/css/syntax.js +6370 -1220
- 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 +14 -5
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- 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/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
- 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 +6 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +124 -102
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- 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 +1 -1
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- 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 +15 -21
- package/lib/dependencies/WorkerDependency.js +7 -7
- package/lib/dependencies/WorkletDependency.js +7 -11
- 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/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/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 +30 -11
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
- 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 +418 -200
- 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 +1618 -1391
- 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 +73 -72
- 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 +137 -9
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +178 -120
- package/lib/optimize/ConstExportsPlugin.js +50 -39
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -123
- 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 +68 -9
- 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 +18 -23
- 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 +98 -66
- 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 +305 -224
- 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/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +16 -16
- 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 +2 -3
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +91 -91
- 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/createHooksRegistry.js +1 -2
- 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 +5 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- 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/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 +379 -66
- 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 +1723 -604
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
|
@@ -39,10 +39,9 @@ module.exports.getTrimmedIdsAndRange = (
|
|
|
39
39
|
);
|
|
40
40
|
let trimmedRange = untrimmedRange;
|
|
41
41
|
if (trimmedIds.length !== untrimmedIds.length) {
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// Use this to find the correct replacement range based on the number of ids that were trimmed.
|
|
42
|
+
// `dep.idRanges` is right-aligned with `dep.names`: the two may differ in
|
|
43
|
+
// length, but their last elements correspond, which is what turns the count
|
|
44
|
+
// of trimmed ids into the replacement range.
|
|
46
45
|
const idx =
|
|
47
46
|
ranges === undefined
|
|
48
47
|
? -1 /* trigger failure case below */
|
package/lib/util/concatenate.js
CHANGED
|
@@ -324,10 +324,10 @@ const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {
|
|
|
324
324
|
}
|
|
325
325
|
};
|
|
326
326
|
|
|
327
|
-
// Declared by the chunk bootstrap in the scope module code is hoisted
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
327
|
+
// WHY: Declared by the chunk bootstrap in the scope module code is hoisted
|
|
328
|
+
// into, so re-bundling a webpack bundle collides with them: the `const` one
|
|
329
|
+
// fails to parse and the `var` one silently clobbers the module table.
|
|
330
|
+
// CompatibilityPlugin renames the other two runtime names.
|
|
331
331
|
const CHUNK_RUNTIME_DECLARATIONS = new Set([
|
|
332
332
|
"__webpack_modules__",
|
|
333
333
|
"__webpack_module_cache__"
|
|
@@ -15,8 +15,7 @@ const createHooksRegistry = (createHooks) => {
|
|
|
15
15
|
return (compilation) => {
|
|
16
16
|
let hooks = map.get(compilation);
|
|
17
17
|
if (hooks === undefined) {
|
|
18
|
-
//
|
|
19
|
-
// codegen. Matched by class name, not `instanceof`: a compilation from
|
|
18
|
+
// Matched by class name rather than `instanceof`: a compilation from
|
|
20
19
|
// another webpack copy has to pass too, and importing `Compilation`
|
|
21
20
|
// here cycles.
|
|
22
21
|
const candidate =
|
package/lib/util/dataURL.js
CHANGED
|
@@ -44,9 +44,8 @@ const decodeDataURI = (uri) => {
|
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
46
|
// `URIRegEx`'s `.` stops at a newline, which a raw `<svg>` payload carries, and
|
|
47
|
-
// its `base64` group
|
|
48
|
-
//
|
|
49
|
-
// module requests are recognized by.
|
|
47
|
+
// its optional `base64` group reads `;charset=utf8` as one. This is the strict
|
|
48
|
+
// split a rewriter needs; that one stays as the matcher for module requests.
|
|
50
49
|
const STRICT_URI_REGEXP = /^data:([^,;]*)((?:;[^,;]*)*),([\s\S]*)$/i;
|
|
51
50
|
|
|
52
51
|
const JSON_TYPE = "json";
|
|
@@ -450,12 +450,11 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
450
450
|
right--;
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
+
// WHY: both sides already clear minSize here.
|
|
453
454
|
// left v v right
|
|
454
455
|
// [ O O O ] O O O [ O O O ]
|
|
455
456
|
// ^^^^^^^^^ leftSize
|
|
456
457
|
// rightSize ^^^^^^^^^
|
|
457
|
-
// leftSize > minSize
|
|
458
|
-
// rightSize > minSize
|
|
459
458
|
|
|
460
459
|
// Perfect split: [ O O O ] [ O O O ]
|
|
461
460
|
// right === left - 1
|
|
@@ -476,26 +475,22 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
476
475
|
queue.push(group);
|
|
477
476
|
continue;
|
|
478
477
|
}
|
|
479
|
-
//
|
|
480
|
-
//
|
|
481
|
-
//
|
|
482
|
-
// To avoid this make sure maxSize > minSize * 3
|
|
478
|
+
// No split holds minSize, which is preferred over maxSize, so these
|
|
479
|
+
// nodes are returned oversized. Keeping maxSize > minSize * 3
|
|
480
|
+
// avoids it.
|
|
483
481
|
result.push(group);
|
|
484
482
|
continue;
|
|
485
483
|
}
|
|
486
484
|
if (left <= right) {
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
// here key space is separated the most
|
|
491
|
-
// But we also need to make sure to not create too small groups
|
|
485
|
+
// In the area between left and right, split at the minimum
|
|
486
|
+
// similarity, where the key space is separated the most — without
|
|
487
|
+
// creating groups that are too small.
|
|
492
488
|
let best = -1;
|
|
493
489
|
let bestSimilarity = Infinity;
|
|
494
490
|
let pos = left;
|
|
495
491
|
const rightSize = sumSize(group.nodes, pos);
|
|
496
492
|
|
|
497
|
-
//
|
|
498
|
-
// [ O O O ] O O O [ O O O ]
|
|
493
|
+
// [ O O O ] O O O [ O O O ] pos, then right
|
|
499
494
|
// ^^^^^^^^^ leftSize
|
|
500
495
|
// rightSize ^^^^^^^^^^^^^^^
|
|
501
496
|
|
|
@@ -125,12 +125,9 @@ module.exports = (items, getDependencies) => {
|
|
|
125
125
|
depSCC.marker = IN_PROGRESS_MARKER;
|
|
126
126
|
break;
|
|
127
127
|
case IN_PROGRESS_MARKER: {
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
// ^ |
|
|
132
|
-
// |_________|
|
|
133
|
-
// If we are at `D` and traverse `D` -> `B`, then `B/C/D` must be in one SCC
|
|
128
|
+
// A back-edge to an SCC still on the stack merges every SCC
|
|
129
|
+
// above it — in `A -> B -> C -> D` with `D -> B`, reaching `B`
|
|
130
|
+
// from `D` puts `B`, `C` and `D` into one SCC.
|
|
134
131
|
/** @type {Set<SCC<T>>} */
|
|
135
132
|
const sccsToMerge = new Set();
|
|
136
133
|
for (
|
|
@@ -162,13 +159,9 @@ module.exports = (items, getDependencies) => {
|
|
|
162
159
|
// All dependencies of the current node have been processed
|
|
163
160
|
// So we leave the node
|
|
164
161
|
stack.pop();
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
// ^ |
|
|
169
|
-
// |_________|
|
|
170
|
-
// If `B` is popped and the new stack top is `A`, they are in
|
|
171
|
-
// different SCCs, so B's SCC can be finalized.
|
|
162
|
+
// An SCC is DONE only once the popped node is its last one on
|
|
163
|
+
// the stack. In `A -> B -> C -> D` with `D -> B`, popping `B` onto a
|
|
164
|
+
// stack topped by `A` — a different SCC — finalizes B's.
|
|
172
165
|
if (
|
|
173
166
|
stack.length &&
|
|
174
167
|
topOfStack.node.scc !== stack[stack.length - 1].node.scc
|
package/lib/util/fs.js
CHANGED
|
@@ -167,7 +167,7 @@ const { ABSOLUTE_PATH_REGEXP } = require("./identifier");
|
|
|
167
167
|
* @typedef {{
|
|
168
168
|
* (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer,
|
|
169
169
|
* (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string,
|
|
170
|
-
* (path: PathOrFileDescriptor, options
|
|
170
|
+
* (path: PathOrFileDescriptor, options: ObjectEncodingOptions & { flag?: string | undefined }): string | Buffer,
|
|
171
171
|
* }} ReadFileSync
|
|
172
172
|
*/
|
|
173
173
|
|
|
@@ -402,6 +402,21 @@ const { ABSOLUTE_PATH_REGEXP } = require("./identifier");
|
|
|
402
402
|
* @typedef {(path: PathLike, options?: BufferEncoding | ReadStreamOptions) => NodeJS.ReadableStream} CreateReadStream
|
|
403
403
|
*/
|
|
404
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Defines the symlink type used by this module.
|
|
407
|
+
* @typedef {(target: PathLike, path: PathLike, type: "dir" | "file" | "junction" | null | undefined, callback: NoParamCallback) => void} Symlink
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Defines the chmod type used by this module.
|
|
412
|
+
* @typedef {(path: PathLike, mode: number | string, callback: NoParamCallback) => void} Chmod
|
|
413
|
+
*/
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Defines the utimes type used by this module.
|
|
417
|
+
* @typedef {(path: PathLike, atime: number | string | Date, mtime: number | string | Date, callback: NoParamCallback) => void} Utimes
|
|
418
|
+
*/
|
|
419
|
+
|
|
405
420
|
/**
|
|
406
421
|
* Defines the output file system type used by this module.
|
|
407
422
|
* @typedef {object} OutputFileSystem
|
|
@@ -410,6 +425,10 @@ const { ABSOLUTE_PATH_REGEXP } = require("./identifier");
|
|
|
410
425
|
* @property {Rmdir=} rmdir
|
|
411
426
|
* @property {WriteFile} writeFile
|
|
412
427
|
* @property {Unlink=} unlink
|
|
428
|
+
* @property {Symlink=} symlink
|
|
429
|
+
* @property {Readlink=} readlink
|
|
430
|
+
* @property {Chmod=} chmod
|
|
431
|
+
* @property {Utimes=} utimes
|
|
413
432
|
* @property {Stat} stat
|
|
414
433
|
* @property {LStat=} lstat
|
|
415
434
|
* @property {ReadFile} readFile
|
|
@@ -755,6 +774,13 @@ const lstatReadlinkAbsolute = (fs, p, callback) => {
|
|
|
755
774
|
*/
|
|
756
775
|
const isAbsolute = (pathname) => ABSOLUTE_PATH_REGEXP.test(pathname);
|
|
757
776
|
|
|
777
|
+
/**
|
|
778
|
+
* What of a file's mode is its permissions — the type bits above them are not
|
|
779
|
+
* settable, and the set-user-id and sticky bits are not carried over a copy.
|
|
780
|
+
*/
|
|
781
|
+
const PERMISSIONS_MASK = 0o777;
|
|
782
|
+
|
|
783
|
+
module.exports.PERMISSIONS_MASK = PERMISSIONS_MASK;
|
|
758
784
|
module.exports.dirname = dirname;
|
|
759
785
|
module.exports.isAbsolute = isAbsolute;
|
|
760
786
|
module.exports.join = join;
|
package/lib/util/globUtils.js
CHANGED
|
@@ -558,7 +558,7 @@ const braceFreeGlobToPathRegExpSource = (glob) => {
|
|
|
558
558
|
* pattern built with `path.resolve` works everywhere; use `[*]` to match a
|
|
559
559
|
* literal `*`), and a relative pattern matches at any depth. Matching follows
|
|
560
560
|
* `path.matchesGlob`, except where its minimatch shows through — see the
|
|
561
|
-
* divergences listed above the corpus in `test/globUtils.unittest.js`.
|
|
561
|
+
* divergences listed above the corpus in `test/unitCases/globUtils.unittest.js`.
|
|
562
562
|
* @param {string} pattern glob pattern
|
|
563
563
|
* @param {GlobMatchOptions=} options options
|
|
564
564
|
* @returns {((str: string) => boolean) | null} matcher, null for un-compilable patterns
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
/** @import RuntimeModule from "../RuntimeModule" */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The one key a chunk's runtime modules install on a handler map, or `null` when
|
|
11
|
+
* they install several, none, or one a module could not name. Every module states
|
|
12
|
+
* what it installs, so nothing has to be rendered to find out.
|
|
13
|
+
* @param {RuntimeModule} runtimeModule the runtime module rendering the dispatch
|
|
14
|
+
* @param {string} handlers the handler map global
|
|
15
|
+
* @returns {string | null} the sole handler key, or `null`
|
|
16
|
+
*/
|
|
17
|
+
const getOnlyHandlerKey = (runtimeModule, handlers) => {
|
|
18
|
+
const { chunkGraph, chunk } = runtimeModule;
|
|
19
|
+
if (chunkGraph === undefined || chunk === undefined) return null;
|
|
20
|
+
/** @type {string | null} */
|
|
21
|
+
let only = null;
|
|
22
|
+
for (const module of chunkGraph.getChunkRuntimeModulesIterable(chunk)) {
|
|
23
|
+
// TODO webpack 6: call it directly, every runtime module answers by then. A
|
|
24
|
+
// module built against an older webpack extends a base class without it.
|
|
25
|
+
const installed =
|
|
26
|
+
typeof module.getInstalledChunkHandlers === "function"
|
|
27
|
+
? module.getInstalledChunkHandlers()
|
|
28
|
+
: null;
|
|
29
|
+
// A module that cannot name what it installs leaves every map unknowable.
|
|
30
|
+
if (!Array.isArray(installed)) return null;
|
|
31
|
+
for (const [map, key] of installed) {
|
|
32
|
+
if (map !== handlers) continue;
|
|
33
|
+
if (only !== null && only !== key) return null;
|
|
34
|
+
only = key;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return only;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports.getOnlyHandlerKey = getOnlyHandlerKey;
|
|
@@ -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": () =>
|
|
@@ -257,7 +262,6 @@ module.exports = {
|
|
|
257
262
|
"wasm-async/AsyncWasmModule": () => require("../wasm-async/AsyncWasmModule"),
|
|
258
263
|
"wasm-sync/SyncWasmModule": () => require("../wasm-sync/SyncWasmModule"),
|
|
259
264
|
AsyncDependenciesBlock: () => require("../AsyncDependenciesBlock"),
|
|
260
|
-
ContextModule: () => require("../ContextModule"),
|
|
261
265
|
CssModule: () => require("../css/CssModule"),
|
|
262
266
|
DependenciesBlock: () => require("../DependenciesBlock"),
|
|
263
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/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
|
|
@@ -56,6 +56,15 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
|
|
|
56
56
|
this.supportsStreaming = supportsStreaming;
|
|
57
57
|
}
|
|
58
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
|
+
|
|
59
68
|
/**
|
|
60
69
|
* Generates runtime code for this runtime module.
|
|
61
70
|
* @returns {string | null} runtime code
|
|
@@ -57,6 +57,15 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
57
57
|
this.supportsStreaming = supportsStreaming;
|
|
58
58
|
}
|
|
59
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
|
+
|
|
60
69
|
/**
|
|
61
70
|
* Generates runtime code for this runtime module.
|
|
62
71
|
* @returns {string | null} runtime code
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -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
|