webpack 5.92.1 → 5.94.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +36 -21
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +76 -69
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +104 -64
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +132 -70
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +12 -10
- package/lib/UseStrictPlugin.js +8 -1
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +89 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +14 -19
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +31 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +39 -40
- package/lib/css/CssGenerator.js +11 -14
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +72 -9
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +68 -21
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +41 -16
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +11 -12
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +6 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -11
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +97 -70
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +9 -11
- package/lib/library/EnableLibraryPlugin.js +25 -15
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +144 -0
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +144 -61
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedModule.js +19 -14
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +108 -141
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +1 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +10 -13
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +31 -31
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +103 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +17 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +682 -347
package/lib/util/runtime.js
CHANGED
@@ -19,7 +19,7 @@ const SortableSet = require("./SortableSet");
|
|
19
19
|
* @param {EntryOptions=} options optionally already received entry options
|
20
20
|
* @returns {RuntimeSpec} runtime
|
21
21
|
*/
|
22
|
-
exports.getEntryRuntime = (compilation, name, options) => {
|
22
|
+
module.exports.getEntryRuntime = (compilation, name, options) => {
|
23
23
|
let dependOn;
|
24
24
|
let runtime;
|
25
25
|
if (options) {
|
@@ -31,7 +31,7 @@ exports.getEntryRuntime = (compilation, name, options) => {
|
|
31
31
|
}
|
32
32
|
if (dependOn) {
|
33
33
|
/** @type {RuntimeSpec} */
|
34
|
-
let result
|
34
|
+
let result;
|
35
35
|
const queue = new Set(dependOn);
|
36
36
|
for (const name of queue) {
|
37
37
|
const dep = compilation.entries.get(name);
|
@@ -46,9 +46,8 @@ exports.getEntryRuntime = (compilation, name, options) => {
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
return result || name;
|
49
|
-
} else {
|
50
|
-
return runtime || name;
|
51
49
|
}
|
50
|
+
return runtime || name;
|
52
51
|
};
|
53
52
|
|
54
53
|
/**
|
@@ -69,7 +68,7 @@ const forEachRuntime = (runtime, fn, deterministicOrder = false) => {
|
|
69
68
|
}
|
70
69
|
}
|
71
70
|
};
|
72
|
-
exports.forEachRuntime = forEachRuntime;
|
71
|
+
module.exports.forEachRuntime = forEachRuntime;
|
73
72
|
|
74
73
|
/**
|
75
74
|
* @template T
|
@@ -90,19 +89,19 @@ const getRuntimeKey = runtime => {
|
|
90
89
|
if (typeof runtime === "string") return runtime;
|
91
90
|
return runtime.getFromUnorderedCache(getRuntimesKey);
|
92
91
|
};
|
93
|
-
exports.getRuntimeKey = getRuntimeKey;
|
92
|
+
module.exports.getRuntimeKey = getRuntimeKey;
|
94
93
|
|
95
94
|
/**
|
96
95
|
* @param {string} key key of runtimes
|
97
96
|
* @returns {RuntimeSpec} runtime(s)
|
98
97
|
*/
|
99
98
|
const keyToRuntime = key => {
|
100
|
-
if (key === "*") return
|
99
|
+
if (key === "*") return;
|
101
100
|
const items = key.split("\n");
|
102
101
|
if (items.length === 1) return items[0];
|
103
102
|
return new SortableSet(items);
|
104
103
|
};
|
105
|
-
exports.keyToRuntime = keyToRuntime;
|
104
|
+
module.exports.keyToRuntime = keyToRuntime;
|
106
105
|
|
107
106
|
/**
|
108
107
|
* @template T
|
@@ -123,13 +122,13 @@ const runtimeToString = runtime => {
|
|
123
122
|
if (typeof runtime === "string") return runtime;
|
124
123
|
return runtime.getFromUnorderedCache(getRuntimesString);
|
125
124
|
};
|
126
|
-
exports.runtimeToString = runtimeToString;
|
125
|
+
module.exports.runtimeToString = runtimeToString;
|
127
126
|
|
128
127
|
/**
|
129
128
|
* @param {RuntimeCondition} runtimeCondition runtime condition
|
130
129
|
* @returns {string} readable version
|
131
130
|
*/
|
132
|
-
exports.runtimeConditionToString = runtimeCondition => {
|
131
|
+
module.exports.runtimeConditionToString = runtimeCondition => {
|
133
132
|
if (runtimeCondition === true) return "true";
|
134
133
|
if (runtimeCondition === false) return "false";
|
135
134
|
return runtimeToString(runtimeCondition);
|
@@ -152,40 +151,38 @@ const runtimeEqual = (a, b) => {
|
|
152
151
|
return false;
|
153
152
|
} else if (a.size !== b.size) {
|
154
153
|
return false;
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
}
|
154
|
+
}
|
155
|
+
a.sort();
|
156
|
+
b.sort();
|
157
|
+
const aIt = a[Symbol.iterator]();
|
158
|
+
const bIt = b[Symbol.iterator]();
|
159
|
+
for (;;) {
|
160
|
+
const aV = aIt.next();
|
161
|
+
if (aV.done) return true;
|
162
|
+
const bV = bIt.next();
|
163
|
+
if (aV.value !== bV.value) return false;
|
166
164
|
}
|
167
165
|
};
|
168
|
-
exports.runtimeEqual = runtimeEqual;
|
166
|
+
module.exports.runtimeEqual = runtimeEqual;
|
169
167
|
|
170
168
|
/**
|
171
169
|
* @param {RuntimeSpec} a first
|
172
170
|
* @param {RuntimeSpec} b second
|
173
171
|
* @returns {-1|0|1} compare
|
174
172
|
*/
|
175
|
-
exports.compareRuntime = (a, b) => {
|
173
|
+
module.exports.compareRuntime = (a, b) => {
|
176
174
|
if (a === b) {
|
177
175
|
return 0;
|
178
176
|
} else if (a === undefined) {
|
179
177
|
return -1;
|
180
178
|
} else if (b === undefined) {
|
181
179
|
return 1;
|
182
|
-
} else {
|
183
|
-
const aKey = getRuntimeKey(a);
|
184
|
-
const bKey = getRuntimeKey(b);
|
185
|
-
if (aKey < bKey) return -1;
|
186
|
-
if (aKey > bKey) return 1;
|
187
|
-
return 0;
|
188
180
|
}
|
181
|
+
const aKey = getRuntimeKey(a);
|
182
|
+
const bKey = getRuntimeKey(b);
|
183
|
+
if (aKey < bKey) return -1;
|
184
|
+
if (aKey > bKey) return 1;
|
185
|
+
return 0;
|
189
186
|
};
|
190
187
|
|
191
188
|
/**
|
@@ -208,26 +205,23 @@ const mergeRuntime = (a, b) => {
|
|
208
205
|
return set;
|
209
206
|
} else if (b.has(a)) {
|
210
207
|
return b;
|
211
|
-
} else {
|
212
|
-
const set = new SortableSet(b);
|
213
|
-
set.add(a);
|
214
|
-
return set;
|
215
|
-
}
|
216
|
-
} else {
|
217
|
-
if (typeof b === "string") {
|
218
|
-
if (a.has(b)) return a;
|
219
|
-
const set = new SortableSet(a);
|
220
|
-
set.add(b);
|
221
|
-
return set;
|
222
|
-
} else {
|
223
|
-
const set = new SortableSet(a);
|
224
|
-
for (const item of b) set.add(item);
|
225
|
-
if (set.size === a.size) return a;
|
226
|
-
return set;
|
227
208
|
}
|
209
|
+
const set = new SortableSet(b);
|
210
|
+
set.add(a);
|
211
|
+
return set;
|
228
212
|
}
|
213
|
+
if (typeof b === "string") {
|
214
|
+
if (a.has(b)) return a;
|
215
|
+
const set = new SortableSet(a);
|
216
|
+
set.add(b);
|
217
|
+
return set;
|
218
|
+
}
|
219
|
+
const set = new SortableSet(a);
|
220
|
+
for (const item of b) set.add(item);
|
221
|
+
if (set.size === a.size) return a;
|
222
|
+
return set;
|
229
223
|
};
|
230
|
-
exports.mergeRuntime = mergeRuntime;
|
224
|
+
module.exports.mergeRuntime = mergeRuntime;
|
231
225
|
|
232
226
|
/**
|
233
227
|
* @param {RuntimeCondition} a first
|
@@ -235,12 +229,12 @@ exports.mergeRuntime = mergeRuntime;
|
|
235
229
|
* @param {RuntimeSpec} runtime full runtime
|
236
230
|
* @returns {RuntimeCondition} result
|
237
231
|
*/
|
238
|
-
exports.mergeRuntimeCondition = (a, b, runtime) => {
|
232
|
+
module.exports.mergeRuntimeCondition = (a, b, runtime) => {
|
239
233
|
if (a === false) return b;
|
240
234
|
if (b === false) return a;
|
241
235
|
if (a === true || b === true) return true;
|
242
236
|
const merged = mergeRuntime(a, b);
|
243
|
-
if (merged === undefined) return
|
237
|
+
if (merged === undefined) return;
|
244
238
|
if (typeof merged === "string") {
|
245
239
|
if (typeof runtime === "string" && merged === runtime) return true;
|
246
240
|
return merged;
|
@@ -256,10 +250,10 @@ exports.mergeRuntimeCondition = (a, b, runtime) => {
|
|
256
250
|
* @param {RuntimeSpec} runtime full runtime
|
257
251
|
* @returns {RuntimeSpec | true} result
|
258
252
|
*/
|
259
|
-
exports.mergeRuntimeConditionNonFalse = (a, b, runtime) => {
|
253
|
+
module.exports.mergeRuntimeConditionNonFalse = (a, b, runtime) => {
|
260
254
|
if (a === true || b === true) return true;
|
261
255
|
const merged = mergeRuntime(a, b);
|
262
|
-
if (merged === undefined) return
|
256
|
+
if (merged === undefined) return;
|
263
257
|
if (typeof merged === "string") {
|
264
258
|
if (typeof runtime === "string" && merged === runtime) return true;
|
265
259
|
return merged;
|
@@ -282,38 +276,34 @@ const mergeRuntimeOwned = (a, b) => {
|
|
282
276
|
} else if (a === undefined) {
|
283
277
|
if (typeof b === "string") {
|
284
278
|
return b;
|
285
|
-
} else {
|
286
|
-
return new SortableSet(b);
|
287
279
|
}
|
280
|
+
return new SortableSet(b);
|
288
281
|
} else if (typeof a === "string") {
|
289
282
|
if (typeof b === "string") {
|
290
283
|
const set = new SortableSet();
|
291
284
|
set.add(a);
|
292
285
|
set.add(b);
|
293
286
|
return set;
|
294
|
-
} else {
|
295
|
-
const set = new SortableSet(b);
|
296
|
-
set.add(a);
|
297
|
-
return set;
|
298
|
-
}
|
299
|
-
} else {
|
300
|
-
if (typeof b === "string") {
|
301
|
-
a.add(b);
|
302
|
-
return a;
|
303
|
-
} else {
|
304
|
-
for (const item of b) a.add(item);
|
305
|
-
return a;
|
306
287
|
}
|
288
|
+
const set = new SortableSet(b);
|
289
|
+
set.add(a);
|
290
|
+
return set;
|
307
291
|
}
|
292
|
+
if (typeof b === "string") {
|
293
|
+
a.add(b);
|
294
|
+
return a;
|
295
|
+
}
|
296
|
+
for (const item of b) a.add(item);
|
297
|
+
return a;
|
308
298
|
};
|
309
|
-
exports.mergeRuntimeOwned = mergeRuntimeOwned;
|
299
|
+
module.exports.mergeRuntimeOwned = mergeRuntimeOwned;
|
310
300
|
|
311
301
|
/**
|
312
302
|
* @param {RuntimeSpec} a first
|
313
303
|
* @param {RuntimeSpec} b second
|
314
304
|
* @returns {RuntimeSpec} merged
|
315
305
|
*/
|
316
|
-
exports.intersectRuntime = (a, b) => {
|
306
|
+
module.exports.intersectRuntime = (a, b) => {
|
317
307
|
if (a === undefined) {
|
318
308
|
return b;
|
319
309
|
} else if (b === undefined) {
|
@@ -322,26 +312,26 @@ exports.intersectRuntime = (a, b) => {
|
|
322
312
|
return a;
|
323
313
|
} else if (typeof a === "string") {
|
324
314
|
if (typeof b === "string") {
|
325
|
-
return
|
315
|
+
return;
|
326
316
|
} else if (b.has(a)) {
|
327
317
|
return a;
|
328
|
-
} else {
|
329
|
-
return undefined;
|
330
|
-
}
|
331
|
-
} else {
|
332
|
-
if (typeof b === "string") {
|
333
|
-
if (a.has(b)) return b;
|
334
|
-
return undefined;
|
335
|
-
} else {
|
336
|
-
const set = new SortableSet();
|
337
|
-
for (const item of b) {
|
338
|
-
if (a.has(item)) set.add(item);
|
339
|
-
}
|
340
|
-
if (set.size === 0) return undefined;
|
341
|
-
if (set.size === 1) for (const item of set) return item;
|
342
|
-
return set;
|
343
318
|
}
|
319
|
+
return;
|
320
|
+
}
|
321
|
+
if (typeof b === "string") {
|
322
|
+
if (a.has(b)) return b;
|
323
|
+
return;
|
324
|
+
}
|
325
|
+
const set = new SortableSet();
|
326
|
+
for (const item of b) {
|
327
|
+
if (a.has(item)) set.add(item);
|
344
328
|
}
|
329
|
+
if (set.size === 0) return;
|
330
|
+
if (set.size === 1) {
|
331
|
+
const [item] = set;
|
332
|
+
return item;
|
333
|
+
}
|
334
|
+
return set;
|
345
335
|
};
|
346
336
|
|
347
337
|
/**
|
@@ -351,42 +341,42 @@ exports.intersectRuntime = (a, b) => {
|
|
351
341
|
*/
|
352
342
|
const subtractRuntime = (a, b) => {
|
353
343
|
if (a === undefined) {
|
354
|
-
return
|
344
|
+
return;
|
355
345
|
} else if (b === undefined) {
|
356
346
|
return a;
|
357
347
|
} else if (a === b) {
|
358
|
-
return
|
348
|
+
return;
|
359
349
|
} else if (typeof a === "string") {
|
360
350
|
if (typeof b === "string") {
|
361
351
|
return a;
|
362
352
|
} else if (b.has(a)) {
|
363
|
-
return
|
364
|
-
} else {
|
365
|
-
return a;
|
353
|
+
return;
|
366
354
|
}
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
if (item !== b) return item;
|
373
|
-
}
|
374
|
-
}
|
375
|
-
const set = new SortableSet(a);
|
376
|
-
set.delete(b);
|
377
|
-
return set;
|
378
|
-
} else {
|
379
|
-
const set = new SortableSet();
|
355
|
+
return a;
|
356
|
+
}
|
357
|
+
if (typeof b === "string") {
|
358
|
+
if (!a.has(b)) return a;
|
359
|
+
if (a.size === 2) {
|
380
360
|
for (const item of a) {
|
381
|
-
if (
|
361
|
+
if (item !== b) return item;
|
382
362
|
}
|
383
|
-
if (set.size === 0) return undefined;
|
384
|
-
if (set.size === 1) for (const item of set) return item;
|
385
|
-
return set;
|
386
363
|
}
|
364
|
+
const set = new SortableSet(a);
|
365
|
+
set.delete(b);
|
366
|
+
return set;
|
387
367
|
}
|
368
|
+
const set = new SortableSet();
|
369
|
+
for (const item of a) {
|
370
|
+
if (!b.has(item)) set.add(item);
|
371
|
+
}
|
372
|
+
if (set.size === 0) return;
|
373
|
+
if (set.size === 1) {
|
374
|
+
const [item] = set;
|
375
|
+
return item;
|
376
|
+
}
|
377
|
+
return set;
|
388
378
|
};
|
389
|
-
exports.subtractRuntime = subtractRuntime;
|
379
|
+
module.exports.subtractRuntime = subtractRuntime;
|
390
380
|
|
391
381
|
/**
|
392
382
|
* @param {RuntimeCondition} a first
|
@@ -394,7 +384,7 @@ exports.subtractRuntime = subtractRuntime;
|
|
394
384
|
* @param {RuntimeSpec} runtime runtime
|
395
385
|
* @returns {RuntimeCondition} result
|
396
386
|
*/
|
397
|
-
exports.subtractRuntimeCondition = (a, b, runtime) => {
|
387
|
+
module.exports.subtractRuntimeCondition = (a, b, runtime) => {
|
398
388
|
if (b === true) return false;
|
399
389
|
if (b === false) return a;
|
400
390
|
if (a === false) return false;
|
@@ -404,15 +394,15 @@ exports.subtractRuntimeCondition = (a, b, runtime) => {
|
|
404
394
|
|
405
395
|
/**
|
406
396
|
* @param {RuntimeSpec} runtime runtime
|
407
|
-
* @param {function(RuntimeSpec): boolean} filter filter function
|
397
|
+
* @param {function(RuntimeSpec=): boolean} filter filter function
|
408
398
|
* @returns {boolean | RuntimeSpec} true/false if filter is constant for all runtimes, otherwise runtimes that are active
|
409
399
|
*/
|
410
|
-
exports.filterRuntime = (runtime, filter) => {
|
411
|
-
if (runtime === undefined) return filter(
|
400
|
+
module.exports.filterRuntime = (runtime, filter) => {
|
401
|
+
if (runtime === undefined) return filter();
|
412
402
|
if (typeof runtime === "string") return filter(runtime);
|
413
403
|
let some = false;
|
414
404
|
let every = true;
|
415
|
-
let result
|
405
|
+
let result;
|
416
406
|
for (const r of runtime) {
|
417
407
|
const v = filter(r);
|
418
408
|
if (v) {
|
@@ -456,7 +446,7 @@ class RuntimeSpecMap {
|
|
456
446
|
get(runtime) {
|
457
447
|
switch (this._mode) {
|
458
448
|
case 0:
|
459
|
-
return
|
449
|
+
return;
|
460
450
|
case 1:
|
461
451
|
return runtimeEqual(this._singleRuntime, runtime)
|
462
452
|
? this._singleValue
|
@@ -645,7 +635,7 @@ class RuntimeSpecMap {
|
|
645
635
|
}
|
646
636
|
}
|
647
637
|
|
648
|
-
exports.RuntimeSpecMap = RuntimeSpecMap;
|
638
|
+
module.exports.RuntimeSpecMap = RuntimeSpecMap;
|
649
639
|
|
650
640
|
class RuntimeSpecSet {
|
651
641
|
/**
|
@@ -685,4 +675,4 @@ class RuntimeSpecSet {
|
|
685
675
|
}
|
686
676
|
}
|
687
677
|
|
688
|
-
exports.RuntimeSpecSet = RuntimeSpecSet;
|
678
|
+
module.exports.RuntimeSpecSet = RuntimeSpecSet;
|
package/lib/util/semver.js
CHANGED
@@ -32,7 +32,7 @@ const parseVersion = str => {
|
|
32
32
|
}
|
33
33
|
return ver;
|
34
34
|
};
|
35
|
-
exports.parseVersion = parseVersion;
|
35
|
+
module.exports.parseVersion = parseVersion;
|
36
36
|
|
37
37
|
/* eslint-disable eqeqeq */
|
38
38
|
/**
|
@@ -82,13 +82,13 @@ const versionLt = (a, b) => {
|
|
82
82
|
}
|
83
83
|
};
|
84
84
|
/* eslint-enable eqeqeq */
|
85
|
-
exports.versionLt = versionLt;
|
85
|
+
module.exports.versionLt = versionLt;
|
86
86
|
|
87
87
|
/**
|
88
88
|
* @param {string} str range string
|
89
89
|
* @returns {SemVerRange} parsed range
|
90
90
|
*/
|
91
|
-
exports.parseRange = str => {
|
91
|
+
module.exports.parseRange = str => {
|
92
92
|
const splitAndConvert = str => {
|
93
93
|
return str
|
94
94
|
.split(".")
|
@@ -126,9 +126,9 @@ exports.parseRange = str => {
|
|
126
126
|
} else if (range.length === 3) {
|
127
127
|
// Special case for "1.2" is "1.2.x" instead of "=1.2"
|
128
128
|
return [2, ...range.slice(1)];
|
129
|
-
} else {
|
130
|
-
return [range.length, ...range.slice(1)];
|
131
129
|
}
|
130
|
+
|
131
|
+
return [range.length, ...range.slice(1)];
|
132
132
|
};
|
133
133
|
const negate = range => {
|
134
134
|
return [-range[0] - 1, ...range.slice(1)];
|
@@ -256,30 +256,31 @@ const rangeToString = range => {
|
|
256
256
|
(needDot > 0 ? "." : "") + ((needDot = 2), item);
|
257
257
|
}
|
258
258
|
return str;
|
259
|
-
}
|
260
|
-
|
259
|
+
}
|
260
|
+
/** @type {string[]} */
|
261
|
+
var stack = [];
|
262
|
+
// eslint-disable-next-line no-redeclare
|
263
|
+
for (var i = 1; i < range.length; i++) {
|
261
264
|
// eslint-disable-next-line no-redeclare
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
item ===
|
267
|
-
? "
|
268
|
-
: item ===
|
269
|
-
?
|
270
|
-
: item
|
271
|
-
|
272
|
-
: rangeToString(item)
|
273
|
-
);
|
274
|
-
}
|
275
|
-
return pop();
|
265
|
+
var item = range[i];
|
266
|
+
stack.push(
|
267
|
+
item === 0
|
268
|
+
? "not(" + pop() + ")"
|
269
|
+
: item === 1
|
270
|
+
? "(" + pop() + " || " + pop() + ")"
|
271
|
+
: item === 2
|
272
|
+
? stack.pop() + " " + stack.pop()
|
273
|
+
: rangeToString(item)
|
274
|
+
);
|
276
275
|
}
|
276
|
+
return pop();
|
277
|
+
|
277
278
|
function pop() {
|
278
|
-
return stack.pop().replace(/^\((.+)\)$/, "$1");
|
279
|
+
return /** @type {string} */ (stack.pop()).replace(/^\((.+)\)$/, "$1");
|
279
280
|
}
|
280
281
|
};
|
281
282
|
/* eslint-enable eqeqeq */
|
282
|
-
exports.rangeToString = rangeToString;
|
283
|
+
module.exports.rangeToString = rangeToString;
|
283
284
|
|
284
285
|
/* eslint-disable eqeqeq */
|
285
286
|
/**
|
@@ -399,6 +400,7 @@ const satisfy = (range, version) => {
|
|
399
400
|
}
|
400
401
|
} else {
|
401
402
|
// Handles all "next-ver" cases in the second table
|
403
|
+
// eslint-disable-next-line no-lonely-if
|
402
404
|
if (rangeType != "s" && rangeType != "n") {
|
403
405
|
isEqual = false;
|
404
406
|
j--;
|
@@ -427,9 +429,9 @@ const satisfy = (range, version) => {
|
|
427
429
|
return !!p();
|
428
430
|
};
|
429
431
|
/* eslint-enable eqeqeq */
|
430
|
-
exports.satisfy = satisfy;
|
432
|
+
module.exports.satisfy = satisfy;
|
431
433
|
|
432
|
-
exports.stringifyHoley = json => {
|
434
|
+
module.exports.stringifyHoley = json => {
|
433
435
|
switch (typeof json) {
|
434
436
|
case "undefined":
|
435
437
|
return "";
|
@@ -442,9 +444,9 @@ exports.stringifyHoley = json => {
|
|
442
444
|
}
|
443
445
|
str += "]";
|
444
446
|
return str;
|
445
|
-
} else {
|
446
|
-
return JSON.stringify(json);
|
447
447
|
}
|
448
|
+
|
449
|
+
return JSON.stringify(json);
|
448
450
|
default:
|
449
451
|
return JSON.stringify(json);
|
450
452
|
}
|
@@ -39,7 +39,11 @@ const registerSerializers = memoize(() => {
|
|
39
39
|
// This allows bundling all internal serializers
|
40
40
|
const internalSerializables = require("./internalSerializables");
|
41
41
|
getObjectMiddleware().registerLoader(/^webpack\/lib\//, req => {
|
42
|
-
const loader =
|
42
|
+
const loader =
|
43
|
+
internalSerializables[
|
44
|
+
/** @type {keyof import("./internalSerializables")} */
|
45
|
+
(req.slice("webpack/lib/".length))
|
46
|
+
];
|
43
47
|
if (loader) {
|
44
48
|
loader();
|
45
49
|
} else {
|
@@ -88,6 +92,9 @@ module.exports = {
|
|
88
92
|
new SingleItemMiddleware(),
|
89
93
|
new (getObjectMiddleware())(context => {
|
90
94
|
if (context.write) {
|
95
|
+
/**
|
96
|
+
* @param {any} value value
|
97
|
+
*/
|
91
98
|
context.writeLazy = value => {
|
92
99
|
context.write(
|
93
100
|
SerializerMiddleware.createLazy(value, binaryMiddleware)
|
@@ -115,11 +122,19 @@ module.exports = {
|
|
115
122
|
new SingleItemMiddleware(),
|
116
123
|
new (getObjectMiddleware())(context => {
|
117
124
|
if (context.write) {
|
125
|
+
/**
|
126
|
+
* @param {any} value value
|
127
|
+
*/
|
118
128
|
context.writeLazy = value => {
|
119
129
|
context.write(
|
120
130
|
SerializerMiddleware.createLazy(value, binaryMiddleware)
|
121
131
|
);
|
122
132
|
};
|
133
|
+
/**
|
134
|
+
* @param {any} value value
|
135
|
+
* @param {object=} options lazy options
|
136
|
+
* @returns {function(): Promise<any> | any} lazy function
|
137
|
+
*/
|
123
138
|
context.writeSeparate = (value, options) => {
|
124
139
|
const lazy = SerializerMiddleware.createLazy(
|
125
140
|
value,
|
@@ -16,7 +16,7 @@
|
|
16
16
|
* @template T
|
17
17
|
* @template R
|
18
18
|
* @typedef {object} GroupConfig
|
19
|
-
* @property {function(T): string[]} getKeys
|
19
|
+
* @property {function(T): string[] | undefined} getKeys
|
20
20
|
* @property {function(string, (R | T)[], T[]): R} createGroup
|
21
21
|
* @property {function(string, T[]): GroupOptions=} getOptions
|
22
22
|
*/
|
@@ -111,10 +111,10 @@ const smartGrouping = (items, groupConfigs) => {
|
|
111
111
|
const results = [];
|
112
112
|
for (;;) {
|
113
113
|
/** @type {Group<T, R> | undefined} */
|
114
|
-
let bestGroup
|
114
|
+
let bestGroup;
|
115
115
|
let bestGroupSize = -1;
|
116
|
-
let bestGroupItems
|
117
|
-
let bestGroupOptions
|
116
|
+
let bestGroupItems;
|
117
|
+
let bestGroupOptions;
|
118
118
|
for (const [group, state] of groupMap) {
|
119
119
|
const { items, used } = state;
|
120
120
|
let options = state.options;
|
@@ -138,7 +138,7 @@ const smartGrouping = (items, groupConfigs) => {
|
|
138
138
|
}
|
139
139
|
}
|
140
140
|
const targetGroupCount = (options && options.targetGroupCount) || 4;
|
141
|
-
|
141
|
+
const sizeValue = force
|
142
142
|
? items.size
|
143
143
|
: Math.min(
|
144
144
|
items.size,
|
package/lib/util/source.js
CHANGED
@@ -52,10 +52,11 @@ class EnableWasmLoadingPlugin {
|
|
52
52
|
throw new Error(
|
53
53
|
`Library type "${type}" is not enabled. ` +
|
54
54
|
"EnableWasmLoadingPlugin need to be used to enable this type of wasm loading. " +
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
`This usually happens through the "output.enabledWasmLoadingTypes" option. ` +
|
56
|
+
`If you are using a function as entry which sets "wasmLoading", you need to add all potential library types to "output.enabledWasmLoadingTypes". ` +
|
57
|
+
`These types are enabled: ${Array.from(
|
58
|
+
getEnabledTypes(compiler)
|
59
|
+
).join(", ")}`
|
59
60
|
);
|
60
61
|
}
|
61
62
|
}
|
@@ -81,10 +81,10 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
81
81
|
Template.indent([
|
82
82
|
".then(",
|
83
83
|
Template.indent([
|
84
|
-
runtimeTemplate.returningFunction(
|
84
|
+
`${runtimeTemplate.returningFunction(
|
85
85
|
"Object.assign(exports, res.instance.exports)",
|
86
86
|
"res"
|
87
|
-
)
|
87
|
+
)},`,
|
88
88
|
runtimeTemplate.basicFunction("e", [
|
89
89
|
`if(res.headers.get("Content-Type") !== "application/wasm") {`,
|
90
90
|
Template.indent([
|
@@ -110,7 +110,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
110
110
|
"exports, wasmModuleId, wasmModuleHash, importsObj",
|
111
111
|
this.supportsStreaming
|
112
112
|
? getStreaming()
|
113
|
-
: [`return ${loader}`, Template.indent(fallback)
|
113
|
+
: [`return ${loader}`, `${Template.indent(fallback)};`]
|
114
114
|
)};`;
|
115
115
|
}
|
116
116
|
}
|
@@ -161,12 +161,11 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
161
161
|
])
|
162
162
|
: undefined;
|
163
163
|
|
164
|
-
const instantiateCall =
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
)}` + (importsObj ? `, ${importsObj})` : `)`);
|
164
|
+
const instantiateCall = `${RuntimeGlobals.instantiateWasm}(${module.exportsArgument}, ${
|
165
|
+
module.moduleArgument
|
166
|
+
}.id, ${JSON.stringify(
|
167
|
+
chunkGraph.getRenderedModuleHash(module, runtime)
|
168
|
+
)}${importsObj ? `, ${importsObj})` : ")"}`;
|
170
169
|
|
171
170
|
if (promises.length > 0)
|
172
171
|
runtimeRequirements.add(RuntimeGlobals.asyncModule);
|
@@ -208,9 +208,9 @@ class AsyncWebAssemblyModulesPlugin {
|
|
208
208
|
hooks.renderModuleContent.call(moduleSource, module, renderContext),
|
209
209
|
"AsyncWebAssemblyModulesPlugin.getCompilationHooks().renderModuleContent"
|
210
210
|
);
|
211
|
-
} catch (
|
212
|
-
/** @type {WebpackError} */ (
|
213
|
-
throw
|
211
|
+
} catch (err) {
|
212
|
+
/** @type {WebpackError} */ (err).module = module;
|
213
|
+
throw err;
|
214
214
|
}
|
215
215
|
}
|
216
216
|
}
|