webpack 5.85.0 → 5.88.1
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +5 -2
- package/lib/APIPlugin.js +150 -99
- package/lib/AsyncDependenciesBlock.js +3 -3
- package/lib/BannerPlugin.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +35 -17
- package/lib/ChunkGraph.js +4 -4
- package/lib/ChunkGroup.js +20 -9
- package/lib/CompatibilityPlugin.js +50 -30
- package/lib/Compilation.js +2 -1
- package/lib/Compiler.js +10 -9
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +73 -32
- package/lib/ContextModule.js +8 -3
- package/lib/ContextModuleFactory.js +1 -0
- package/lib/ContextReplacementPlugin.js +13 -0
- package/lib/DelegatedModule.js +15 -3
- package/lib/DelegatedModuleFactoryPlugin.js +6 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/Dependency.js +11 -5
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllEntryPlugin.js +11 -1
- package/lib/DllModule.js +6 -0
- package/lib/DllReferencePlugin.js +13 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/ErrorHelpers.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +6 -1
- package/lib/ExportsInfo.js +22 -4
- package/lib/ExportsInfoApiPlugin.js +14 -5
- package/lib/ExternalModule.js +20 -8
- package/lib/FileSystemInfo.js +52 -24
- package/lib/FlagAllModulesAsUsedPlugin.js +6 -1
- package/lib/FlagDependencyUsagePlugin.js +3 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/Generator.js +7 -0
- package/lib/HotModuleReplacementPlugin.js +8 -0
- package/lib/InitFragment.js +28 -5
- package/lib/JavascriptMetaInfoPlugin.js +11 -6
- package/lib/LibManifestPlugin.js +20 -4
- package/lib/Module.js +14 -3
- package/lib/ModuleDependencyError.js +4 -2
- package/lib/ModuleDependencyWarning.js +4 -2
- package/lib/ModuleGraph.js +31 -24
- package/lib/ModuleGraphConnection.js +19 -6
- package/lib/ModuleInfoHeaderPlugin.js +9 -2
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleProfile.js +1 -0
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +7 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/NodeStuffPlugin.js +32 -6
- package/lib/ProgressPlugin.js +71 -15
- package/lib/ProvidePlugin.js +13 -4
- package/lib/RawModule.js +3 -1
- package/lib/RequireJsStuffPlugin.js +7 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +3 -3
- package/lib/RuntimePlugin.js +6 -3
- package/lib/RuntimeTemplate.js +22 -4
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +7 -2
- package/lib/UseStrictPlugin.js +10 -3
- package/lib/Watching.js +62 -25
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackIsIncludedPlugin.js +6 -4
- package/lib/WebpackOptionsApply.js +4 -2
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/asset/AssetGenerator.js +2 -1
- package/lib/asset/AssetParser.js +11 -6
- package/lib/asset/AssetSourceParser.js +8 -3
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/buildChunkGraph.js +37 -21
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/PackFileCacheStrategy.js +53 -22
- package/lib/config/browserslistTargetHandler.js +7 -7
- package/lib/config/defaults.js +43 -26
- package/lib/container/RemoteRuntimeModule.js +1 -1
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +43 -19
- package/lib/css/CssModulesPlugin.js +42 -14
- package/lib/css/CssParser.js +22 -0
- package/lib/dependencies/AMDDefineDependency.js +34 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +5 -0
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +14 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +169 -59
- package/lib/dependencies/CommonJsPlugin.js +13 -8
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +7 -2
- package/lib/dependencies/CssImportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +5 -0
- package/lib/dependencies/CssUrlDependency.js +3 -3
- package/lib/dependencies/DllEntryDependency.js +5 -0
- package/lib/dependencies/DynamicExports.js +10 -6
- package/lib/dependencies/ExportsInfoDependency.js +14 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +2 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExports.js +9 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +40 -27
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +31 -21
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
- package/lib/dependencies/ImportDependency.js +5 -3
- package/lib/dependencies/ImportEagerDependency.js +5 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
- package/lib/dependencies/ImportMetaPlugin.js +31 -15
- package/lib/dependencies/ImportParserPlugin.js +62 -25
- package/lib/dependencies/ImportWeakDependency.js +5 -3
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ProvidedDependency.js +4 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +13 -5
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +5 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +6 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +26 -5
- package/lib/dependencies/RequireResolveHeaderDependency.js +9 -0
- package/lib/dependencies/SystemPlugin.js +17 -5
- package/lib/dependencies/SystemRuntimeModule.js +1 -1
- package/lib/dependencies/URLDependency.js +2 -2
- package/lib/dependencies/URLPlugin.js +9 -4
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +59 -22
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -0
- package/lib/javascript/BasicEvaluatedExpression.js +28 -19
- package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
- package/lib/javascript/JavascriptModulesPlugin.js +25 -5
- package/lib/javascript/JavascriptParser.js +157 -85
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/json/JsonData.js +2 -2
- package/lib/json/JsonParser.js +25 -12
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +13 -1
- package/lib/library/EnableLibraryPlugin.js +4 -0
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +20 -2
- package/lib/logging/runtime.js +1 -1
- package/lib/logging/truncateArgs.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -6
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +10 -6
- package/lib/optimize/AggressiveMergingPlugin.js +8 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +2 -1
- package/lib/optimize/LimitChunkCountPlugin.js +29 -4
- package/lib/optimize/MangleExportsPlugin.js +1 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
- package/lib/optimize/RealContentHashPlugin.js +80 -30
- package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
- package/lib/optimize/RuntimeChunkPlugin.js +9 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
- package/lib/optimize/SplitChunksPlugin.js +71 -31
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +6 -3
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -2
- package/lib/rules/BasicEffectRulePlugin.js +4 -0
- package/lib/rules/BasicMatcherRulePlugin.js +5 -0
- package/lib/rules/RuleSetCompiler.js +3 -3
- package/lib/rules/UseEffectRulePlugin.js +6 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +8 -5
- package/lib/runtime/AutoPublicPathRuntimeModule.js +4 -2
- package/lib/runtime/BaseUriRuntimeModule.js +3 -3
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
- package/lib/runtime/CompatRuntimeModule.js +7 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/CreateScriptRuntimeModule.js +4 -2
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +4 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +5 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +15 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -10
- package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
- package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -2
- package/lib/runtime/GlobalRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +64 -48
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/NonceRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
- package/lib/runtime/PublicPathRuntimeModule.js +4 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -3
- package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -2
- package/lib/runtime/SystemContextRuntimeModule.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +143 -1
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/ObjectMiddleware.js +9 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +14 -5
- package/lib/sharing/ProvideSharedDependency.js +11 -0
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +22 -21
- package/lib/sharing/ShareRuntimeModule.js +12 -5
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/sharing/utils.js +32 -5
- package/lib/util/AsyncQueue.js +4 -2
- package/lib/util/ParallelismFactorCalculator.js +10 -0
- package/lib/util/Semaphore.js +1 -1
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/createHash.js +30 -9
- package/lib/util/deprecation.js +10 -3
- package/lib/util/deterministicGrouping.js +50 -11
- package/lib/util/findGraphRoots.js +4 -2
- package/lib/util/memoize.js +3 -3
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +84 -21
- package/lib/util/semver.js +1 -0
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +6 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +14 -7
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyParser.js +6 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +14 -4
- package/lib/webpack.js +11 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +15 -16
- package/module.d.ts +1 -0
- package/package.json +5 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +52 -6
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +606 -292
@@ -21,6 +21,9 @@ Section -> NullsSection |
|
|
21
21
|
I32NumbersSection |
|
22
22
|
I8NumbersSection |
|
23
23
|
ShortStringSection |
|
24
|
+
BigIntSection |
|
25
|
+
I32BigIntSection |
|
26
|
+
I8BigIntSection
|
24
27
|
StringSection |
|
25
28
|
BufferSection |
|
26
29
|
NopSection
|
@@ -39,6 +42,9 @@ ShortStringSection -> ShortStringSectionHeaderByte ascii-byte*
|
|
39
42
|
StringSection -> StringSectionHeaderByte i32:length utf8-byte*
|
40
43
|
BufferSection -> BufferSectionHeaderByte i32:length byte*
|
41
44
|
NopSection --> NopSectionHeaderByte
|
45
|
+
BigIntSection -> BigIntSectionHeaderByte i32:length ascii-byte*
|
46
|
+
I32BigIntSection -> I32BigIntSectionHeaderByte i32
|
47
|
+
I8BigIntSection -> I8BigIntSectionHeaderByte i8
|
42
48
|
|
43
49
|
ShortStringSectionHeaderByte -> 0b1nnn_nnnn (n:length)
|
44
50
|
|
@@ -58,6 +64,9 @@ BooleansCountAndBitsByte ->
|
|
58
64
|
StringSectionHeaderByte -> 0b0000_1110
|
59
65
|
BufferSectionHeaderByte -> 0b0000_1111
|
60
66
|
NopSectionHeaderByte -> 0b0000_1011
|
67
|
+
BigIntSectionHeaderByte -> 0b0001_1010
|
68
|
+
I32BigIntSectionHeaderByte -> 0b0001_1100
|
69
|
+
I8BigIntSectionHeaderByte -> 0b0001_1011
|
61
70
|
FalseHeaderByte -> 0b0000_1100
|
62
71
|
TrueHeaderByte -> 0b0000_1101
|
63
72
|
|
@@ -78,6 +87,9 @@ const NULL_AND_I8_HEADER = 0x15;
|
|
78
87
|
const NULL_AND_I32_HEADER = 0x16;
|
79
88
|
const NULL_AND_TRUE_HEADER = 0x17;
|
80
89
|
const NULL_AND_FALSE_HEADER = 0x18;
|
90
|
+
const BIGINT_HEADER = 0x1a;
|
91
|
+
const BIGINT_I8_HEADER = 0x1b;
|
92
|
+
const BIGINT_I32_HEADER = 0x1c;
|
81
93
|
const STRING_HEADER = 0x1e;
|
82
94
|
const BUFFER_HEADER = 0x1f;
|
83
95
|
const I8_HEADER = 0x60;
|
@@ -86,7 +98,7 @@ const F64_HEADER = 0x20;
|
|
86
98
|
const SHORT_STRING_HEADER = 0x80;
|
87
99
|
|
88
100
|
/** Uplift high-order bits */
|
89
|
-
const NUMBERS_HEADER_MASK = 0xe0;
|
101
|
+
const NUMBERS_HEADER_MASK = 0xe0; // 0b1010_0000
|
90
102
|
const NUMBERS_COUNT_MASK = 0x1f; // 0b0001_1111
|
91
103
|
const SHORT_STRING_LENGTH_MASK = 0x7f; // 0b0111_1111
|
92
104
|
|
@@ -113,6 +125,16 @@ const identifyNumber = n => {
|
|
113
125
|
return 2;
|
114
126
|
};
|
115
127
|
|
128
|
+
/**
|
129
|
+
* @param {bigint} n bigint
|
130
|
+
* @returns {0 | 1 | 2} type of bigint for serialization
|
131
|
+
*/
|
132
|
+
const identifyBigInt = n => {
|
133
|
+
if (n <= BigInt(127) && n >= BigInt(-128)) return 0;
|
134
|
+
if (n <= BigInt(2147483647) && n >= BigInt(-2147483648)) return 1;
|
135
|
+
return 2;
|
136
|
+
};
|
137
|
+
|
116
138
|
/**
|
117
139
|
* @typedef {PrimitiveSerializableType[]} DeserializedType
|
118
140
|
* @typedef {BufferSerializableType[]} SerializedType
|
@@ -331,6 +353,62 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
331
353
|
}
|
332
354
|
break;
|
333
355
|
}
|
356
|
+
case "bigint": {
|
357
|
+
const type = identifyBigInt(thing);
|
358
|
+
if (type === 0 && thing >= 0 && thing <= BigInt(10)) {
|
359
|
+
// shortcut for very small bigints
|
360
|
+
allocate(HEADER_SIZE + I8_SIZE);
|
361
|
+
writeU8(BIGINT_I8_HEADER);
|
362
|
+
writeU8(Number(thing));
|
363
|
+
break;
|
364
|
+
}
|
365
|
+
|
366
|
+
switch (type) {
|
367
|
+
case 0: {
|
368
|
+
let n = 1;
|
369
|
+
allocate(HEADER_SIZE + I8_SIZE * n);
|
370
|
+
writeU8(BIGINT_I8_HEADER | (n - 1));
|
371
|
+
while (n > 0) {
|
372
|
+
currentBuffer.writeInt8(
|
373
|
+
Number(/** @type {bigint} */ (data[i])),
|
374
|
+
currentPosition
|
375
|
+
);
|
376
|
+
currentPosition += I8_SIZE;
|
377
|
+
n--;
|
378
|
+
i++;
|
379
|
+
}
|
380
|
+
i--;
|
381
|
+
break;
|
382
|
+
}
|
383
|
+
case 1: {
|
384
|
+
let n = 1;
|
385
|
+
allocate(HEADER_SIZE + I32_SIZE * n);
|
386
|
+
writeU8(BIGINT_I32_HEADER | (n - 1));
|
387
|
+
while (n > 0) {
|
388
|
+
currentBuffer.writeInt32LE(
|
389
|
+
Number(/** @type {bigint} */ (data[i])),
|
390
|
+
currentPosition
|
391
|
+
);
|
392
|
+
currentPosition += I32_SIZE;
|
393
|
+
n--;
|
394
|
+
i++;
|
395
|
+
}
|
396
|
+
i--;
|
397
|
+
break;
|
398
|
+
}
|
399
|
+
default: {
|
400
|
+
const value = thing.toString();
|
401
|
+
const len = Buffer.byteLength(value);
|
402
|
+
allocate(len + HEADER_SIZE + I32_SIZE);
|
403
|
+
writeU8(BIGINT_HEADER);
|
404
|
+
writeU32(len);
|
405
|
+
currentBuffer.write(value, currentPosition);
|
406
|
+
currentPosition += len;
|
407
|
+
break;
|
408
|
+
}
|
409
|
+
}
|
410
|
+
break;
|
411
|
+
}
|
334
412
|
case "number": {
|
335
413
|
const type = identifyNumber(thing);
|
336
414
|
if (type === 0 && thing >= 0 && thing <= 10) {
|
@@ -847,6 +925,70 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
847
925
|
result.push(read(1).readInt8(0));
|
848
926
|
}
|
849
927
|
};
|
928
|
+
case BIGINT_I8_HEADER: {
|
929
|
+
const len = 1;
|
930
|
+
return () => {
|
931
|
+
const need = I8_SIZE * len;
|
932
|
+
|
933
|
+
if (isInCurrentBuffer(need)) {
|
934
|
+
for (let i = 0; i < len; i++) {
|
935
|
+
const value =
|
936
|
+
/** @type {Buffer} */
|
937
|
+
(currentBuffer).readInt8(currentPosition);
|
938
|
+
result.push(BigInt(value));
|
939
|
+
currentPosition += I8_SIZE;
|
940
|
+
}
|
941
|
+
checkOverflow();
|
942
|
+
} else {
|
943
|
+
const buf = read(need);
|
944
|
+
for (let i = 0; i < len; i++) {
|
945
|
+
const value = buf.readInt8(i * I8_SIZE);
|
946
|
+
result.push(BigInt(value));
|
947
|
+
}
|
948
|
+
}
|
949
|
+
};
|
950
|
+
}
|
951
|
+
case BIGINT_I32_HEADER: {
|
952
|
+
const len = 1;
|
953
|
+
return () => {
|
954
|
+
const need = I32_SIZE * len;
|
955
|
+
if (isInCurrentBuffer(need)) {
|
956
|
+
for (let i = 0; i < len; i++) {
|
957
|
+
const value = /** @type {Buffer} */ (currentBuffer).readInt32LE(
|
958
|
+
currentPosition
|
959
|
+
);
|
960
|
+
result.push(BigInt(value));
|
961
|
+
currentPosition += I32_SIZE;
|
962
|
+
}
|
963
|
+
checkOverflow();
|
964
|
+
} else {
|
965
|
+
const buf = read(need);
|
966
|
+
for (let i = 0; i < len; i++) {
|
967
|
+
const value = buf.readInt32LE(i * I32_SIZE);
|
968
|
+
result.push(BigInt(value));
|
969
|
+
}
|
970
|
+
}
|
971
|
+
};
|
972
|
+
}
|
973
|
+
case BIGINT_HEADER: {
|
974
|
+
return () => {
|
975
|
+
const len = readU32();
|
976
|
+
if (isInCurrentBuffer(len) && currentPosition + len < 0x7fffffff) {
|
977
|
+
const value = currentBuffer.toString(
|
978
|
+
undefined,
|
979
|
+
currentPosition,
|
980
|
+
currentPosition + len
|
981
|
+
);
|
982
|
+
|
983
|
+
result.push(BigInt(value));
|
984
|
+
currentPosition += len;
|
985
|
+
checkOverflow();
|
986
|
+
} else {
|
987
|
+
const value = read(len).toString();
|
988
|
+
result.push(BigInt(value));
|
989
|
+
}
|
990
|
+
};
|
991
|
+
}
|
850
992
|
default:
|
851
993
|
if (header <= 10) {
|
852
994
|
return () => result.push(header);
|
@@ -21,6 +21,7 @@ class ErrorObjectSerializer {
|
|
21
21
|
serialize(obj, context) {
|
22
22
|
context.write(obj.message);
|
23
23
|
context.write(obj.stack);
|
24
|
+
context.write(/** @type {Error & { cause: "unknown" }} */ (obj).cause);
|
24
25
|
}
|
25
26
|
/**
|
26
27
|
* @param {ObjectDeserializerContext} context context
|
@@ -31,6 +32,8 @@ class ErrorObjectSerializer {
|
|
31
32
|
|
32
33
|
err.message = context.read();
|
33
34
|
err.stack = context.read();
|
35
|
+
/** @type {Error & { cause: "unknown" }} */
|
36
|
+
(err).cause = context.read();
|
34
37
|
|
35
38
|
return err;
|
36
39
|
}
|
@@ -107,7 +107,7 @@ const ESCAPE_UNDEFINED = false;
|
|
107
107
|
|
108
108
|
const CURRENT_VERSION = 2;
|
109
109
|
|
110
|
-
/** @type {Map<Constructor, { request?: string, name?: string | number , serializer?: ObjectSerializer }>} */
|
110
|
+
/** @type {Map<Constructor, { request?: string, name?: string | number | null, serializer?: ObjectSerializer }>} */
|
111
111
|
const serializers = new Map();
|
112
112
|
/** @type {Map<string | number, ObjectSerializer>} */
|
113
113
|
const serializerInversed = new Map();
|
@@ -158,7 +158,10 @@ if (exports.constructor !== Object) {
|
|
158
158
|
}
|
159
159
|
|
160
160
|
for (const { request, name, serializer } of serializers.values()) {
|
161
|
-
serializerInversed.set(
|
161
|
+
serializerInversed.set(
|
162
|
+
`${request}/${name}`,
|
163
|
+
/** @type {ObjectSerializer} */ (serializer)
|
164
|
+
);
|
162
165
|
}
|
163
166
|
|
164
167
|
/** @type {Map<RegExp, (request: string) => boolean>} */
|
@@ -191,7 +194,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
191
194
|
/**
|
192
195
|
* @param {Constructor} Constructor the constructor
|
193
196
|
* @param {string} request the request which will be required when deserializing
|
194
|
-
* @param {string} name the name to make multiple serializer unique when sharing a request
|
197
|
+
* @param {string | null} name the name to make multiple serializer unique when sharing a request
|
195
198
|
* @param {ObjectSerializer} serializer the serializer
|
196
199
|
* @returns {void}
|
197
200
|
*/
|
@@ -397,6 +400,9 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
397
400
|
", "
|
398
401
|
)} }`;
|
399
402
|
}
|
403
|
+
if (typeof item === "bigint") {
|
404
|
+
return `BigInt ${item}n`;
|
405
|
+
}
|
400
406
|
try {
|
401
407
|
return `${item}`;
|
402
408
|
} catch (e) {
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
/** @typedef {undefined|null|number|string|boolean|Buffer|Object|(() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */
|
8
8
|
|
9
|
-
/** @typedef {undefined|null|number|string|boolean|Buffer|(() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>)} PrimitiveSerializableType */
|
9
|
+
/** @typedef {undefined|null|number|bigint|string|boolean|Buffer|(() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>)} PrimitiveSerializableType */
|
10
10
|
|
11
11
|
/** @typedef {Buffer|(() => BufferSerializableType[] | Promise<BufferSerializableType[]>)} BufferSerializableType */
|
12
12
|
|
@@ -9,6 +9,9 @@ const ModuleDependency = require("../dependencies/ModuleDependency");
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
10
10
|
|
11
11
|
class ConsumeSharedFallbackDependency extends ModuleDependency {
|
12
|
+
/**
|
13
|
+
* @param {string} request the request
|
14
|
+
*/
|
12
15
|
constructor(request) {
|
13
16
|
super(request);
|
14
17
|
}
|
@@ -17,24 +17,31 @@ const {
|
|
17
17
|
|
18
18
|
/** @typedef {import("webpack-sources").Source} Source */
|
19
19
|
/** @typedef {import("../Chunk")} Chunk */
|
20
|
+
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
21
|
+
/** @typedef {import("../Compilation")} Compilation */
|
20
22
|
/** @typedef {import("../Module")} Module */
|
21
23
|
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
|
22
24
|
|
23
25
|
class ConsumeSharedRuntimeModule extends RuntimeModule {
|
26
|
+
/**
|
27
|
+
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
28
|
+
*/
|
24
29
|
constructor(runtimeRequirements) {
|
25
30
|
super("consumes", RuntimeModule.STAGE_ATTACH);
|
26
31
|
this._runtimeRequirements = runtimeRequirements;
|
27
32
|
}
|
28
33
|
|
29
34
|
/**
|
30
|
-
* @returns {string} runtime code
|
35
|
+
* @returns {string | null} runtime code
|
31
36
|
*/
|
32
37
|
generate() {
|
33
|
-
const
|
38
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
39
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
34
40
|
const { runtimeTemplate, codeGenerationResults } = compilation;
|
35
41
|
const chunkToModuleMapping = {};
|
36
42
|
/** @type {Map<string | number, Source>} */
|
37
43
|
const moduleIdToSourceMapping = new Map();
|
44
|
+
/** @type {(string | number)[]} */
|
38
45
|
const initialConsumes = [];
|
39
46
|
/**
|
40
47
|
*
|
@@ -57,7 +64,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
57
64
|
);
|
58
65
|
}
|
59
66
|
};
|
60
|
-
for (const chunk of this.chunk.getAllAsyncChunks()) {
|
67
|
+
for (const chunk of /** @type {Chunk} */ (this.chunk).getAllAsyncChunks()) {
|
61
68
|
const modules = chunkGraph.getChunkModulesIterableBySourceType(
|
62
69
|
chunk,
|
63
70
|
"consume-shared"
|
@@ -65,7 +72,9 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
65
72
|
if (!modules) continue;
|
66
73
|
addModules(modules, chunk, (chunkToModuleMapping[chunk.id] = []));
|
67
74
|
}
|
68
|
-
for (const chunk of
|
75
|
+
for (const chunk of /** @type {Chunk} */ (
|
76
|
+
this.chunk
|
77
|
+
).getAllInitialChunks()) {
|
69
78
|
const modules = chunkGraph.getChunkModulesIterableBySourceType(
|
70
79
|
chunk,
|
71
80
|
"consume-shared"
|
@@ -166,7 +175,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
166
175
|
]
|
167
176
|
)};`,
|
168
177
|
`var warn = ${
|
169
|
-
|
178
|
+
compilation.outputOptions.ignoreBrowserWarnings
|
170
179
|
? runtimeTemplate.basicFunction("", "")
|
171
180
|
: runtimeTemplate.basicFunction("msg", [
|
172
181
|
'if (typeof console !== "undefined" && console.warn) console.warn(msg);'
|
@@ -12,6 +12,13 @@ const makeSerializable = require("../util/makeSerializable");
|
|
12
12
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
13
13
|
|
14
14
|
class ProvideSharedDependency extends Dependency {
|
15
|
+
/**
|
16
|
+
* @param {string} shareScope share scope
|
17
|
+
* @param {string} name module name
|
18
|
+
* @param {string | false} version version
|
19
|
+
* @param {string} request request
|
20
|
+
* @param {boolean} eager true, if this is an eager dependency
|
21
|
+
*/
|
15
22
|
constructor(shareScope, name, version, request, eager) {
|
16
23
|
super();
|
17
24
|
this.shareScope = shareScope;
|
@@ -46,6 +53,10 @@ class ProvideSharedDependency extends Dependency {
|
|
46
53
|
super.serialize(context);
|
47
54
|
}
|
48
55
|
|
56
|
+
/**
|
57
|
+
* @param {ObjectDeserializerContext} context context
|
58
|
+
* @returns {ProvideSharedDependency} deserialize fallback dependency
|
59
|
+
*/
|
49
60
|
static deserialize(context) {
|
50
61
|
const { read } = context;
|
51
62
|
const obj = new ProvideSharedDependency(
|
@@ -174,6 +174,10 @@ class ProvideSharedModule extends Module {
|
|
174
174
|
super.serialize(context);
|
175
175
|
}
|
176
176
|
|
177
|
+
/**
|
178
|
+
* @param {ObjectDeserializerContext} context context
|
179
|
+
* @returns {ProvideSharedModule} deserialize fallback dependency
|
180
|
+
*/
|
177
181
|
static deserialize(context) {
|
178
182
|
const { read } = context;
|
179
183
|
const obj = new ProvideSharedModule(read(), read(), read(), read(), read());
|
@@ -42,27 +42,28 @@ class ProvideSharedPlugin {
|
|
42
42
|
constructor(options) {
|
43
43
|
validate(options);
|
44
44
|
|
45
|
-
/** @type {[string, ProvideOptions][]} */
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
45
|
+
this._provides = /** @type {[string, ProvideOptions][]} */ (
|
46
|
+
parseOptions(
|
47
|
+
options.provides,
|
48
|
+
item => {
|
49
|
+
if (Array.isArray(item))
|
50
|
+
throw new Error("Unexpected array of provides");
|
51
|
+
/** @type {ProvideOptions} */
|
52
|
+
const result = {
|
53
|
+
shareKey: item,
|
54
|
+
version: undefined,
|
55
|
+
shareScope: options.shareScope || "default",
|
56
|
+
eager: false
|
57
|
+
};
|
58
|
+
return result;
|
59
|
+
},
|
60
|
+
item => ({
|
61
|
+
shareKey: item.shareKey,
|
62
|
+
version: item.version,
|
63
|
+
shareScope: item.shareScope || options.shareScope || "default",
|
64
|
+
eager: !!item.eager
|
65
|
+
})
|
66
|
+
)
|
66
67
|
);
|
67
68
|
this._provides.sort(([a], [b]) => {
|
68
69
|
if (a < b) return -1;
|
@@ -13,24 +13,31 @@ const {
|
|
13
13
|
compareStrings
|
14
14
|
} = require("../util/comparators");
|
15
15
|
|
16
|
+
/** @typedef {import("../Chunk")} Chunk */
|
17
|
+
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
18
|
+
/** @typedef {import("../Compilation")} Compilation */
|
19
|
+
|
16
20
|
class ShareRuntimeModule extends RuntimeModule {
|
17
21
|
constructor() {
|
18
22
|
super("sharing");
|
19
23
|
}
|
20
24
|
|
21
25
|
/**
|
22
|
-
* @returns {string} runtime code
|
26
|
+
* @returns {string | null} runtime code
|
23
27
|
*/
|
24
28
|
generate() {
|
25
|
-
const
|
29
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
26
30
|
const {
|
27
31
|
runtimeTemplate,
|
28
32
|
codeGenerationResults,
|
29
|
-
outputOptions: { uniqueName }
|
33
|
+
outputOptions: { uniqueName, ignoreBrowserWarnings }
|
30
34
|
} = compilation;
|
35
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
31
36
|
/** @type {Map<string, Map<number, Set<string>>>} */
|
32
37
|
const initCodePerScope = new Map();
|
33
|
-
for (const chunk of
|
38
|
+
for (const chunk of /** @type {Chunk} */ (
|
39
|
+
this.chunk
|
40
|
+
).getAllReferencedChunks()) {
|
34
41
|
const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
35
42
|
chunk,
|
36
43
|
"share-init",
|
@@ -78,7 +85,7 @@ class ShareRuntimeModule extends RuntimeModule {
|
|
78
85
|
"// runs all init snippets from all modules reachable",
|
79
86
|
`var scope = ${RuntimeGlobals.shareScopeMap}[name];`,
|
80
87
|
`var warn = ${
|
81
|
-
|
88
|
+
ignoreBrowserWarnings
|
82
89
|
? runtimeTemplate.basicFunction("", "")
|
83
90
|
: runtimeTemplate.basicFunction("msg", [
|
84
91
|
'if (typeof console !== "undefined" && console.warn) console.warn(msg);'
|
package/lib/sharing/utils.js
CHANGED
@@ -52,6 +52,11 @@ const DEF_GIT_PROTOCOL = "git+ssh://";
|
|
52
52
|
|
53
53
|
// thanks to https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js
|
54
54
|
const extractCommithashByDomain = {
|
55
|
+
/**
|
56
|
+
* @param {string} pathname pathname
|
57
|
+
* @param {string} hash hash
|
58
|
+
* @returns {string | undefined} hash
|
59
|
+
*/
|
55
60
|
"github.com": (pathname, hash) => {
|
56
61
|
let [, user, project, type, commithash] = pathname.split("/", 5);
|
57
62
|
if (type && type !== "tree") {
|
@@ -74,6 +79,11 @@ const extractCommithashByDomain = {
|
|
74
79
|
|
75
80
|
return commithash;
|
76
81
|
},
|
82
|
+
/**
|
83
|
+
* @param {string} pathname pathname
|
84
|
+
* @param {string} hash hash
|
85
|
+
* @returns {string | undefined} hash
|
86
|
+
*/
|
77
87
|
"gitlab.com": (pathname, hash) => {
|
78
88
|
const path = pathname.slice(1);
|
79
89
|
if (path.includes("/-/") || path.includes("/archive.tar.gz")) {
|
@@ -81,7 +91,7 @@ const extractCommithashByDomain = {
|
|
81
91
|
}
|
82
92
|
|
83
93
|
const segments = path.split("/");
|
84
|
-
let project = segments.pop();
|
94
|
+
let project = /** @type {string} */ (segments.pop());
|
85
95
|
if (project.endsWith(".git")) {
|
86
96
|
project = project.slice(0, -4);
|
87
97
|
}
|
@@ -93,6 +103,11 @@ const extractCommithashByDomain = {
|
|
93
103
|
|
94
104
|
return hash;
|
95
105
|
},
|
106
|
+
/**
|
107
|
+
* @param {string} pathname pathname
|
108
|
+
* @param {string} hash hash
|
109
|
+
* @returns {string | undefined} hash
|
110
|
+
*/
|
96
111
|
"bitbucket.org": (pathname, hash) => {
|
97
112
|
let [, user, project, aux] = pathname.split("/", 4);
|
98
113
|
if (["get"].includes(aux)) {
|
@@ -109,6 +124,11 @@ const extractCommithashByDomain = {
|
|
109
124
|
|
110
125
|
return hash;
|
111
126
|
},
|
127
|
+
/**
|
128
|
+
* @param {string} pathname pathname
|
129
|
+
* @param {string} hash hash
|
130
|
+
* @returns {string | undefined} hash
|
131
|
+
*/
|
112
132
|
"gist.github.com": (pathname, hash) => {
|
113
133
|
let [, user, project, aux] = pathname.split("/", 4);
|
114
134
|
if (aux === "raw") {
|
@@ -121,7 +141,6 @@ const extractCommithashByDomain = {
|
|
121
141
|
}
|
122
142
|
|
123
143
|
project = user;
|
124
|
-
user = null;
|
125
144
|
}
|
126
145
|
|
127
146
|
if (project.endsWith(".git")) {
|
@@ -136,7 +155,7 @@ const extractCommithashByDomain = {
|
|
136
155
|
* extract commit hash from parsed url
|
137
156
|
*
|
138
157
|
* @inner
|
139
|
-
* @param {
|
158
|
+
* @param {URL} urlParsed parsed url
|
140
159
|
* @returns {string} commithash
|
141
160
|
*/
|
142
161
|
function getCommithash(urlParsed) {
|
@@ -148,8 +167,16 @@ function getCommithash(urlParsed) {
|
|
148
167
|
// eslint-disable-next-line no-empty
|
149
168
|
} catch (e) {}
|
150
169
|
|
151
|
-
if (
|
152
|
-
|
170
|
+
if (
|
171
|
+
extractCommithashByDomain[
|
172
|
+
/** @type {keyof extractCommithashByDomain} */ (hostname)
|
173
|
+
]
|
174
|
+
) {
|
175
|
+
return (
|
176
|
+
extractCommithashByDomain[
|
177
|
+
/** @type {keyof extractCommithashByDomain} */ (hostname)
|
178
|
+
](pathname, hash) || ""
|
179
|
+
);
|
153
180
|
}
|
154
181
|
|
155
182
|
return hash;
|
package/lib/util/AsyncQueue.js
CHANGED
@@ -70,7 +70,7 @@ class AsyncQueue {
|
|
70
70
|
this._entries = new Map();
|
71
71
|
/** @type {ArrayQueue<AsyncQueueEntry<T, K, R>>} */
|
72
72
|
this._queued = new ArrayQueue();
|
73
|
-
/** @type {AsyncQueue<any, any, any>[]} */
|
73
|
+
/** @type {AsyncQueue<any, any, any>[] | undefined} */
|
74
74
|
this._children = undefined;
|
75
75
|
this._activeTasks = 0;
|
76
76
|
this._willEnsureProcessing = false;
|
@@ -159,7 +159,9 @@ class AsyncQueue {
|
|
159
159
|
*/
|
160
160
|
invalidate(item) {
|
161
161
|
const key = this._getKey(item);
|
162
|
-
const entry =
|
162
|
+
const entry =
|
163
|
+
/** @type {AsyncQueueEntry<T, K, R>} */
|
164
|
+
(this._entries.get(key));
|
163
165
|
this._entries.delete(key);
|
164
166
|
if (entry.state === QUEUED_STATE) {
|
165
167
|
this._queued.delete(entry);
|
@@ -7,12 +7,22 @@
|
|
7
7
|
|
8
8
|
const binarySearchBounds = require("../util/binarySearchBounds");
|
9
9
|
|
10
|
+
/** @typedef {function(number): void} Callback */
|
11
|
+
|
10
12
|
class ParallelismFactorCalculator {
|
11
13
|
constructor() {
|
14
|
+
/** @type {number[]} */
|
12
15
|
this._rangePoints = [];
|
16
|
+
/** @type {Callback[]} */
|
13
17
|
this._rangeCallbacks = [];
|
14
18
|
}
|
15
19
|
|
20
|
+
/**
|
21
|
+
* @param {number} start range start
|
22
|
+
* @param {number} end range end
|
23
|
+
* @param {Callback} callback callback
|
24
|
+
* @returns {void}
|
25
|
+
*/
|
16
26
|
range(start, end, callback) {
|
17
27
|
if (start === end) return callback(1);
|
18
28
|
this._rangePoints.push(start);
|
package/lib/util/Semaphore.js
CHANGED
@@ -19,7 +19,7 @@ class StackedCacheMap {
|
|
19
19
|
|
20
20
|
/**
|
21
21
|
* @param {ReadonlyMap<K, V>} map map to add
|
22
|
-
* @param {boolean} immutable if 'map' is immutable and StackedCacheMap can keep referencing it
|
22
|
+
* @param {boolean=} immutable if 'map' is immutable and StackedCacheMap can keep referencing it
|
23
23
|
*/
|
24
24
|
addAll(map, immutable) {
|
25
25
|
if (immutable) {
|
@@ -76,7 +76,7 @@ function getScheme(specifier) {
|
|
76
76
|
|
77
77
|
/**
|
78
78
|
* @param {string} specifier specifier
|
79
|
-
* @returns {string|null} protocol if absolute URL specifier provided
|
79
|
+
* @returns {string | null | undefined} protocol if absolute URL specifier provided
|
80
80
|
*/
|
81
81
|
function getProtocol(specifier) {
|
82
82
|
const scheme = getScheme(specifier);
|