webpack 5.99.9 → 5.100.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/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +6 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +1 -1
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +29 -19
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +6 -3
- package/lib/rules/UseEffectRulePlugin.js +3 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +4 -2
- package/lib/stats/StatsPrinter.js +3 -2
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +12 -8
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1230 -360
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
|
-
|
|
22
|
+
const getEntryRuntime = (compilation, name, options) => {
|
|
23
23
|
let dependOn;
|
|
24
24
|
let runtime;
|
|
25
25
|
if (options) {
|
|
@@ -68,7 +68,6 @@ const forEachRuntime = (runtime, fn, deterministicOrder = false) => {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
module.exports.forEachRuntime = forEachRuntime;
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
73
|
* @template T
|
|
@@ -77,7 +76,7 @@ module.exports.forEachRuntime = forEachRuntime;
|
|
|
77
76
|
*/
|
|
78
77
|
const getRuntimesKey = set => {
|
|
79
78
|
set.sort();
|
|
80
|
-
return
|
|
79
|
+
return [...set].join("\n");
|
|
81
80
|
};
|
|
82
81
|
|
|
83
82
|
/**
|
|
@@ -89,7 +88,6 @@ const getRuntimeKey = runtime => {
|
|
|
89
88
|
if (typeof runtime === "string") return runtime;
|
|
90
89
|
return runtime.getFromUnorderedCache(getRuntimesKey);
|
|
91
90
|
};
|
|
92
|
-
module.exports.getRuntimeKey = getRuntimeKey;
|
|
93
91
|
|
|
94
92
|
/**
|
|
95
93
|
* @param {string} key key of runtimes
|
|
@@ -101,7 +99,6 @@ const keyToRuntime = key => {
|
|
|
101
99
|
if (items.length === 1) return items[0];
|
|
102
100
|
return new SortableSet(items);
|
|
103
101
|
};
|
|
104
|
-
module.exports.keyToRuntime = keyToRuntime;
|
|
105
102
|
|
|
106
103
|
/**
|
|
107
104
|
* @template T
|
|
@@ -110,7 +107,7 @@ module.exports.keyToRuntime = keyToRuntime;
|
|
|
110
107
|
*/
|
|
111
108
|
const getRuntimesString = set => {
|
|
112
109
|
set.sort();
|
|
113
|
-
return
|
|
110
|
+
return [...set].join("+");
|
|
114
111
|
};
|
|
115
112
|
|
|
116
113
|
/**
|
|
@@ -122,13 +119,12 @@ const runtimeToString = runtime => {
|
|
|
122
119
|
if (typeof runtime === "string") return runtime;
|
|
123
120
|
return runtime.getFromUnorderedCache(getRuntimesString);
|
|
124
121
|
};
|
|
125
|
-
module.exports.runtimeToString = runtimeToString;
|
|
126
122
|
|
|
127
123
|
/**
|
|
128
124
|
* @param {RuntimeCondition} runtimeCondition runtime condition
|
|
129
125
|
* @returns {string} readable version
|
|
130
126
|
*/
|
|
131
|
-
|
|
127
|
+
const runtimeConditionToString = runtimeCondition => {
|
|
132
128
|
if (runtimeCondition === true) return "true";
|
|
133
129
|
if (runtimeCondition === false) return "false";
|
|
134
130
|
return runtimeToString(runtimeCondition);
|
|
@@ -163,14 +159,13 @@ const runtimeEqual = (a, b) => {
|
|
|
163
159
|
if (aV.value !== bV.value) return false;
|
|
164
160
|
}
|
|
165
161
|
};
|
|
166
|
-
module.exports.runtimeEqual = runtimeEqual;
|
|
167
162
|
|
|
168
163
|
/**
|
|
169
164
|
* @param {RuntimeSpec} a first
|
|
170
165
|
* @param {RuntimeSpec} b second
|
|
171
166
|
* @returns {-1|0|1} compare
|
|
172
167
|
*/
|
|
173
|
-
|
|
168
|
+
const compareRuntime = (a, b) => {
|
|
174
169
|
if (a === b) {
|
|
175
170
|
return 0;
|
|
176
171
|
} else if (a === undefined) {
|
|
@@ -221,7 +216,6 @@ const mergeRuntime = (a, b) => {
|
|
|
221
216
|
if (set.size === a.size) return a;
|
|
222
217
|
return set;
|
|
223
218
|
};
|
|
224
|
-
module.exports.mergeRuntime = mergeRuntime;
|
|
225
219
|
|
|
226
220
|
/**
|
|
227
221
|
* @param {RuntimeCondition} a first
|
|
@@ -229,7 +223,7 @@ module.exports.mergeRuntime = mergeRuntime;
|
|
|
229
223
|
* @param {RuntimeSpec} runtime full runtime
|
|
230
224
|
* @returns {RuntimeCondition} result
|
|
231
225
|
*/
|
|
232
|
-
|
|
226
|
+
const mergeRuntimeCondition = (a, b, runtime) => {
|
|
233
227
|
if (a === false) return b;
|
|
234
228
|
if (b === false) return a;
|
|
235
229
|
if (a === true || b === true) return true;
|
|
@@ -250,7 +244,7 @@ module.exports.mergeRuntimeCondition = (a, b, runtime) => {
|
|
|
250
244
|
* @param {RuntimeSpec} runtime full runtime
|
|
251
245
|
* @returns {RuntimeSpec | true} result
|
|
252
246
|
*/
|
|
253
|
-
|
|
247
|
+
const mergeRuntimeConditionNonFalse = (a, b, runtime) => {
|
|
254
248
|
if (a === true || b === true) return true;
|
|
255
249
|
const merged = mergeRuntime(a, b);
|
|
256
250
|
if (merged === undefined) return;
|
|
@@ -296,14 +290,13 @@ const mergeRuntimeOwned = (a, b) => {
|
|
|
296
290
|
for (const item of b) a.add(item);
|
|
297
291
|
return a;
|
|
298
292
|
};
|
|
299
|
-
module.exports.mergeRuntimeOwned = mergeRuntimeOwned;
|
|
300
293
|
|
|
301
294
|
/**
|
|
302
295
|
* @param {RuntimeSpec} a first
|
|
303
296
|
* @param {RuntimeSpec} b second
|
|
304
297
|
* @returns {RuntimeSpec} merged
|
|
305
298
|
*/
|
|
306
|
-
|
|
299
|
+
const intersectRuntime = (a, b) => {
|
|
307
300
|
if (a === undefined) {
|
|
308
301
|
return b;
|
|
309
302
|
} else if (b === undefined) {
|
|
@@ -376,7 +369,6 @@ const subtractRuntime = (a, b) => {
|
|
|
376
369
|
}
|
|
377
370
|
return set;
|
|
378
371
|
};
|
|
379
|
-
module.exports.subtractRuntime = subtractRuntime;
|
|
380
372
|
|
|
381
373
|
/**
|
|
382
374
|
* @param {RuntimeCondition} a first
|
|
@@ -384,7 +376,7 @@ module.exports.subtractRuntime = subtractRuntime;
|
|
|
384
376
|
* @param {RuntimeSpec} runtime runtime
|
|
385
377
|
* @returns {RuntimeCondition} result
|
|
386
378
|
*/
|
|
387
|
-
|
|
379
|
+
const subtractRuntimeCondition = (a, b, runtime) => {
|
|
388
380
|
if (b === true) return false;
|
|
389
381
|
if (b === false) return a;
|
|
390
382
|
if (a === false) return false;
|
|
@@ -397,7 +389,7 @@ module.exports.subtractRuntimeCondition = (a, b, runtime) => {
|
|
|
397
389
|
* @param {(runtime?: RuntimeSpec) => boolean} filter filter function
|
|
398
390
|
* @returns {boolean | RuntimeSpec} true/false if filter is constant for all runtimes, otherwise runtimes that are active
|
|
399
391
|
*/
|
|
400
|
-
|
|
392
|
+
const filterRuntime = (runtime, filter) => {
|
|
401
393
|
if (runtime === undefined) return filter();
|
|
402
394
|
if (typeof runtime === "string") return filter(runtime);
|
|
403
395
|
let some = false;
|
|
@@ -604,9 +596,10 @@ class RuntimeSpecMap {
|
|
|
604
596
|
/** @type {RuntimeSpecMapInnerMap<R>} */
|
|
605
597
|
(this._map).get(key);
|
|
606
598
|
const newValue = fn(oldValue);
|
|
607
|
-
if (newValue !== oldValue)
|
|
599
|
+
if (newValue !== oldValue) {
|
|
608
600
|
/** @type {RuntimeSpecMapInnerMap<R>} */
|
|
609
601
|
(this._map).set(key, newValue);
|
|
602
|
+
}
|
|
610
603
|
}
|
|
611
604
|
}
|
|
612
605
|
}
|
|
@@ -649,8 +642,6 @@ class RuntimeSpecMap {
|
|
|
649
642
|
}
|
|
650
643
|
}
|
|
651
644
|
|
|
652
|
-
module.exports.RuntimeSpecMap = RuntimeSpecMap;
|
|
653
|
-
|
|
654
645
|
class RuntimeSpecSet {
|
|
655
646
|
/**
|
|
656
647
|
* @param {Iterable<RuntimeSpec>=} iterable iterable
|
|
@@ -692,4 +683,21 @@ class RuntimeSpecSet {
|
|
|
692
683
|
}
|
|
693
684
|
}
|
|
694
685
|
|
|
686
|
+
module.exports.RuntimeSpecMap = RuntimeSpecMap;
|
|
695
687
|
module.exports.RuntimeSpecSet = RuntimeSpecSet;
|
|
688
|
+
module.exports.compareRuntime = compareRuntime;
|
|
689
|
+
module.exports.filterRuntime = filterRuntime;
|
|
690
|
+
module.exports.forEachRuntime = forEachRuntime;
|
|
691
|
+
module.exports.getEntryRuntime = getEntryRuntime;
|
|
692
|
+
module.exports.getRuntimeKey = getRuntimeKey;
|
|
693
|
+
module.exports.intersectRuntime = intersectRuntime;
|
|
694
|
+
module.exports.keyToRuntime = keyToRuntime;
|
|
695
|
+
module.exports.mergeRuntime = mergeRuntime;
|
|
696
|
+
module.exports.mergeRuntimeCondition = mergeRuntimeCondition;
|
|
697
|
+
module.exports.mergeRuntimeConditionNonFalse = mergeRuntimeConditionNonFalse;
|
|
698
|
+
module.exports.mergeRuntimeOwned = mergeRuntimeOwned;
|
|
699
|
+
module.exports.runtimeConditionToString = runtimeConditionToString;
|
|
700
|
+
module.exports.runtimeEqual = runtimeEqual;
|
|
701
|
+
module.exports.runtimeToString = runtimeToString;
|
|
702
|
+
module.exports.subtractRuntime = subtractRuntime;
|
|
703
|
+
module.exports.subtractRuntimeCondition = subtractRuntimeCondition;
|
package/lib/util/semver.js
CHANGED
|
@@ -561,7 +561,7 @@ module.exports.stringifyHoley = json => {
|
|
|
561
561
|
exports.parseVersionRuntimeCode = runtimeTemplate =>
|
|
562
562
|
`var parseVersion = ${runtimeTemplate.basicFunction("str", [
|
|
563
563
|
"// see webpack/lib/util/semver.js for original code",
|
|
564
|
-
`var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map(
|
|
564
|
+
`var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map(${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p})},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
|
|
565
565
|
])}`;
|
|
566
566
|
//#endregion
|
|
567
567
|
|
|
@@ -41,6 +41,7 @@ const registerSerializers = memoize(() => {
|
|
|
41
41
|
// Load internal paths with a relative require
|
|
42
42
|
// This allows bundling all internal serializers
|
|
43
43
|
const internalSerializables = require("./internalSerializables");
|
|
44
|
+
|
|
44
45
|
getObjectMiddleware().registerLoader(/^webpack\/lib\//, req => {
|
|
45
46
|
const loader =
|
|
46
47
|
internalSerializables[
|
|
@@ -116,7 +117,9 @@ module.exports = {
|
|
|
116
117
|
createFileSerializer: (fs, hashFunction) => {
|
|
117
118
|
registerSerializers();
|
|
118
119
|
const Serializer = getSerializer();
|
|
120
|
+
|
|
119
121
|
const FileMiddleware = require("../serialization/FileMiddleware");
|
|
122
|
+
|
|
120
123
|
const fileMiddleware = new FileMiddleware(fs, hashFunction);
|
|
121
124
|
const binaryMiddleware = getBinaryMiddlewareInstance();
|
|
122
125
|
const SerializerMiddleware = getSerializerMiddleware();
|
package/lib/util/source.js
CHANGED
|
@@ -23,8 +23,8 @@ const _isSourceEqual = (a, b) => {
|
|
|
23
23
|
let bSource = typeof b.buffer === "function" ? b.buffer() : b.source();
|
|
24
24
|
if (aSource === bSource) return true;
|
|
25
25
|
if (typeof aSource === "string" && typeof bSource === "string") return false;
|
|
26
|
-
if (!Buffer.isBuffer(aSource)) aSource = Buffer.from(aSource, "
|
|
27
|
-
if (!Buffer.isBuffer(bSource)) bSource = Buffer.from(bSource, "
|
|
26
|
+
if (!Buffer.isBuffer(aSource)) aSource = Buffer.from(aSource, "utf8");
|
|
27
|
+
if (!Buffer.isBuffer(bSource)) bSource = Buffer.from(bSource, "utf8");
|
|
28
28
|
return aSource.equals(bSource);
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -58,4 +58,5 @@ const isSourceEqual = (a, b) => {
|
|
|
58
58
|
}
|
|
59
59
|
return result;
|
|
60
60
|
};
|
|
61
|
+
|
|
61
62
|
module.exports.isSourceEqual = isSourceEqual;
|
package/lib/validateSchema.js
CHANGED
|
@@ -54,9 +54,7 @@ class EnableWasmLoadingPlugin {
|
|
|
54
54
|
"EnableWasmLoadingPlugin need to be used to enable this type of wasm loading. " +
|
|
55
55
|
'This usually happens through the "output.enabledWasmLoadingTypes" option. ' +
|
|
56
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: ${
|
|
58
|
-
getEnabledTypes(compiler)
|
|
59
|
-
).join(", ")}`
|
|
57
|
+
`These types are enabled: ${[...getEnabledTypes(compiler)].join(", ")}`
|
|
60
58
|
);
|
|
61
59
|
}
|
|
62
60
|
}
|
|
@@ -80,6 +78,7 @@ class EnableWasmLoadingPlugin {
|
|
|
80
78
|
if (compiler.options.experiments.syncWebAssembly) {
|
|
81
79
|
// TODO webpack 6 remove FetchCompileWasmPlugin
|
|
82
80
|
const FetchCompileWasmPlugin = require("../web/FetchCompileWasmPlugin");
|
|
81
|
+
|
|
83
82
|
new FetchCompileWasmPlugin({
|
|
84
83
|
mangleImports: compiler.options.optimization.mangleWasmImports
|
|
85
84
|
}).apply(compiler);
|
|
@@ -87,6 +86,7 @@ class EnableWasmLoadingPlugin {
|
|
|
87
86
|
|
|
88
87
|
if (compiler.options.experiments.asyncWebAssembly) {
|
|
89
88
|
const FetchCompileAsyncWasmPlugin = require("../web/FetchCompileAsyncWasmPlugin");
|
|
89
|
+
|
|
90
90
|
new FetchCompileAsyncWasmPlugin().apply(compiler);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -96,6 +96,7 @@ class EnableWasmLoadingPlugin {
|
|
|
96
96
|
if (compiler.options.experiments.syncWebAssembly) {
|
|
97
97
|
// TODO webpack 6 remove ReadFileCompileWasmPlugin
|
|
98
98
|
const ReadFileCompileWasmPlugin = require("../node/ReadFileCompileWasmPlugin");
|
|
99
|
+
|
|
99
100
|
new ReadFileCompileWasmPlugin({
|
|
100
101
|
mangleImports: compiler.options.optimization.mangleWasmImports,
|
|
101
102
|
import:
|
|
@@ -106,6 +107,7 @@ class EnableWasmLoadingPlugin {
|
|
|
106
107
|
|
|
107
108
|
if (compiler.options.experiments.asyncWebAssembly) {
|
|
108
109
|
const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
|
|
110
|
+
|
|
109
111
|
new ReadFileCompileAsyncWasmPlugin({
|
|
110
112
|
import:
|
|
111
113
|
compiler.options.output.module &&
|
|
@@ -117,6 +119,7 @@ class EnableWasmLoadingPlugin {
|
|
|
117
119
|
}
|
|
118
120
|
case "universal": {
|
|
119
121
|
const UniversalCompileAsyncWasmPlugin = require("../wasm-async/UniversalCompileAsyncWasmPlugin");
|
|
122
|
+
|
|
120
123
|
new UniversalCompileAsyncWasmPlugin().apply(compiler);
|
|
121
124
|
break;
|
|
122
125
|
}
|
|
@@ -105,6 +105,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
105
105
|
return runtimeTemplate.importStatement({
|
|
106
106
|
update: false,
|
|
107
107
|
module: importedModule,
|
|
108
|
+
moduleGraph,
|
|
108
109
|
chunkGraph,
|
|
109
110
|
request,
|
|
110
111
|
originModule: module,
|
|
@@ -131,6 +132,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
131
132
|
)}: ${runtimeTemplate.exportFromImport({
|
|
132
133
|
moduleGraph,
|
|
133
134
|
module: importedModule,
|
|
135
|
+
chunkGraph,
|
|
134
136
|
request,
|
|
135
137
|
exportName: dep.name,
|
|
136
138
|
originModule: module,
|
|
@@ -167,8 +169,9 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
167
169
|
chunkGraph.getRenderedModuleHash(module, runtime)
|
|
168
170
|
)}${importsObj ? `, ${importsObj})` : ")"}`;
|
|
169
171
|
|
|
170
|
-
if (promises.length > 0)
|
|
172
|
+
if (promises.length > 0) {
|
|
171
173
|
runtimeRequirements.add(RuntimeGlobals.asyncModule);
|
|
174
|
+
}
|
|
172
175
|
|
|
173
176
|
const source = new RawSource(
|
|
174
177
|
promises.length > 0
|
|
@@ -133,58 +133,55 @@ class AsyncWebAssemblyModulesPlugin {
|
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
compilation.hooks.renderManifest.tap(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
render: () =>
|
|
158
|
-
this.renderModule(
|
|
159
|
-
module,
|
|
160
|
-
{
|
|
161
|
-
chunk,
|
|
162
|
-
dependencyTemplates,
|
|
163
|
-
runtimeTemplate,
|
|
164
|
-
moduleGraph,
|
|
165
|
-
chunkGraph,
|
|
166
|
-
codeGenerationResults
|
|
167
|
-
},
|
|
168
|
-
hooks
|
|
169
|
-
),
|
|
170
|
-
filenameTemplate,
|
|
171
|
-
pathOptions: {
|
|
136
|
+
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
|
|
137
|
+
const { moduleGraph, chunkGraph, runtimeTemplate } = compilation;
|
|
138
|
+
const {
|
|
139
|
+
chunk,
|
|
140
|
+
outputOptions,
|
|
141
|
+
dependencyTemplates,
|
|
142
|
+
codeGenerationResults
|
|
143
|
+
} = options;
|
|
144
|
+
|
|
145
|
+
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
|
146
|
+
chunk,
|
|
147
|
+
compareModulesByIdOrIdentifier(chunkGraph)
|
|
148
|
+
)) {
|
|
149
|
+
if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
|
|
150
|
+
const filenameTemplate =
|
|
151
|
+
/** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */
|
|
152
|
+
(outputOptions.webassemblyModuleFilename);
|
|
153
|
+
|
|
154
|
+
result.push({
|
|
155
|
+
render: () =>
|
|
156
|
+
this.renderModule(
|
|
172
157
|
module,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
158
|
+
{
|
|
159
|
+
chunk,
|
|
160
|
+
dependencyTemplates,
|
|
161
|
+
runtimeTemplate,
|
|
162
|
+
moduleGraph,
|
|
163
|
+
chunkGraph,
|
|
164
|
+
codeGenerationResults
|
|
165
|
+
},
|
|
166
|
+
hooks
|
|
167
|
+
),
|
|
168
|
+
filenameTemplate,
|
|
169
|
+
pathOptions: {
|
|
170
|
+
module,
|
|
171
|
+
runtime: chunk.runtime,
|
|
172
|
+
chunkGraph
|
|
173
|
+
},
|
|
174
|
+
auxiliary: true,
|
|
175
|
+
identifier: `webassemblyAsyncModule${chunkGraph.getModuleId(
|
|
176
|
+
module
|
|
177
|
+
)}`,
|
|
178
|
+
hash: chunkGraph.getModuleHash(module, chunk.runtime)
|
|
179
|
+
});
|
|
183
180
|
}
|
|
184
|
-
|
|
185
|
-
return result;
|
|
186
181
|
}
|
|
187
|
-
|
|
182
|
+
|
|
183
|
+
return result;
|
|
184
|
+
});
|
|
188
185
|
}
|
|
189
186
|
);
|
|
190
187
|
}
|
|
@@ -172,9 +172,9 @@ const generateImportObject = (
|
|
|
172
172
|
|
|
173
173
|
const moduleIdStringified = JSON.stringify(chunkGraph.getModuleId(module));
|
|
174
174
|
if (waitForInstances.size === 1) {
|
|
175
|
-
const moduleId =
|
|
175
|
+
const moduleId = [...waitForInstances.values()][0];
|
|
176
176
|
const promise = `installedWasmModules[${JSON.stringify(moduleId)}]`;
|
|
177
|
-
const variable =
|
|
177
|
+
const variable = [...waitForInstances.keys()][0];
|
|
178
178
|
return Template.asString([
|
|
179
179
|
`${moduleIdStringified}: function() {`,
|
|
180
180
|
Template.indent([
|
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
const t = require("@webassemblyjs/ast");
|
|
9
9
|
const { moduleContextFromModuleAST } = require("@webassemblyjs/ast");
|
|
10
|
-
const {
|
|
10
|
+
const { addWithAST, editWithAST } = require("@webassemblyjs/wasm-edit");
|
|
11
11
|
const { decode } = require("@webassemblyjs/wasm-parser");
|
|
12
12
|
const { RawSource } = require("webpack-sources");
|
|
13
13
|
const Generator = require("../Generator");
|
|
14
14
|
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
|
|
15
|
-
const WebAssemblyUtils = require("./WebAssemblyUtils");
|
|
16
|
-
|
|
17
15
|
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
|
|
16
|
+
const WebAssemblyUtils = require("./WebAssemblyUtils");
|
|
18
17
|
|
|
19
18
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
19
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
@@ -42,8 +42,9 @@ const getInitialModuleChains = (
|
|
|
42
42
|
for (const connection of moduleGraph.getIncomingConnections(head)) {
|
|
43
43
|
const newHead = connection.originModule;
|
|
44
44
|
if (newHead) {
|
|
45
|
-
if (!chunkGraph.getModuleChunks(newHead).some(c => c.canBeInitial()))
|
|
45
|
+
if (!chunkGraph.getModuleChunks(newHead).some(c => c.canBeInitial())) {
|
|
46
46
|
continue;
|
|
47
|
+
}
|
|
47
48
|
final = false;
|
|
48
49
|
if (alreadyReferencedModules.has(newHead)) continue;
|
|
49
50
|
alreadyReferencedModules.add(newHead);
|
|
@@ -76,7 +77,7 @@ const getInitialModuleChains = (
|
|
|
76
77
|
for (const result of incompleteResults) {
|
|
77
78
|
results.add(result);
|
|
78
79
|
}
|
|
79
|
-
return
|
|
80
|
+
return [...results];
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
module.exports = class WebAssemblyInInitialChunkError extends WebpackError {
|
|
@@ -97,6 +97,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
97
97
|
initParams.push(
|
|
98
98
|
runtimeTemplate.exportFromImport({
|
|
99
99
|
moduleGraph,
|
|
100
|
+
chunkGraph,
|
|
100
101
|
module: importedModule,
|
|
101
102
|
request: dep.request,
|
|
102
103
|
importVar: importData.importVar,
|
|
@@ -129,6 +130,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
129
130
|
`${exportProp} = ${runtimeTemplate.exportFromImport({
|
|
130
131
|
moduleGraph,
|
|
131
132
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
|
133
|
+
chunkGraph,
|
|
132
134
|
request: dep.request,
|
|
133
135
|
importVar: importData.importVar,
|
|
134
136
|
originModule: module,
|
|
@@ -158,6 +160,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
158
160
|
([module, { importVar, request, reexports }]) => {
|
|
159
161
|
const importStatement = runtimeTemplate.importStatement({
|
|
160
162
|
module,
|
|
163
|
+
moduleGraph,
|
|
161
164
|
chunkGraph,
|
|
162
165
|
request,
|
|
163
166
|
importVar,
|
|
@@ -9,6 +9,9 @@ const Compilation = require("../Compilation");
|
|
|
9
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const RuntimeModule = require("../RuntimeModule");
|
|
11
11
|
const Template = require("../Template");
|
|
12
|
+
const {
|
|
13
|
+
generateJavascriptHMR
|
|
14
|
+
} = require("../hmr/JavascriptHotModuleReplacementHelper");
|
|
12
15
|
const chunkHasJs = require("../javascript/JavascriptModulesPlugin").chunkHasJs;
|
|
13
16
|
const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
|
14
17
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
@@ -363,28 +366,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
363
366
|
]
|
|
364
367
|
)};`,
|
|
365
368
|
"",
|
|
366
|
-
|
|
367
|
-
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
|
|
368
|
-
)
|
|
369
|
-
.replace(/\$key\$/g, "jsonp")
|
|
370
|
-
.replace(/\$installedChunks\$/g, "installedChunks")
|
|
371
|
-
.replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
|
|
372
|
-
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
|
|
373
|
-
.replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
|
|
374
|
-
.replace(
|
|
375
|
-
/\$ensureChunkHandlers\$/g,
|
|
376
|
-
RuntimeGlobals.ensureChunkHandlers
|
|
377
|
-
)
|
|
378
|
-
.replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
|
|
379
|
-
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
|
|
380
|
-
.replace(
|
|
381
|
-
/\$hmrDownloadUpdateHandlers\$/g,
|
|
382
|
-
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
383
|
-
)
|
|
384
|
-
.replace(
|
|
385
|
-
/\$hmrInvalidateModuleHandlers\$/g,
|
|
386
|
-
RuntimeGlobals.hmrInvalidateModuleHandlers
|
|
387
|
-
)
|
|
369
|
+
generateJavascriptHMR("jsonp")
|
|
388
370
|
])
|
|
389
371
|
: "// no HMR",
|
|
390
372
|
"",
|
package/lib/webpack.js
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const util = require("util");
|
|
9
|
-
const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check
|
|
9
|
+
const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check");
|
|
10
10
|
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
|
|
11
11
|
const Compiler = require("./Compiler");
|
|
12
12
|
const MultiCompiler = require("./MultiCompiler");
|
|
13
13
|
const WebpackOptionsApply = require("./WebpackOptionsApply");
|
|
14
14
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
applyWebpackOptionsBaseDefaults,
|
|
16
|
+
applyWebpackOptionsDefaults
|
|
17
17
|
} = require("./config/defaults");
|
|
18
18
|
const { getNormalizedWebpackOptions } = require("./config/normalization");
|
|
19
19
|
const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
|
|
@@ -115,8 +115,7 @@ const createCompiler = (rawOptions, compilerIndex) => {
|
|
|
115
115
|
* @param {Array<T> | T} options options
|
|
116
116
|
* @returns {Array<T>} array of options
|
|
117
117
|
*/
|
|
118
|
-
const asArray = options =>
|
|
119
|
-
Array.isArray(options) ? Array.from(options) : [options];
|
|
118
|
+
const asArray = options => (Array.isArray(options) ? [...options] : [options]);
|
|
120
119
|
|
|
121
120
|
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
|
122
121
|
/**
|
|
@@ -8,8 +8,11 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
8
8
|
const RuntimeModule = require("../RuntimeModule");
|
|
9
9
|
const Template = require("../Template");
|
|
10
10
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
generateJavascriptHMR
|
|
12
|
+
} = require("../hmr/JavascriptHotModuleReplacementHelper");
|
|
13
|
+
const {
|
|
14
|
+
chunkHasJs,
|
|
15
|
+
getChunkFilenameTemplate
|
|
13
16
|
} = require("../javascript/JavascriptModulesPlugin");
|
|
14
17
|
const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
|
15
18
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
@@ -199,28 +202,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
199
202
|
]),
|
|
200
203
|
"}",
|
|
201
204
|
"",
|
|
202
|
-
|
|
203
|
-
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
|
|
204
|
-
)
|
|
205
|
-
.replace(/\$key\$/g, "importScripts")
|
|
206
|
-
.replace(/\$installedChunks\$/g, "installedChunks")
|
|
207
|
-
.replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
|
|
208
|
-
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
|
|
209
|
-
.replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
|
|
210
|
-
.replace(
|
|
211
|
-
/\$ensureChunkHandlers\$/g,
|
|
212
|
-
RuntimeGlobals.ensureChunkHandlers
|
|
213
|
-
)
|
|
214
|
-
.replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
|
|
215
|
-
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
|
|
216
|
-
.replace(
|
|
217
|
-
/\$hmrDownloadUpdateHandlers\$/g,
|
|
218
|
-
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
219
|
-
)
|
|
220
|
-
.replace(
|
|
221
|
-
/\$hmrInvalidateModuleHandlers\$/g,
|
|
222
|
-
RuntimeGlobals.hmrInvalidateModuleHandlers
|
|
223
|
-
)
|
|
205
|
+
generateJavascriptHMR("importScripts")
|
|
224
206
|
])
|
|
225
207
|
: "// no HMR",
|
|
226
208
|
"",
|