webpack 5.97.1 → 5.99.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 +345 -392
- package/lib/AsyncDependenciesBlock.js +3 -1
- package/lib/BannerPlugin.js +1 -1
- package/lib/Cache.js +9 -7
- package/lib/CacheFacade.js +5 -5
- package/lib/Chunk.js +2 -2
- package/lib/ChunkGraph.js +21 -16
- package/lib/ChunkTemplate.js +6 -6
- package/lib/CleanPlugin.js +10 -10
- package/lib/CodeGenerationResults.js +4 -3
- package/lib/CompatibilityPlugin.js +4 -1
- package/lib/Compilation.js +343 -167
- package/lib/Compiler.js +13 -18
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +4 -2
- package/lib/ContextModuleFactory.js +3 -3
- package/lib/ContextReplacementPlugin.js +43 -16
- package/lib/DefinePlugin.js +25 -24
- package/lib/DelegatedModule.js +4 -2
- package/lib/DelegatedModuleFactoryPlugin.js +2 -1
- package/lib/Dependency.js +19 -13
- package/lib/DependencyTemplates.js +4 -3
- package/lib/DllModule.js +4 -2
- package/lib/DllModuleFactory.js +2 -2
- package/lib/DllReferencePlugin.js +2 -1
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/ExportsInfo.js +72 -40
- package/lib/ExternalModule.js +14 -5
- package/lib/ExternalModuleFactoryPlugin.js +24 -12
- package/lib/FileSystemInfo.js +129 -94
- package/lib/FlagDependencyExportsPlugin.js +6 -4
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +29 -1
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +3 -9
- package/lib/IgnoreErrorModuleFactory.js +2 -2
- package/lib/IgnorePlugin.js +0 -5
- package/lib/InitFragment.js +1 -1
- package/lib/LoaderOptionsPlugin.js +8 -5
- package/lib/MainTemplate.js +7 -7
- package/lib/Module.js +44 -21
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +4 -3
- package/lib/ModuleDependencyWarning.js +4 -3
- package/lib/ModuleFactory.js +9 -3
- package/lib/ModuleFilenameHelpers.js +21 -39
- package/lib/ModuleGraph.js +20 -14
- package/lib/ModuleGraphConnection.js +7 -13
- package/lib/ModuleNotFoundError.js +1 -1
- package/lib/ModuleParseError.js +2 -1
- package/lib/ModuleSourceTypesConstants.js +11 -0
- package/lib/ModuleTemplate.js +5 -5
- package/lib/ModuleTypeConstants.js +15 -0
- package/lib/MultiCompiler.js +4 -4
- package/lib/MultiStats.js +1 -1
- package/lib/NormalModule.js +101 -54
- package/lib/NormalModuleFactory.js +38 -33
- package/lib/NormalModuleReplacementPlugin.js +3 -2
- package/lib/NullFactory.js +2 -2
- package/lib/Parser.js +4 -3
- package/lib/ProgressPlugin.js +1 -2
- package/lib/RawModule.js +4 -2
- package/lib/RecordIdsPlugin.js +6 -2
- package/lib/RequestShortener.js +3 -1
- package/lib/ResolverFactory.js +12 -9
- package/lib/RuntimeModule.js +4 -2
- package/lib/RuntimeTemplate.js +2 -1
- package/lib/SelfModuleFactory.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +0 -8
- package/lib/Template.js +6 -5
- package/lib/TemplatedPathPlugin.js +15 -12
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +237 -170
- package/lib/asset/AssetModulesPlugin.js +52 -10
- package/lib/asset/AssetSourceGenerator.js +18 -0
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/buildChunkGraph.js +14 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +137 -121
- package/lib/cache/ResolverCachePlugin.js +15 -7
- package/lib/cache/getLazyHashedEtag.js +4 -3
- package/lib/cli.js +23 -15
- package/lib/config/defaults.js +104 -28
- package/lib/config/normalization.js +14 -13
- package/lib/config/target.js +8 -8
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerEntryModuleFactory.js +2 -2
- package/lib/container/FallbackModule.js +4 -2
- package/lib/container/FallbackModuleFactory.js +2 -2
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/options.js +5 -5
- package/lib/css/CssGenerator.js +71 -9
- package/lib/css/CssLoadingRuntimeModule.js +5 -2
- package/lib/css/CssModulesPlugin.js +41 -9
- package/lib/css/CssParser.js +37 -17
- package/lib/css/walkCssTokens.js +17 -17
- package/lib/debug/ProfilingPlugin.js +98 -38
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
- package/lib/dependencies/AMDPlugin.js +5 -2
- package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
- package/lib/dependencies/AMDRequireContextDependency.js +2 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
- package/lib/dependencies/AMDRuntimeModules.js +3 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsImportsParserPlugin.js +38 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +13 -6
- package/lib/dependencies/CssIcssExportDependency.js +15 -12
- package/lib/dependencies/CssIcssImportDependency.js +4 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +18 -15
- package/lib/dependencies/ExportsInfoDependency.js +6 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +8 -6
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
- package/lib/dependencies/ImportContextDependency.js +2 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
- package/lib/dependencies/JsonExportsDependency.js +49 -27
- package/lib/dependencies/LoaderPlugin.js +4 -14
- package/lib/dependencies/RequireContextDependency.js +2 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
- package/lib/dependencies/RequireResolveContextDependency.js +1 -1
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
- package/lib/dependencies/WorkerDependency.js +6 -3
- package/lib/dependencies/WorkerPlugin.js +100 -41
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +3 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +32 -24
- package/lib/hmr/lazyCompilationBackend.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/ids/IdHelpers.js +15 -14
- package/lib/ids/SyncModuleIdsPlugin.js +9 -5
- package/lib/index.js +5 -5
- package/lib/javascript/BasicEvaluatedExpression.js +6 -6
- package/lib/javascript/JavascriptGenerator.js +11 -1
- package/lib/javascript/JavascriptModulesPlugin.js +54 -34
- package/lib/javascript/JavascriptParser.js +272 -188
- package/lib/javascript/JavascriptParserHelpers.js +10 -9
- package/lib/javascript/StartupHelpers.js +4 -1
- package/lib/json/JsonData.js +4 -4
- package/lib/json/JsonGenerator.js +54 -22
- package/lib/json/JsonModulesPlugin.js +16 -3
- package/lib/json/JsonParser.js +10 -4
- package/lib/library/AbstractLibraryPlugin.js +7 -3
- package/lib/library/AssignLibraryPlugin.js +29 -1
- package/lib/library/EnableLibraryPlugin.js +7 -10
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +121 -15
- package/lib/logging/Logger.js +2 -2
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/node/NodeEnvironmentPlugin.js +6 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
- package/lib/node/nodeConsole.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +19 -12
- package/lib/optimize/InnerGraph.js +3 -2
- package/lib/optimize/InnerGraphPlugin.js +13 -7
- package/lib/optimize/LimitChunkCountPlugin.js +20 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
- package/lib/optimize/RealContentHashPlugin.js +8 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
- package/lib/optimize/SplitChunksPlugin.js +90 -65
- package/lib/rules/BasicEffectRulePlugin.js +9 -1
- package/lib/rules/BasicMatcherRulePlugin.js +15 -4
- package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
- package/lib/rules/RuleSetCompiler.js +25 -14
- package/lib/rules/UseEffectRulePlugin.js +47 -17
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
- package/lib/schemes/HttpUriPlugin.js +38 -17
- package/lib/serialization/BinaryMiddleware.js +52 -19
- package/lib/serialization/FileMiddleware.js +78 -48
- package/lib/serialization/ObjectMiddleware.js +78 -29
- package/lib/serialization/PlainObjectSerializer.js +1 -1
- package/lib/serialization/Serializer.js +15 -10
- package/lib/serialization/SerializerMiddleware.js +80 -41
- package/lib/serialization/SingleItemMiddleware.js +10 -7
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
- package/lib/sharing/utils.js +2 -2
- package/lib/stats/DefaultStatsFactoryPlugin.js +81 -79
- package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
- package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
- package/lib/stats/StatsFactory.js +11 -11
- package/lib/stats/StatsPrinter.js +7 -7
- package/lib/util/ArrayHelpers.js +2 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +41 -23
- package/lib/util/LazySet.js +3 -2
- package/lib/util/MapHelpers.js +1 -1
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Semaphore.js +3 -3
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/SortableSet.js +9 -7
- package/lib/util/TupleQueue.js +9 -8
- package/lib/util/TupleSet.js +2 -2
- package/lib/util/WeakTupleMap.js +12 -11
- package/lib/util/binarySearchBounds.js +2 -1
- package/lib/util/cleverMerge.js +84 -54
- package/lib/util/comparators.js +22 -21
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +6 -4
- package/lib/util/create-schema-validation.js +4 -4
- package/lib/util/createHash.js +2 -2
- package/lib/util/deprecation.js +35 -33
- package/lib/util/deterministicGrouping.js +6 -6
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +39 -39
- package/lib/util/hash/wasm-hash.js +2 -2
- package/lib/util/identifier.js +15 -18
- package/lib/util/makeSerializable.js +1 -1
- package/lib/util/memoize.js +4 -1
- package/lib/util/objectToMap.js +3 -2
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +0 -1
- package/lib/util/registerExternalSerializer.js +15 -18
- package/lib/util/removeBOM.js +25 -0
- package/lib/util/runtime.js +34 -27
- package/lib/util/semver.js +18 -8
- package/lib/util/serialization.js +5 -16
- package/lib/util/smartGrouping.js +3 -3
- package/lib/validateSchema.js +4 -7
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
- package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +9 -4
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -2
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
- package/package.json +27 -26
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +48 -13
- package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
- package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
- package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
- package/schemas/plugins/JsonModulesPluginParser.check.js +1 -1
- package/schemas/plugins/JsonModulesPluginParser.json +4 -0
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/types.d.ts +888 -583
- package/lib/library/ModernModuleLibraryPlugin.js +0 -144
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
const { register } = require("./serialization");
|
9
9
|
|
10
|
-
const Position =
|
10
|
+
const Position = require("acorn").Position;
|
11
11
|
const SourceLocation = require("acorn").SourceLocation;
|
12
12
|
const ValidationError = require("schema-utils").ValidationError;
|
13
13
|
const {
|
@@ -23,10 +23,8 @@ const {
|
|
23
23
|
/** @typedef {import("acorn").Position} Position */
|
24
24
|
/** @typedef {import("../Dependency").RealDependencyLocation} RealDependencyLocation */
|
25
25
|
/** @typedef {import("../Dependency").SourcePosition} SourcePosition */
|
26
|
-
/** @typedef {import("
|
27
|
-
/** @typedef {import("
|
28
|
-
|
29
|
-
/** @typedef {ObjectSerializerContext & { writeLazy?: (value: any) => void }} WebpackObjectSerializerContext */
|
26
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
27
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
30
28
|
|
31
29
|
const CURRENT_MODULE = "webpack/lib/util/registerExternalSerializer";
|
32
30
|
|
@@ -37,7 +35,7 @@ register(
|
|
37
35
|
new (class CachedSourceSerializer {
|
38
36
|
/**
|
39
37
|
* @param {CachedSource} source the cached source to be serialized
|
40
|
-
* @param {
|
38
|
+
* @param {ObjectSerializerContext} context context
|
41
39
|
* @returns {void}
|
42
40
|
*/
|
43
41
|
serialize(source, { write, writeLazy }) {
|
@@ -68,7 +66,7 @@ register(
|
|
68
66
|
new (class RawSourceSerializer {
|
69
67
|
/**
|
70
68
|
* @param {RawSource} source the raw source to be serialized
|
71
|
-
* @param {
|
69
|
+
* @param {ObjectSerializerContext} context context
|
72
70
|
* @returns {void}
|
73
71
|
*/
|
74
72
|
serialize(source, { write }) {
|
@@ -95,7 +93,7 @@ register(
|
|
95
93
|
new (class ConcatSourceSerializer {
|
96
94
|
/**
|
97
95
|
* @param {ConcatSource} source the concat source to be serialized
|
98
|
-
* @param {
|
96
|
+
* @param {ObjectSerializerContext} context context
|
99
97
|
* @returns {void}
|
100
98
|
*/
|
101
99
|
serialize(source, { write }) {
|
@@ -121,7 +119,7 @@ register(
|
|
121
119
|
new (class PrefixSourceSerializer {
|
122
120
|
/**
|
123
121
|
* @param {PrefixSource} source the prefix source to be serialized
|
124
|
-
* @param {
|
122
|
+
* @param {ObjectSerializerContext} context context
|
125
123
|
* @returns {void}
|
126
124
|
*/
|
127
125
|
serialize(source, { write }) {
|
@@ -146,7 +144,7 @@ register(
|
|
146
144
|
new (class ReplaceSourceSerializer {
|
147
145
|
/**
|
148
146
|
* @param {ReplaceSource} source the replace source to be serialized
|
149
|
-
* @param {
|
147
|
+
* @param {ObjectSerializerContext} context context
|
150
148
|
* @returns {void}
|
151
149
|
*/
|
152
150
|
serialize(source, { write }) {
|
@@ -196,7 +194,7 @@ register(
|
|
196
194
|
new (class OriginalSourceSerializer {
|
197
195
|
/**
|
198
196
|
* @param {OriginalSource} source the original source to be serialized
|
199
|
-
* @param {
|
197
|
+
* @param {ObjectSerializerContext} context context
|
200
198
|
* @returns {void}
|
201
199
|
*/
|
202
200
|
serialize(source, { write }) {
|
@@ -223,7 +221,7 @@ register(
|
|
223
221
|
new (class SourceLocationSerializer {
|
224
222
|
/**
|
225
223
|
* @param {SourceLocation} loc the location to be serialized
|
226
|
-
* @param {
|
224
|
+
* @param {ObjectSerializerContext} context context
|
227
225
|
* @returns {void}
|
228
226
|
*/
|
229
227
|
serialize(loc, { write }) {
|
@@ -259,7 +257,7 @@ register(
|
|
259
257
|
new (class PositionSerializer {
|
260
258
|
/**
|
261
259
|
* @param {Position} pos the position to be serialized
|
262
|
-
* @param {
|
260
|
+
* @param {ObjectSerializerContext} context context
|
263
261
|
* @returns {void}
|
264
262
|
*/
|
265
263
|
serialize(pos, { write }) {
|
@@ -287,7 +285,7 @@ register(
|
|
287
285
|
new (class SourceMapSourceSerializer {
|
288
286
|
/**
|
289
287
|
* @param {SourceMapSource} source the source map source to be serialized
|
290
|
-
* @param {
|
288
|
+
* @param {ObjectSerializerContext} context context
|
291
289
|
* @returns {void}
|
292
290
|
*/
|
293
291
|
serialize(source, { write }) {
|
@@ -310,10 +308,9 @@ register(
|
|
310
308
|
CURRENT_MODULE,
|
311
309
|
"schema-utils/ValidationError",
|
312
310
|
new (class ValidationErrorSerializer {
|
313
|
-
// TODO error should be ValidationError, but this fails the type checks
|
314
311
|
/**
|
315
|
-
* @param {
|
316
|
-
* @param {
|
312
|
+
* @param {ValidationError} error the source map source to be serialized
|
313
|
+
* @param {ObjectSerializerContext} context context
|
317
314
|
* @returns {void}
|
318
315
|
*/
|
319
316
|
serialize(error, { write }) {
|
@@ -328,7 +325,7 @@ register(
|
|
328
325
|
|
329
326
|
/**
|
330
327
|
* @param {ObjectDeserializerContext} context context
|
331
|
-
* @returns {
|
328
|
+
* @returns {ValidationError} error
|
332
329
|
*/
|
333
330
|
deserialize({ read }) {
|
334
331
|
return new ValidationError(read(), read(), read());
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Alexander Akait @alexander-akait
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @param {string | Buffer} strOrBuffer string or buffer
|
10
|
+
* @returns {string | Buffer} result without BOM
|
11
|
+
*/
|
12
|
+
module.exports = strOrBuffer => {
|
13
|
+
if (typeof strOrBuffer === "string" && strOrBuffer.charCodeAt(0) === 0xfeff) {
|
14
|
+
return strOrBuffer.substr(1);
|
15
|
+
} else if (
|
16
|
+
Buffer.isBuffer(strOrBuffer) &&
|
17
|
+
strOrBuffer[0] === 0xef &&
|
18
|
+
strOrBuffer[1] === 0xbb &&
|
19
|
+
strOrBuffer[2] === 0xbf
|
20
|
+
) {
|
21
|
+
return strOrBuffer.subarray(3);
|
22
|
+
}
|
23
|
+
|
24
|
+
return strOrBuffer;
|
25
|
+
};
|
package/lib/util/runtime.js
CHANGED
@@ -52,7 +52,7 @@ module.exports.getEntryRuntime = (compilation, name, options) => {
|
|
52
52
|
|
53
53
|
/**
|
54
54
|
* @param {RuntimeSpec} runtime runtime
|
55
|
-
* @param {
|
55
|
+
* @param {(runtime: string | undefined) => void} fn functor
|
56
56
|
* @param {boolean} deterministicOrder enforce a deterministic order
|
57
57
|
* @returns {void}
|
58
58
|
*/
|
@@ -394,7 +394,7 @@ module.exports.subtractRuntimeCondition = (a, b, runtime) => {
|
|
394
394
|
|
395
395
|
/**
|
396
396
|
* @param {RuntimeSpec} runtime runtime
|
397
|
-
* @param {
|
397
|
+
* @param {(runtime?: RuntimeSpec) => boolean} filter filter function
|
398
398
|
* @returns {boolean | RuntimeSpec} true/false if filter is constant for all runtimes, otherwise runtimes that are active
|
399
399
|
*/
|
400
400
|
module.exports.filterRuntime = (runtime, filter) => {
|
@@ -424,24 +424,25 @@ module.exports.filterRuntime = (runtime, filter) => {
|
|
424
424
|
|
425
425
|
/**
|
426
426
|
* @template T
|
427
|
+
* @template [R=T]
|
427
428
|
*/
|
428
429
|
class RuntimeSpecMap {
|
429
430
|
/**
|
430
|
-
* @param {RuntimeSpecMap<T>=} clone copy form this
|
431
|
+
* @param {RuntimeSpecMap<T, R>=} clone copy form this
|
431
432
|
*/
|
432
433
|
constructor(clone) {
|
433
434
|
this._mode = clone ? clone._mode : 0; // 0 = empty, 1 = single entry, 2 = map
|
434
435
|
/** @type {RuntimeSpec} */
|
435
436
|
this._singleRuntime = clone ? clone._singleRuntime : undefined;
|
436
|
-
/** @type {
|
437
|
+
/** @type {R | undefined} */
|
437
438
|
this._singleValue = clone ? clone._singleValue : undefined;
|
438
|
-
/** @type {RuntimeSpecMapInnerMap<
|
439
|
+
/** @type {RuntimeSpecMapInnerMap<R> | undefined} */
|
439
440
|
this._map = clone && clone._map ? new Map(clone._map) : undefined;
|
440
441
|
}
|
441
442
|
|
442
443
|
/**
|
443
444
|
* @param {RuntimeSpec} runtime the runtimes
|
444
|
-
* @returns {
|
445
|
+
* @returns {R | undefined} value
|
445
446
|
*/
|
446
447
|
get(runtime) {
|
447
448
|
switch (this._mode) {
|
@@ -452,7 +453,7 @@ class RuntimeSpecMap {
|
|
452
453
|
? this._singleValue
|
453
454
|
: undefined;
|
454
455
|
default:
|
455
|
-
return /** @type {RuntimeSpecMapInnerMap<
|
456
|
+
return /** @type {RuntimeSpecMapInnerMap<R>} */ (this._map).get(
|
456
457
|
getRuntimeKey(runtime)
|
457
458
|
);
|
458
459
|
}
|
@@ -469,7 +470,7 @@ class RuntimeSpecMap {
|
|
469
470
|
case 1:
|
470
471
|
return runtimeEqual(this._singleRuntime, runtime);
|
471
472
|
default:
|
472
|
-
return /** @type {RuntimeSpecMapInnerMap<
|
473
|
+
return /** @type {RuntimeSpecMapInnerMap<R>} */ (this._map).has(
|
473
474
|
getRuntimeKey(runtime)
|
474
475
|
);
|
475
476
|
}
|
@@ -477,7 +478,7 @@ class RuntimeSpecMap {
|
|
477
478
|
|
478
479
|
/**
|
479
480
|
* @param {RuntimeSpec} runtime the runtimes
|
480
|
-
* @param {
|
481
|
+
* @param {R} value the value
|
481
482
|
*/
|
482
483
|
set(runtime, value) {
|
483
484
|
switch (this._mode) {
|
@@ -495,21 +496,21 @@ class RuntimeSpecMap {
|
|
495
496
|
this._map = new Map();
|
496
497
|
this._map.set(
|
497
498
|
getRuntimeKey(this._singleRuntime),
|
498
|
-
/** @type {
|
499
|
+
/** @type {R} */ (this._singleValue)
|
499
500
|
);
|
500
501
|
this._singleRuntime = undefined;
|
501
502
|
this._singleValue = undefined;
|
502
503
|
/* falls through */
|
503
504
|
default:
|
504
|
-
/** @type {RuntimeSpecMapInnerMap<
|
505
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
505
506
|
(this._map).set(getRuntimeKey(runtime), value);
|
506
507
|
}
|
507
508
|
}
|
508
509
|
|
509
510
|
/**
|
510
511
|
* @param {RuntimeSpec} runtime the runtimes
|
511
|
-
* @param {() =>
|
512
|
-
* @returns {
|
512
|
+
* @param {() => R} computer function to compute the value
|
513
|
+
* @returns {R} the new value
|
513
514
|
*/
|
514
515
|
provide(runtime, computer) {
|
515
516
|
switch (this._mode) {
|
@@ -519,13 +520,14 @@ class RuntimeSpecMap {
|
|
519
520
|
return (this._singleValue = computer());
|
520
521
|
case 1: {
|
521
522
|
if (runtimeEqual(this._singleRuntime, runtime)) {
|
522
|
-
return /** @type {
|
523
|
+
return /** @type {R} */ (this._singleValue);
|
523
524
|
}
|
524
525
|
this._mode = 2;
|
525
526
|
this._map = new Map();
|
526
527
|
this._map.set(
|
527
528
|
getRuntimeKey(this._singleRuntime),
|
528
|
-
/** @type {
|
529
|
+
/** @type {R} */
|
530
|
+
(this._singleValue)
|
529
531
|
);
|
530
532
|
this._singleRuntime = undefined;
|
531
533
|
this._singleValue = undefined;
|
@@ -535,10 +537,12 @@ class RuntimeSpecMap {
|
|
535
537
|
}
|
536
538
|
default: {
|
537
539
|
const key = getRuntimeKey(runtime);
|
538
|
-
const value =
|
540
|
+
const value =
|
541
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
542
|
+
(this._map).get(key);
|
539
543
|
if (value !== undefined) return value;
|
540
544
|
const newValue = computer();
|
541
|
-
/** @type {
|
545
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
542
546
|
(this._map).set(key, newValue);
|
543
547
|
return newValue;
|
544
548
|
}
|
@@ -560,14 +564,14 @@ class RuntimeSpecMap {
|
|
560
564
|
}
|
561
565
|
return;
|
562
566
|
default:
|
563
|
-
/** @type {RuntimeSpecMapInnerMap<
|
567
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
564
568
|
(this._map).delete(getRuntimeKey(runtime));
|
565
569
|
}
|
566
570
|
}
|
567
571
|
|
568
572
|
/**
|
569
573
|
* @param {RuntimeSpec} runtime the runtimes
|
570
|
-
* @param {
|
574
|
+
* @param {(value: R | undefined) => R} fn function to update the value
|
571
575
|
*/
|
572
576
|
update(runtime, fn) {
|
573
577
|
switch (this._mode) {
|
@@ -584,7 +588,8 @@ class RuntimeSpecMap {
|
|
584
588
|
this._map = new Map();
|
585
589
|
this._map.set(
|
586
590
|
getRuntimeKey(this._singleRuntime),
|
587
|
-
/** @type {
|
591
|
+
/** @type {R} */
|
592
|
+
(this._singleValue)
|
588
593
|
);
|
589
594
|
this._singleRuntime = undefined;
|
590
595
|
this._singleValue = undefined;
|
@@ -594,10 +599,12 @@ class RuntimeSpecMap {
|
|
594
599
|
}
|
595
600
|
default: {
|
596
601
|
const key = getRuntimeKey(runtime);
|
597
|
-
const oldValue =
|
602
|
+
const oldValue =
|
603
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
604
|
+
(this._map).get(key);
|
598
605
|
const newValue = fn(oldValue);
|
599
606
|
if (newValue !== oldValue)
|
600
|
-
/** @type {RuntimeSpecMapInnerMap<
|
607
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
601
608
|
(this._map).set(key, newValue);
|
602
609
|
}
|
603
610
|
}
|
@@ -611,7 +618,7 @@ class RuntimeSpecMap {
|
|
611
618
|
return [this._singleRuntime];
|
612
619
|
default:
|
613
620
|
return Array.from(
|
614
|
-
/** @type {RuntimeSpecMapInnerMap<
|
621
|
+
/** @type {RuntimeSpecMapInnerMap<R>} */
|
615
622
|
(this._map).keys(),
|
616
623
|
keyToRuntime
|
617
624
|
);
|
@@ -619,16 +626,16 @@ class RuntimeSpecMap {
|
|
619
626
|
}
|
620
627
|
|
621
628
|
/**
|
622
|
-
* @returns {IterableIterator<
|
629
|
+
* @returns {IterableIterator<R>} values
|
623
630
|
*/
|
624
631
|
values() {
|
625
632
|
switch (this._mode) {
|
626
633
|
case 0:
|
627
634
|
return [][Symbol.iterator]();
|
628
635
|
case 1:
|
629
|
-
return [/** @type {
|
636
|
+
return [/** @type {R} */ (this._singleValue)][Symbol.iterator]();
|
630
637
|
default:
|
631
|
-
return /** @type {
|
638
|
+
return /** @type {RuntimeSpecMapInnerMap<R>} */ (this._map).values();
|
632
639
|
}
|
633
640
|
}
|
634
641
|
|
@@ -637,7 +644,7 @@ class RuntimeSpecMap {
|
|
637
644
|
return /** @type {number} */ (this._mode);
|
638
645
|
}
|
639
646
|
|
640
|
-
return /** @type {
|
647
|
+
return /** @type {RuntimeSpecMapInnerMap<R>} */ (this._map).size;
|
641
648
|
}
|
642
649
|
}
|
643
650
|
|
package/lib/util/semver.js
CHANGED
@@ -259,15 +259,25 @@ module.exports.parseRange = str => {
|
|
259
259
|
const items = str.split(/\s+-\s+/);
|
260
260
|
|
261
261
|
if (items.length === 1) {
|
262
|
-
|
263
|
-
/** @type {SemVerRangeItem[][]} */
|
264
|
-
(
|
265
|
-
str
|
266
|
-
.trim()
|
267
|
-
.split(/(?<=[-0-9A-Za-z])\s+/g)
|
268
|
-
.map(parseSimple)
|
269
|
-
);
|
262
|
+
str = str.trim();
|
270
263
|
|
264
|
+
/** @type {SemVerRangeItem[][]} */
|
265
|
+
const items = [];
|
266
|
+
const r = /[-0-9A-Za-z]\s+/g;
|
267
|
+
var start = 0;
|
268
|
+
var match;
|
269
|
+
while ((match = r.exec(str))) {
|
270
|
+
const end = match.index + 1;
|
271
|
+
items.push(
|
272
|
+
/** @type {SemVerRangeItem[]} */
|
273
|
+
(parseSimple(str.slice(start, end).trim()))
|
274
|
+
);
|
275
|
+
start = end;
|
276
|
+
}
|
277
|
+
items.push(
|
278
|
+
/** @type {SemVerRangeItem[]} */
|
279
|
+
(parseSimple(str.slice(start).trim()))
|
280
|
+
);
|
271
281
|
return combine(items, 2);
|
272
282
|
}
|
273
283
|
|
@@ -4,12 +4,11 @@
|
|
4
4
|
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const { DEFAULTS } = require("../config/defaults");
|
7
8
|
const memoize = require("./memoize");
|
8
9
|
|
9
10
|
/** @typedef {import("../serialization/BinaryMiddleware").MEASURE_END_OPERATION_TYPE} MEASURE_END_OPERATION */
|
10
11
|
/** @typedef {import("../serialization/BinaryMiddleware").MEASURE_START_OPERATION_TYPE} MEASURE_START_OPERATION */
|
11
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
12
|
-
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
13
12
|
/** @typedef {import("../serialization/Serializer")} Serializer */
|
14
13
|
/** @typedef {typeof import("../util/Hash")} Hash */
|
15
14
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
@@ -47,6 +46,7 @@ const registerSerializers = memoize(() => {
|
|
47
46
|
if (loader) {
|
48
47
|
loader();
|
49
48
|
} else {
|
49
|
+
// eslint-disable-next-line no-console
|
50
50
|
console.warn(`${req} not found in internalSerializables`);
|
51
51
|
}
|
52
52
|
return true;
|
@@ -91,17 +91,14 @@ module.exports = {
|
|
91
91
|
return (buffersSerializer = new Serializer([
|
92
92
|
new SingleItemMiddleware(),
|
93
93
|
new (getObjectMiddleware())(context => {
|
94
|
-
if (context
|
95
|
-
/**
|
96
|
-
* @param {any} value value
|
97
|
-
*/
|
94
|
+
if ("write" in context) {
|
98
95
|
context.writeLazy = value => {
|
99
96
|
context.write(
|
100
97
|
SerializerMiddleware.createLazy(value, binaryMiddleware)
|
101
98
|
);
|
102
99
|
};
|
103
100
|
}
|
104
|
-
},
|
101
|
+
}, DEFAULTS.HASH_FUNCTION),
|
105
102
|
binaryMiddleware
|
106
103
|
]));
|
107
104
|
},
|
@@ -121,20 +118,12 @@ module.exports = {
|
|
121
118
|
return new Serializer([
|
122
119
|
new SingleItemMiddleware(),
|
123
120
|
new (getObjectMiddleware())(context => {
|
124
|
-
if (context
|
125
|
-
/**
|
126
|
-
* @param {any} value value
|
127
|
-
*/
|
121
|
+
if ("write" in context) {
|
128
122
|
context.writeLazy = value => {
|
129
123
|
context.write(
|
130
124
|
SerializerMiddleware.createLazy(value, binaryMiddleware)
|
131
125
|
);
|
132
126
|
};
|
133
|
-
/**
|
134
|
-
* @param {any} value value
|
135
|
-
* @param {object=} options lazy options
|
136
|
-
* @returns {function(): Promise<any> | any} lazy function
|
137
|
-
*/
|
138
127
|
context.writeSeparate = (value, options) => {
|
139
128
|
const lazy = SerializerMiddleware.createLazy(
|
140
129
|
value,
|
@@ -16,9 +16,9 @@
|
|
16
16
|
* @template T
|
17
17
|
* @template R
|
18
18
|
* @typedef {object} GroupConfig
|
19
|
-
* @property {
|
20
|
-
* @property {
|
21
|
-
* @property {
|
19
|
+
* @property {(item: T) => string[] | undefined} getKeys
|
20
|
+
* @property {(key: string, children: (R | T)[], items: T[]) => R} createGroup
|
21
|
+
* @property {(name: string, items: T[]) => GroupOptions=} getOptions
|
22
22
|
*/
|
23
23
|
|
24
24
|
/**
|
package/lib/validateSchema.js
CHANGED
@@ -87,7 +87,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
|
|
87
87
|
children.some(
|
88
88
|
child =>
|
89
89
|
child.keyword === "absolutePath" &&
|
90
|
-
child.
|
90
|
+
child.instancePath === "/output/filename"
|
91
91
|
)
|
92
92
|
) {
|
93
93
|
return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
|
@@ -97,7 +97,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
|
|
97
97
|
children &&
|
98
98
|
children.some(
|
99
99
|
child =>
|
100
|
-
child.keyword === "pattern" && child.
|
100
|
+
child.keyword === "pattern" && child.instancePath === "/devtool"
|
101
101
|
)
|
102
102
|
) {
|
103
103
|
return (
|
@@ -108,10 +108,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
|
|
108
108
|
}
|
109
109
|
|
110
110
|
if (error.keyword === "additionalProperties") {
|
111
|
-
const params =
|
112
|
-
/** @type {import("ajv").AdditionalPropertiesParams} */ (
|
113
|
-
error.params
|
114
|
-
);
|
111
|
+
const params = error.params;
|
115
112
|
if (
|
116
113
|
Object.prototype.hasOwnProperty.call(
|
117
114
|
DID_YOU_MEAN,
|
@@ -136,7 +133,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
|
|
136
133
|
}?`;
|
137
134
|
}
|
138
135
|
|
139
|
-
if (!error.
|
136
|
+
if (!error.instancePath) {
|
140
137
|
if (params.additionalProperty === "debug") {
|
141
138
|
return (
|
142
139
|
`${formattedError}\n` +
|
@@ -99,7 +99,7 @@ class EnableWasmLoadingPlugin {
|
|
99
99
|
new ReadFileCompileWasmPlugin({
|
100
100
|
mangleImports: compiler.options.optimization.mangleWasmImports,
|
101
101
|
import:
|
102
|
-
compiler.options.output.
|
102
|
+
compiler.options.output.module &&
|
103
103
|
compiler.options.output.environment.dynamicImport
|
104
104
|
}).apply(compiler);
|
105
105
|
}
|
@@ -108,7 +108,7 @@ class EnableWasmLoadingPlugin {
|
|
108
108
|
const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
|
109
109
|
new ReadFileCompileAsyncWasmPlugin({
|
110
110
|
import:
|
111
|
-
compiler.options.output.
|
111
|
+
compiler.options.output.module &&
|
112
112
|
compiler.options.output.environment.dynamicImport
|
113
113
|
}).apply(compiler);
|
114
114
|
}
|
@@ -14,9 +14,9 @@ const Template = require("../Template");
|
|
14
14
|
|
15
15
|
/**
|
16
16
|
* @typedef {object} AsyncWasmLoadingRuntimeModuleOptions
|
17
|
-
* @property {(
|
18
|
-
* @property {
|
19
|
-
* @property {(
|
17
|
+
* @property {((wasmModuleSrcPath: string) => string)=} generateBeforeLoadBinaryCode
|
18
|
+
* @property {(wasmModuleSrcPath: string) => string} generateLoadBinaryCode
|
19
|
+
* @property {(() => string)=} generateBeforeInstantiateStreaming
|
20
20
|
* @property {boolean} supportsStreaming
|
21
21
|
*/
|
22
22
|
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { RawSource } = require("webpack-sources");
|
8
9
|
const Generator = require("../Generator");
|
9
10
|
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
|
10
11
|
|
@@ -56,6 +57,16 @@ class AsyncWebAssemblyGenerator extends Generator {
|
|
56
57
|
generate(module, generateContext) {
|
57
58
|
return /** @type {Source} */ (module.originalSource());
|
58
59
|
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @param {Error} error the error
|
63
|
+
* @param {NormalModule} module module for which the code should be generated
|
64
|
+
* @param {GenerateContext} generateContext context for generate
|
65
|
+
* @returns {Source | null} generated code
|
66
|
+
*/
|
67
|
+
generateError(error, module, generateContext) {
|
68
|
+
return new RawSource(error.message);
|
69
|
+
}
|
59
70
|
}
|
60
71
|
|
61
72
|
module.exports = AsyncWebAssemblyGenerator;
|
@@ -201,6 +201,16 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
201
201
|
|
202
202
|
return InitFragment.addToSource(source, initFragments, generateContext);
|
203
203
|
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* @param {Error} error the error
|
207
|
+
* @param {NormalModule} module module for which the code should be generated
|
208
|
+
* @param {GenerateContext} generateContext context for generate
|
209
|
+
* @returns {Source | null} generated code
|
210
|
+
*/
|
211
|
+
generateError(error, module, generateContext) {
|
212
|
+
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
|
213
|
+
}
|
204
214
|
}
|
205
215
|
|
206
216
|
module.exports = AsyncWebAssemblyJavascriptGenerator;
|
@@ -11,7 +11,7 @@ const Generator = require("../Generator");
|
|
11
11
|
const { tryRunOrWebpackError } = require("../HookWebpackError");
|
12
12
|
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
13
13
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
14
|
-
const {
|
14
|
+
const { compareModulesByIdOrIdentifier } = require("../util/comparators");
|
15
15
|
const memoize = require("../util/memoize");
|
16
16
|
|
17
17
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -146,7 +146,7 @@ class AsyncWebAssemblyModulesPlugin {
|
|
146
146
|
|
147
147
|
for (const module of chunkGraph.getOrderedChunkModulesIterable(
|
148
148
|
chunk,
|
149
|
-
|
149
|
+
compareModulesByIdOrIdentifier(chunkGraph)
|
150
150
|
)) {
|
151
151
|
if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
|
152
152
|
const filenameTemplate =
|
@@ -42,6 +42,10 @@ class UniversalCompileAsyncWasmPlugin {
|
|
42
42
|
Template.indent(["return fallback();"]),
|
43
43
|
"}"
|
44
44
|
]);
|
45
|
+
/**
|
46
|
+
* @param {string} path path
|
47
|
+
* @returns {string} code
|
48
|
+
*/
|
45
49
|
const generateBeforeLoadBinaryCode = path =>
|
46
50
|
Template.asString([
|
47
51
|
"var useFetch = typeof document !== 'undefined' || typeof self !== 'undefined';",
|