webpack 5.104.1 → 5.105.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 +6 -3
- package/lib/APIPlugin.js +85 -15
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +13 -1
- package/lib/AsyncDependencyToInitialChunkError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +2 -0
- package/lib/CacheFacade.js +2 -2
- package/lib/CaseSensitiveModulesWarning.js +1 -0
- package/lib/Chunk.js +8 -4
- package/lib/ChunkGraph.js +30 -9
- package/lib/ChunkGroup.js +6 -3
- package/lib/ChunkRenderError.js +2 -0
- package/lib/CleanPlugin.js +4 -1
- package/lib/CodeGenerationError.js +7 -1
- package/lib/CodeGenerationResults.js +10 -3
- package/lib/CommentCompilationWarning.js +2 -1
- package/lib/Compilation.js +280 -236
- package/lib/Compiler.js +3 -2
- package/lib/ConcatenationScope.js +2 -1
- package/lib/ConcurrentCompilationError.js +3 -3
- package/lib/ContextModule.js +248 -111
- package/lib/ContextModuleFactory.js +14 -2
- package/lib/DefinePlugin.js +3 -1
- package/lib/DelegatedModule.js +6 -0
- package/lib/DelegatedModuleFactoryPlugin.js +2 -0
- package/lib/Dependency.js +6 -1
- package/lib/DependencyTemplates.js +3 -2
- package/lib/DllModule.js +2 -0
- package/lib/DllReferencePlugin.js +1 -0
- package/lib/DotenvPlugin.js +11 -5
- package/lib/DynamicEntryPlugin.js +1 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +17 -13
- package/lib/ExportsInfo.js +8 -4
- package/lib/ExternalModule.js +16 -0
- package/lib/FalseIIFEUmdWarning.js +1 -0
- package/lib/FileSystemInfo.js +49 -25
- package/lib/FlagDependencyExportsPlugin.js +8 -1
- package/lib/FlagDependencyUsagePlugin.js +9 -7
- package/lib/HarmonyLinkingError.js +1 -0
- package/lib/HookWebpackError.js +2 -0
- package/lib/HotModuleReplacementPlugin.js +16 -2
- package/lib/InitFragment.js +1 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -0
- package/lib/LibManifestPlugin.js +1 -0
- package/lib/ManifestPlugin.js +4 -1
- package/lib/Module.js +7 -4
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +1 -0
- package/lib/ModuleDependencyWarning.js +1 -0
- package/lib/ModuleError.js +2 -1
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleGraphConnection.js +10 -1
- package/lib/ModuleHashingError.js +2 -0
- package/lib/ModuleInfoHeaderPlugin.js +6 -1
- package/lib/ModuleNotFoundError.js +1 -0
- package/lib/ModuleParseError.js +5 -1
- package/lib/ModuleProfile.js +1 -1
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleSourceTypeConstants.js +1 -11
- package/lib/ModuleStoreError.js +2 -0
- package/lib/ModuleWarning.js +3 -1
- package/lib/MultiCompiler.js +11 -7
- package/lib/MultiWatching.js +2 -2
- package/lib/NoModeWarning.js +1 -0
- package/lib/NodeStuffInWebError.js +1 -0
- package/lib/NormalModule.js +26 -5
- package/lib/NormalModuleFactory.js +20 -4
- package/lib/OptionsApply.js +3 -1
- package/lib/ProgressPlugin.js +4 -0
- package/lib/RawModule.js +2 -0
- package/lib/RuntimeModule.js +10 -0
- package/lib/RuntimePlugin.js +7 -9
- package/lib/RuntimeTemplate.js +14 -7
- package/lib/SourceMapDevToolPlugin.js +30 -23
- package/lib/Template.js +10 -5
- package/lib/TemplatedPathPlugin.js +4 -2
- package/lib/UnhandledSchemeError.js +1 -0
- package/lib/UnsupportedFeatureWarning.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -1
- package/lib/Watching.js +5 -0
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsApply.js +60 -40
- package/lib/asset/AssetBytesGenerator.js +1 -0
- package/lib/asset/AssetGenerator.js +9 -3
- package/lib/asset/AssetModulesPlugin.js +33 -2
- package/lib/asset/AssetSourceGenerator.js +1 -0
- package/lib/asset/RawDataUrlModule.js +4 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +31 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +41 -8
- package/lib/cache/getLazyHashedEtag.js +13 -4
- package/lib/cache/mergeEtags.js +3 -1
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +65 -44
- package/lib/config/normalization.js +96 -0
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/HoistContainerReferencesPlugin.js +6 -0
- package/lib/container/RemoteModule.js +19 -0
- package/lib/css/CssGenerator.js +31 -4
- package/lib/css/CssModulesPlugin.js +26 -30
- package/lib/css/CssParser.js +12 -9
- package/lib/debug/ProfilingPlugin.js +1 -0
- package/lib/dependencies/AMDDefineDependency.js +3 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
- package/lib/dependencies/AMDPlugin.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
- package/lib/dependencies/CachedConstDependency.js +1 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
- package/lib/dependencies/ConstDependency.js +1 -0
- package/lib/dependencies/ContextDependencyHelpers.js +11 -4
- package/lib/dependencies/ContextElementDependency.js +1 -0
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +5 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
- package/lib/dependencies/CssUrlDependency.js +2 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
- package/lib/dependencies/ImportDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +53 -11
- package/lib/dependencies/ImportParserPlugin.js +7 -12
- package/lib/dependencies/LoaderPlugin.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
- package/lib/dependencies/ProvidedDependency.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +9 -3
- package/lib/dependencies/WorkerPlugin.js +1 -0
- package/lib/dependencies/getFunctionExpression.js +3 -1
- package/lib/errors/BuildCycleError.js +4 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
- package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +5 -0
- package/lib/hmr/lazyCompilationBackend.js +3 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
- package/lib/ids/IdHelpers.js +10 -8
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
- package/lib/ids/SyncModuleIdsPlugin.js +5 -1
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
- package/lib/javascript/JavascriptModulesPlugin.js +29 -8
- package/lib/javascript/JavascriptParser.js +47 -14
- package/lib/json/JsonParser.js +6 -0
- package/lib/library/AbstractLibraryPlugin.js +4 -1
- package/lib/library/AmdLibraryPlugin.js +2 -1
- package/lib/library/AssignLibraryPlugin.js +6 -2
- package/lib/library/EnableLibraryPlugin.js +1 -0
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +130 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +4 -3
- package/lib/logging/createConsoleLogger.js +3 -0
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/nodeConsole.js +18 -1
- package/lib/optimize/AggressiveMergingPlugin.js +2 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
- package/lib/optimize/ConcatenatedModule.js +33 -19
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
- package/lib/optimize/InnerGraph.js +5 -3
- package/lib/optimize/InnerGraphPlugin.js +25 -25
- package/lib/optimize/MangleExportsPlugin.js +14 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
- package/lib/optimize/MinChunkSizePlugin.js +5 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
- package/lib/optimize/RealContentHashPlugin.js +35 -27
- package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
- package/lib/optimize/SplitChunksPlugin.js +14 -3
- package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
- package/lib/performance/NoAsyncChunksWarning.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +2 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
- package/lib/rules/RuleSetCompiler.js +2 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +27 -7
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/BinaryMiddleware.js +4 -0
- package/lib/serialization/FileMiddleware.js +9 -4
- package/lib/serialization/ObjectMiddleware.js +34 -11
- package/lib/serialization/PlainObjectSerializer.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +60 -0
- package/lib/sharing/ConsumeSharedPlugin.js +5 -4
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +24 -25
- package/lib/sharing/resolveMatchedConfigs.js +2 -2
- package/lib/sharing/utils.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/url/URLParserPlugin.js +4 -3
- package/lib/util/AppendOnlyStackedSet.js +57 -0
- package/lib/util/Hash.js +1 -0
- package/lib/util/IterableHelpers.js +1 -0
- package/lib/util/LazyBucketSortedSet.js +1 -0
- package/lib/util/LazySet.js +1 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/SortableSet.js +1 -0
- package/lib/util/StringXor.js +1 -0
- package/lib/util/binarySearchBounds.js +15 -8
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +6 -1
- package/lib/util/comparators.js +21 -1
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +3 -2
- package/lib/util/conventions.js +3 -2
- package/lib/util/deterministicGrouping.js +13 -1
- package/lib/util/extractSourceMap.js +12 -13
- package/lib/util/fs.js +15 -19
- package/lib/util/hash/BatchedHash.js +3 -0
- package/lib/util/hash/BulkUpdateHash.js +7 -1
- package/lib/util/hash/hash-digest.js +1 -0
- package/lib/util/hash/wasm-hash.js +16 -1
- package/lib/util/identifier.js +7 -2
- package/lib/util/magicComment.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -0
- package/lib/util/runtime.js +15 -1
- package/lib/util/semver.js +1 -0
- package/lib/util/serialization.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/webpack.js +13 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/package.json +20 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +71 -5
- package/types.d.ts +339 -93
package/lib/util/comparators.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const { getFullModuleName } = require("../ids/IdHelpers");
|
|
8
9
|
const { compareRuntime } = require("./runtime");
|
|
9
10
|
|
|
10
11
|
/** @typedef {import("../Chunk")} Chunk */
|
|
@@ -13,6 +14,7 @@ const { compareRuntime } = require("./runtime");
|
|
|
13
14
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
14
15
|
/** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
|
|
15
16
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
17
|
+
/** @typedef {import("../Compiler")} Compiler */
|
|
16
18
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
17
19
|
/** @typedef {import("../Dependency")} Dependency */
|
|
18
20
|
/** @typedef {import("../dependencies/HarmonyImportSideEffectDependency")} HarmonyImportSideEffectDependency */
|
|
@@ -316,6 +318,19 @@ const compareModulesByIdOrIdentifier = (chunkGraph, a, b) => {
|
|
|
316
318
|
return compareIds(a.identifier(), b.identifier());
|
|
317
319
|
};
|
|
318
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Compare modules by their full name. This differs from comparing by identifier in that the values have been normalized to be relative to the compiler context.
|
|
323
|
+
* @param {{ context: string, root: object }} compiler the compiler, used for context and cache
|
|
324
|
+
* @param {Module} a module
|
|
325
|
+
* @param {Module} b module
|
|
326
|
+
* @returns {-1 | 0 | 1} compare result
|
|
327
|
+
*/
|
|
328
|
+
const compareModulesByFullName = (compiler, a, b) => {
|
|
329
|
+
const aName = getFullModuleName(a, compiler.context, compiler.root);
|
|
330
|
+
const bName = getFullModuleName(b, compiler.context, compiler.root);
|
|
331
|
+
return compareIds(aName, bName);
|
|
332
|
+
};
|
|
333
|
+
|
|
319
334
|
/**
|
|
320
335
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
321
336
|
* @param {Chunk} a chunk
|
|
@@ -519,7 +534,7 @@ const sortWithSourceOrder = (
|
|
|
519
534
|
dependencySourceOrderMap,
|
|
520
535
|
onDependencyReSort
|
|
521
536
|
) => {
|
|
522
|
-
/** @type {{dep: Dependency, main: number, sub: number}[]} */
|
|
537
|
+
/** @type {{ dep: Dependency, main: number, sub: number }[]} */
|
|
523
538
|
const withSourceOrder = [];
|
|
524
539
|
/** @type {number[]} */
|
|
525
540
|
const positions = [];
|
|
@@ -590,6 +605,11 @@ module.exports.compareIterables = compareIterables;
|
|
|
590
605
|
|
|
591
606
|
module.exports.compareLocations = compareLocations;
|
|
592
607
|
|
|
608
|
+
/** @type {ParameterizedComparator<Compiler, Module>} */
|
|
609
|
+
module.exports.compareModulesByFullName = createCachedParameterizedComparator(
|
|
610
|
+
compareModulesByFullName
|
|
611
|
+
);
|
|
612
|
+
|
|
593
613
|
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
|
594
614
|
module.exports.compareModulesById =
|
|
595
615
|
createCachedParameterizedComparator(compareModulesById);
|
|
@@ -252,10 +252,10 @@ const itemsToRegexp = (itemsArr) => {
|
|
|
252
252
|
|
|
253
253
|
// special case for 2 items with common suffix
|
|
254
254
|
if (finishedItems.length === 0 && items.size === 2) {
|
|
255
|
-
/** @type {
|
|
255
|
+
/** @type {SetIterator<string>} */
|
|
256
256
|
const it = items[Symbol.iterator]();
|
|
257
|
-
const a = it.next().value;
|
|
258
|
-
const b = it.next().value;
|
|
257
|
+
const a = /** @type {string} */ (it.next().value);
|
|
258
|
+
const b = /** @type {string} */ (it.next().value);
|
|
259
259
|
if (a.length > 0 && b.length > 0 && a.slice(-1) === b.slice(-1)) {
|
|
260
260
|
return `${itemsToRegexp([a.slice(0, -1), b.slice(0, -1)])}${quoteMeta(
|
|
261
261
|
a.slice(-1)
|
package/lib/util/concatenate.js
CHANGED
|
@@ -110,7 +110,7 @@ function findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {
|
|
|
110
110
|
|
|
111
111
|
// Remove uncool stuff
|
|
112
112
|
extraInfo = extraInfo.replace(
|
|
113
|
-
/\.+\/|(
|
|
113
|
+
/\.+\/|(?:\/index)?\.[a-zA-Z0-9]{1,4}(?:$|\s|\?)|\s*\+\s*\d+\s*modules/g,
|
|
114
114
|
""
|
|
115
115
|
);
|
|
116
116
|
|
|
@@ -199,9 +199,10 @@ const RESERVED_NAMES = new Set(
|
|
|
199
199
|
);
|
|
200
200
|
|
|
201
201
|
/** @typedef {{ usedNames: UsedNames, alreadyCheckedScopes: ScopeSet }} ScopeInfo */
|
|
202
|
+
/** @typedef {Map<string, ScopeInfo>} UsedNamesInScopeInfo */
|
|
202
203
|
|
|
203
204
|
/**
|
|
204
|
-
* @param {
|
|
205
|
+
* @param {UsedNamesInScopeInfo} usedNamesInScopeInfo used names in scope info
|
|
205
206
|
* @param {string} module module identifier
|
|
206
207
|
* @param {string} id export id
|
|
207
208
|
* @returns {ScopeInfo} info
|
package/lib/util/conventions.js
CHANGED
|
@@ -20,7 +20,7 @@ const preserveCamelCase = (string) => {
|
|
|
20
20
|
for (let i = 0; i < result.length; i++) {
|
|
21
21
|
const character = result[i];
|
|
22
22
|
|
|
23
|
-
if (isLastCharLower &&
|
|
23
|
+
if (isLastCharLower && /\p{Lu}/u.test(character)) {
|
|
24
24
|
result = `${result.slice(0, i)}-${result.slice(i)}`;
|
|
25
25
|
isLastCharLower = false;
|
|
26
26
|
isLastLastCharUpper = isLastCharUpper;
|
|
@@ -29,7 +29,7 @@ const preserveCamelCase = (string) => {
|
|
|
29
29
|
} else if (
|
|
30
30
|
isLastCharUpper &&
|
|
31
31
|
isLastLastCharUpper &&
|
|
32
|
-
|
|
32
|
+
/\p{Ll}/u.test(character)
|
|
33
33
|
) {
|
|
34
34
|
result = `${result.slice(0, i - 1)}-${result.slice(i - 1)}`;
|
|
35
35
|
isLastLastCharUpper = isLastCharUpper;
|
|
@@ -84,6 +84,7 @@ module.exports.camelCase = (input) => {
|
|
|
84
84
|
* @returns {string[]} results
|
|
85
85
|
*/
|
|
86
86
|
module.exports.cssExportConvention = (input, convention) => {
|
|
87
|
+
/** @type {Set<string>} */
|
|
87
88
|
const set = new Set();
|
|
88
89
|
if (typeof convention === "function") {
|
|
89
90
|
set.add(convention(input));
|
|
@@ -100,6 +100,7 @@ const subtractSizeFrom = (total, size) => {
|
|
|
100
100
|
* @returns {Sizes} total size
|
|
101
101
|
*/
|
|
102
102
|
const sumSize = (nodes) => {
|
|
103
|
+
/** @type {Sizes} */
|
|
103
104
|
const sum = Object.create(null);
|
|
104
105
|
for (const node of nodes) {
|
|
105
106
|
addSizeTo(sum, node.size);
|
|
@@ -145,7 +146,7 @@ const isTooSmall = (size, minSize) => {
|
|
|
145
146
|
* @returns {Types} set of types that are too small
|
|
146
147
|
*/
|
|
147
148
|
const getTooSmallTypes = (size, minSize) => {
|
|
148
|
-
/** @
|
|
149
|
+
/** @type {Types} */
|
|
149
150
|
const types = new Set();
|
|
150
151
|
for (const key of Object.keys(size)) {
|
|
151
152
|
const s = size[key];
|
|
@@ -223,9 +224,13 @@ class Group {
|
|
|
223
224
|
* @returns {Node<T>[] | undefined} removed nodes
|
|
224
225
|
*/
|
|
225
226
|
popNodes(filter) {
|
|
227
|
+
/** @type {Node<T>[]} */
|
|
226
228
|
const newNodes = [];
|
|
229
|
+
/** @type {Similarities} */
|
|
227
230
|
const newSimilarities = [];
|
|
231
|
+
/** @type {Node<T>[]} */
|
|
228
232
|
const resultNodes = [];
|
|
233
|
+
/** @type {undefined | Node<T>} */
|
|
229
234
|
let lastNode;
|
|
230
235
|
for (let i = 0; i < this.nodes.length; i++) {
|
|
231
236
|
const node = this.nodes[i];
|
|
@@ -260,6 +265,7 @@ const getSimilarities = (nodes) => {
|
|
|
260
265
|
// calculate similarities between lexically adjacent nodes
|
|
261
266
|
/** @type {Similarities} */
|
|
262
267
|
const similarities = [];
|
|
268
|
+
/** @type {undefined | Node<T>} */
|
|
263
269
|
let last;
|
|
264
270
|
for (const node of nodes) {
|
|
265
271
|
if (last !== undefined) {
|
|
@@ -399,6 +405,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
399
405
|
// going minSize from left and right
|
|
400
406
|
// at least one node need to be included otherwise we get stuck
|
|
401
407
|
let left = 1;
|
|
408
|
+
/** @type {Sizes} */
|
|
402
409
|
const leftSize = Object.create(null);
|
|
403
410
|
addSizeTo(leftSize, group.nodes[0].size);
|
|
404
411
|
while (left < group.nodes.length && isTooSmall(leftSize, minSize)) {
|
|
@@ -406,6 +413,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
406
413
|
left++;
|
|
407
414
|
}
|
|
408
415
|
let right = group.nodes.length - 2;
|
|
416
|
+
/** @type {Sizes} */
|
|
409
417
|
const rightSize = Object.create(null);
|
|
410
418
|
addSizeTo(rightSize, group.nodes[group.nodes.length - 1].size);
|
|
411
419
|
while (right >= 0 && isTooSmall(rightSize, minSize)) {
|
|
@@ -425,6 +433,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
425
433
|
|
|
426
434
|
if (left - 1 > right) {
|
|
427
435
|
// We try to remove some problematic nodes to "fix" that
|
|
436
|
+
/** @type {Sizes} */
|
|
428
437
|
let prevSize;
|
|
429
438
|
if (right < group.nodes.length - left) {
|
|
430
439
|
subtractSizeFrom(rightSize, group.nodes[right + 1].size);
|
|
@@ -490,6 +499,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
490
499
|
|
|
491
500
|
// create two new groups for left and right area
|
|
492
501
|
// and queue them up
|
|
502
|
+
/** @type {Node<T>[]} */
|
|
493
503
|
const rightNodes = [group.nodes[right + 1]];
|
|
494
504
|
/** @type {Similarities} */
|
|
495
505
|
const rightSimilarities = [];
|
|
@@ -501,6 +511,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
501
511
|
}
|
|
502
512
|
queue.push(new Group(rightNodes, rightSimilarities));
|
|
503
513
|
|
|
514
|
+
/** @type {Node<T>[]} */
|
|
504
515
|
const leftNodes = [group.nodes[0]];
|
|
505
516
|
/** @type {Similarities} */
|
|
506
517
|
const leftSimilarities = [];
|
|
@@ -523,6 +534,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
523
534
|
});
|
|
524
535
|
|
|
525
536
|
// give every group a name
|
|
537
|
+
/** @type {Set<string>} */
|
|
526
538
|
const usedNames = new Set();
|
|
527
539
|
for (let i = 0; i < result.length; i++) {
|
|
528
540
|
const group = result[i];
|
|
@@ -10,16 +10,10 @@ const urlUtils = require("url");
|
|
|
10
10
|
const { isAbsolute, join } = require("./fs");
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("./fs").InputFileSystem} InputFileSystem */
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {(input: string | Buffer<ArrayBufferLike>, resourcePath: string, fs: InputFileSystem) => Promise<{source: string | Buffer<ArrayBufferLike>, sourceMap: string | RawSourceMap | undefined, fileDependencies: string[]}>} SourceMapExtractorFunction
|
|
16
|
-
*/
|
|
17
|
-
|
|
13
|
+
/** @typedef {string | Buffer<ArrayBufferLike>} StringOrBuffer */
|
|
14
|
+
/** @typedef {(input: StringOrBuffer, resourcePath: string, fs: InputFileSystem) => Promise<{ source: StringOrBuffer, sourceMap: string | RawSourceMap | undefined, fileDependencies: string[] }>} SourceMapExtractorFunction */
|
|
18
15
|
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {(resourcePath: string) => Promise<string | Buffer<ArrayBufferLike>>} ReadResource
|
|
22
|
-
*/
|
|
16
|
+
/** @typedef {(resourcePath: string) => Promise<StringOrBuffer>} ReadResource */
|
|
23
17
|
|
|
24
18
|
/**
|
|
25
19
|
* @typedef {object} SourceMappingURL
|
|
@@ -52,6 +46,7 @@ const sourceMappingURLRegex = new RegExp(
|
|
|
52
46
|
*/
|
|
53
47
|
function getSourceMappingURL(code) {
|
|
54
48
|
const lines = code.split(/^/m);
|
|
49
|
+
/** @type {RegExpMatchArray | null | undefined} */
|
|
55
50
|
let match;
|
|
56
51
|
|
|
57
52
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
@@ -104,13 +99,14 @@ function isURL(value) {
|
|
|
104
99
|
* @param {ReadResource} readResource read resource function
|
|
105
100
|
* @param {string[]} possibleRequests array of possible file paths
|
|
106
101
|
* @param {string} errorsAccumulator accumulated error messages
|
|
107
|
-
* @returns {Promise<{path: string, data?: string}>} source content promise
|
|
102
|
+
* @returns {Promise<{ path: string, data?: string }>} source content promise
|
|
108
103
|
*/
|
|
109
104
|
async function fetchPathsFromURL(
|
|
110
105
|
readResource,
|
|
111
106
|
possibleRequests,
|
|
112
107
|
errorsAccumulator = ""
|
|
113
108
|
) {
|
|
109
|
+
/** @type {StringOrBuffer} */
|
|
114
110
|
let result;
|
|
115
111
|
|
|
116
112
|
try {
|
|
@@ -146,7 +142,7 @@ async function fetchPathsFromURL(
|
|
|
146
142
|
* @param {string} url source URL
|
|
147
143
|
* @param {string=} sourceRoot source root directory
|
|
148
144
|
* @param {boolean=} skipReading whether to skip reading file content
|
|
149
|
-
* @returns {Promise<{sourceURL: string, sourceContent?:
|
|
145
|
+
* @returns {Promise<{ sourceURL: string, sourceContent?: StringOrBuffer }>} source content promise
|
|
150
146
|
*/
|
|
151
147
|
async function fetchFromURL(
|
|
152
148
|
readResource,
|
|
@@ -181,9 +177,11 @@ async function fetchFromURL(
|
|
|
181
177
|
if (isAbsolute(url)) {
|
|
182
178
|
let sourceURL = path.normalize(url);
|
|
183
179
|
|
|
180
|
+
/** @type {undefined | StringOrBuffer} */
|
|
184
181
|
let sourceContent;
|
|
185
182
|
|
|
186
183
|
if (!skipReading) {
|
|
184
|
+
/** @type {string[]} */
|
|
187
185
|
const possibleRequests = [sourceURL];
|
|
188
186
|
|
|
189
187
|
if (url.startsWith("/")) {
|
|
@@ -203,6 +201,7 @@ async function fetchFromURL(
|
|
|
203
201
|
|
|
204
202
|
// 4. Relative path
|
|
205
203
|
const sourceURL = getAbsolutePath(context, url, sourceRoot || "");
|
|
204
|
+
/** @type {undefined | StringOrBuffer} */
|
|
206
205
|
let sourceContent;
|
|
207
206
|
|
|
208
207
|
if (!skipReading) {
|
|
@@ -214,10 +213,10 @@ async function fetchFromURL(
|
|
|
214
213
|
|
|
215
214
|
/**
|
|
216
215
|
* Extract source map from code content
|
|
217
|
-
* @param {
|
|
216
|
+
* @param {StringOrBuffer} stringOrBuffer The input code content as string or buffer
|
|
218
217
|
* @param {string} resourcePath The path to the resource file
|
|
219
218
|
* @param {ReadResource} readResource The read resource function
|
|
220
|
-
* @returns {Promise<{source:
|
|
219
|
+
* @returns {Promise<{ source: StringOrBuffer, sourceMap: string | RawSourceMap | undefined }>} Promise resolving to extracted source map information
|
|
221
220
|
*/
|
|
222
221
|
async function extractSourceMap(stringOrBuffer, resourcePath, readResource) {
|
|
223
222
|
const input =
|
package/lib/util/fs.js
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
const path = require("path");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
|
|
11
|
-
/** @typedef {import("
|
|
11
|
+
/** @typedef {import("watchpack").Entry} Entry */
|
|
12
|
+
/** @typedef {import("watchpack").OnlySafeTimeEntry} OnlySafeTimeEntry */
|
|
13
|
+
/** @typedef {import("watchpack").ExistenceOnlyTimeEntry} ExistenceOnlyTimeEntry */
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @template T
|
|
@@ -83,7 +85,7 @@ const path = require("path");
|
|
|
83
85
|
/** @typedef {(err: NodeJS.ErrnoException | null, result?: number) => void} NumberCallback */
|
|
84
86
|
/** @typedef {(err: NodeJS.ErrnoException | Error | null, result?: JsonObject) => void} ReadJsonCallback */
|
|
85
87
|
|
|
86
|
-
/** @typedef {Map<string,
|
|
88
|
+
/** @typedef {Map<string, Entry | OnlySafeTimeEntry | ExistenceOnlyTimeEntry | null | "ignore">} TimeInfoEntries */
|
|
87
89
|
|
|
88
90
|
/** @typedef {Set<string>} Changes */
|
|
89
91
|
/** @typedef {Set<string>} Removals */
|
|
@@ -201,7 +203,7 @@ const path = require("path");
|
|
|
201
203
|
|
|
202
204
|
/**
|
|
203
205
|
* @typedef {{
|
|
204
|
-
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined
|
|
206
|
+
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | null): string[],
|
|
205
207
|
* (path: PathLike, options: { encoding: "buffer", withFileTypes?: false | undefined, recursive?: boolean | undefined } | "buffer"): Buffer[],
|
|
206
208
|
* (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[],
|
|
207
209
|
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[],
|
|
@@ -225,8 +227,8 @@ const path = require("path");
|
|
|
225
227
|
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined,
|
|
226
228
|
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats,
|
|
227
229
|
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats,
|
|
228
|
-
* (path: PathLike,
|
|
229
|
-
* (path: PathLike,
|
|
230
|
+
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats,
|
|
231
|
+
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined,
|
|
230
232
|
* }} StatSync
|
|
231
233
|
*/
|
|
232
234
|
|
|
@@ -246,8 +248,8 @@ const path = require("path");
|
|
|
246
248
|
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined,
|
|
247
249
|
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats,
|
|
248
250
|
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats,
|
|
249
|
-
* (path: PathLike,
|
|
250
|
-
* (path: PathLike,
|
|
251
|
+
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats,
|
|
252
|
+
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined,
|
|
251
253
|
* }} LStatSync
|
|
252
254
|
*/
|
|
253
255
|
|
|
@@ -256,7 +258,7 @@ const path = require("path");
|
|
|
256
258
|
* (path: PathLike, options: EncodingOption, callback: StringCallback): void,
|
|
257
259
|
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void,
|
|
258
260
|
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void,
|
|
259
|
-
* (path: PathLike, callback: StringCallback): void
|
|
261
|
+
* (path: PathLike, callback: StringCallback): void,
|
|
260
262
|
* }} RealPath
|
|
261
263
|
*/
|
|
262
264
|
|
|
@@ -324,21 +326,14 @@ const path = require("path");
|
|
|
324
326
|
/**
|
|
325
327
|
* @typedef {{
|
|
326
328
|
* (file: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: StringCallback): void,
|
|
327
|
-
* (file: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined
|
|
329
|
+
* (file: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined }) | null | undefined, callback: NoParamCallback): void,
|
|
328
330
|
* (file: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: StringCallback): void,
|
|
329
331
|
* (file: PathLike, callback: NoParamCallback): void,
|
|
330
332
|
* }} Mkdir
|
|
331
333
|
*/
|
|
332
334
|
|
|
333
335
|
/**
|
|
334
|
-
* @typedef {{
|
|
335
|
-
*/
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* @typedef {{
|
|
339
|
-
* (file: PathLike, callback: NoParamCallback): void,
|
|
340
|
-
* (file: PathLike, options: RmDirOptions, callback: NoParamCallback): void,
|
|
341
|
-
* }} Rmdir
|
|
336
|
+
* @typedef {{ (file: PathLike, callback: NoParamCallback): void }} Rmdir
|
|
342
337
|
*/
|
|
343
338
|
|
|
344
339
|
/**
|
|
@@ -405,7 +400,7 @@ const path = require("path");
|
|
|
405
400
|
*/
|
|
406
401
|
|
|
407
402
|
/**
|
|
408
|
-
* @typedef {FSImplementation & { write: (...args: EXPECTED_ANY[]) => EXPECTED_ANY
|
|
403
|
+
* @typedef {FSImplementation & { write: (...args: EXPECTED_ANY[]) => EXPECTED_ANY, close?: (...args: EXPECTED_ANY[]) => EXPECTED_ANY }} CreateWriteStreamFSImplementation
|
|
409
404
|
*/
|
|
410
405
|
|
|
411
406
|
/**
|
|
@@ -422,7 +417,7 @@ const path = require("path");
|
|
|
422
417
|
|
|
423
418
|
/**
|
|
424
419
|
* @typedef {{
|
|
425
|
-
* (file: PathLike, flags: OpenMode | undefined,
|
|
420
|
+
* (file: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: NumberCallback): void,
|
|
426
421
|
* (file: PathLike, flags: OpenMode | undefined, callback: NumberCallback): void,
|
|
427
422
|
* (file: PathLike, callback: NumberCallback): void,
|
|
428
423
|
* }} Open
|
|
@@ -613,6 +608,7 @@ const readJson = (fs, p, callback) => {
|
|
|
613
608
|
}
|
|
614
609
|
fs.readFile(p, (err, buf) => {
|
|
615
610
|
if (err) return callback(err);
|
|
611
|
+
/** @type {JsonObject} */
|
|
616
612
|
let data;
|
|
617
613
|
try {
|
|
618
614
|
data = JSON.parse(/** @type {Buffer} */ (buf).toString("utf8"));
|
|
@@ -17,8 +17,11 @@ class BatchedHash extends Hash {
|
|
|
17
17
|
*/
|
|
18
18
|
constructor(hash) {
|
|
19
19
|
super();
|
|
20
|
+
/** @type {undefined | string} */
|
|
20
21
|
this.string = undefined;
|
|
22
|
+
/** @type {undefined | Encoding} */
|
|
21
23
|
this.encoding = undefined;
|
|
24
|
+
/** @type {Hash} */
|
|
22
25
|
this.hash = hash;
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -15,7 +15,7 @@ const BULK_SIZE = 3;
|
|
|
15
15
|
|
|
16
16
|
// We are using an object instead of a Map as this will stay static during the runtime
|
|
17
17
|
// so access to it can be optimized by v8
|
|
18
|
-
/** @type {{[key: string]: Map<string, string>}} */
|
|
18
|
+
/** @type {{ [key: string]: Map<string, string> }} */
|
|
19
19
|
const digestCaches = {};
|
|
20
20
|
|
|
21
21
|
class BulkUpdateHash extends Hash {
|
|
@@ -25,12 +25,17 @@ class BulkUpdateHash extends Hash {
|
|
|
25
25
|
*/
|
|
26
26
|
constructor(hashOrFactory, hashKey) {
|
|
27
27
|
super();
|
|
28
|
+
/** @type {undefined | string} */
|
|
28
29
|
this.hashKey = hashKey;
|
|
29
30
|
if (typeof hashOrFactory === "function") {
|
|
31
|
+
/** @type {undefined | HashFactory} */
|
|
30
32
|
this.hashFactory = hashOrFactory;
|
|
33
|
+
/** @type {undefined | Hash} */
|
|
31
34
|
this.hash = undefined;
|
|
32
35
|
} else {
|
|
36
|
+
/** @type {undefined | HashFactory} */
|
|
33
37
|
this.hashFactory = undefined;
|
|
38
|
+
/** @type {undefined | Hash} */
|
|
34
39
|
this.hash = hashOrFactory;
|
|
35
40
|
}
|
|
36
41
|
this.buffer = "";
|
|
@@ -103,6 +108,7 @@ class BulkUpdateHash extends Hash {
|
|
|
103
108
|
* @returns {string | Buffer} digest
|
|
104
109
|
*/
|
|
105
110
|
digest(encoding) {
|
|
111
|
+
/** @type {undefined | Map<string, string | Buffer>} */
|
|
106
112
|
let digestCache;
|
|
107
113
|
const buffer = this.buffer;
|
|
108
114
|
if (this.hash === undefined) {
|
|
@@ -49,6 +49,7 @@ const encode = (buffer, base) => {
|
|
|
49
49
|
value = (value << EIGHT) | BigInt(buffer[i]);
|
|
50
50
|
}
|
|
51
51
|
// Convert to baseX string efficiently using array
|
|
52
|
+
/** @type {string[]} */
|
|
52
53
|
const digits = [];
|
|
53
54
|
if (value === ZERO) return ENCODE_TABLE[base][0];
|
|
54
55
|
while (value > ZERO) {
|
|
@@ -13,6 +13,14 @@ const Hash = require("../Hash");
|
|
|
13
13
|
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
|
14
14
|
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {object} WasmExports
|
|
18
|
+
* @property {WebAssembly.Memory} memory
|
|
19
|
+
* @property {() => void} init
|
|
20
|
+
* @property {(length: number) => void} update
|
|
21
|
+
* @property {(length: number) => void} final
|
|
22
|
+
*/
|
|
23
|
+
|
|
16
24
|
class WasmHash extends Hash {
|
|
17
25
|
/**
|
|
18
26
|
* @param {WebAssembly.Instance} instance wasm instance
|
|
@@ -23,13 +31,19 @@ class WasmHash extends Hash {
|
|
|
23
31
|
constructor(instance, instancesPool, chunkSize, digestSize) {
|
|
24
32
|
super();
|
|
25
33
|
|
|
26
|
-
const exports = /** @type {
|
|
34
|
+
const exports = /** @type {WasmExports} */ (instance.exports);
|
|
27
35
|
exports.init();
|
|
36
|
+
/** @type {WasmExports} */
|
|
28
37
|
this.exports = exports;
|
|
38
|
+
/** @type {Buffer} */
|
|
29
39
|
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
|
40
|
+
/** @type {number} */
|
|
30
41
|
this.buffered = 0;
|
|
42
|
+
/** @type {WebAssembly.Instance[]} */
|
|
31
43
|
this.instancesPool = instancesPool;
|
|
44
|
+
/** @type {number} */
|
|
32
45
|
this.chunkSize = chunkSize;
|
|
46
|
+
/** @type {number} */
|
|
33
47
|
this.digestSize = digestSize;
|
|
34
48
|
}
|
|
35
49
|
|
|
@@ -85,6 +99,7 @@ class WasmHash extends Hash {
|
|
|
85
99
|
*/
|
|
86
100
|
_updateWithShortString(data, encoding) {
|
|
87
101
|
const { exports, buffered, mem, chunkSize } = this;
|
|
102
|
+
/** @type {number} */
|
|
88
103
|
let endPos;
|
|
89
104
|
if (data.length < 70) {
|
|
90
105
|
// eslint-disable-next-line unicorn/text-encoding-identifier-case
|
package/lib/util/identifier.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const path = require("path");
|
|
8
8
|
|
|
9
|
-
const WINDOWS_ABS_PATH_REGEXP = /^[a-
|
|
9
|
+
const WINDOWS_ABS_PATH_REGEXP = /^[a-z]:[\\/]/i;
|
|
10
10
|
const SEGMENTS_SPLIT_REGEXP = /([|!])/;
|
|
11
11
|
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
12
12
|
|
|
@@ -165,7 +165,8 @@ const makeCacheable = (realFn) => {
|
|
|
165
165
|
* @returns {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} cacheable function with context
|
|
166
166
|
*/
|
|
167
167
|
const makeCacheableWithContext = (fn) => {
|
|
168
|
-
/** @
|
|
168
|
+
/** @typedef {Map<string, Map<string, string>>} InnerCache */
|
|
169
|
+
/** @type {WeakMap<AssociatedObjectForCache, InnerCache>} */
|
|
169
170
|
const cache = new WeakMap();
|
|
170
171
|
|
|
171
172
|
/** @type {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} */
|
|
@@ -178,6 +179,7 @@ const makeCacheableWithContext = (fn) => {
|
|
|
178
179
|
cache.set(associatedObjectForCache, innerCache);
|
|
179
180
|
}
|
|
180
181
|
|
|
182
|
+
/** @type {undefined | string} */
|
|
181
183
|
let cachedResult;
|
|
182
184
|
let innerSubCache = innerCache.get(context);
|
|
183
185
|
if (innerSubCache === undefined) {
|
|
@@ -196,6 +198,7 @@ const makeCacheableWithContext = (fn) => {
|
|
|
196
198
|
|
|
197
199
|
/** @type {BindCacheForContext} */
|
|
198
200
|
cachedFn.bindCache = (associatedObjectForCache) => {
|
|
201
|
+
/** @type {undefined | InnerCache} */
|
|
199
202
|
let innerCache;
|
|
200
203
|
if (associatedObjectForCache) {
|
|
201
204
|
innerCache = cache.get(associatedObjectForCache);
|
|
@@ -213,6 +216,7 @@ const makeCacheableWithContext = (fn) => {
|
|
|
213
216
|
* @returns {string} the returned relative path
|
|
214
217
|
*/
|
|
215
218
|
const boundFn = (context, identifier) => {
|
|
219
|
+
/** @type {undefined | string} */
|
|
216
220
|
let cachedResult;
|
|
217
221
|
let innerSubCache = innerCache.get(context);
|
|
218
222
|
if (innerSubCache === undefined) {
|
|
@@ -234,6 +238,7 @@ const makeCacheableWithContext = (fn) => {
|
|
|
234
238
|
|
|
235
239
|
/** @type {BindContextCacheForContext} */
|
|
236
240
|
cachedFn.bindContextCache = (context, associatedObjectForCache) => {
|
|
241
|
+
/** @type {undefined | Map<string, string>} */
|
|
237
242
|
let innerSubCache;
|
|
238
243
|
if (associatedObjectForCache) {
|
|
239
244
|
let innerCache = cache.get(associatedObjectForCache);
|
package/lib/util/magicComment.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports.createMagicCommentContext = () =>
|
|
|
16
16
|
codeGeneration: { strings: false, wasm: false }
|
|
17
17
|
});
|
|
18
18
|
module.exports.webpackCommentRegExp = new RegExp(
|
|
19
|
-
/(^|\W)webpack[A-Z]
|
|
19
|
+
/(^|\W)webpack[A-Z][A-Za-z]+:/
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
// regexp to match at least one "magic comment"
|
package/lib/util/propertyName.js
CHANGED
package/lib/util/runtime.js
CHANGED
|
@@ -10,7 +10,8 @@ const SortableSet = require("./SortableSet");
|
|
|
10
10
|
/** @typedef {import("../Compilation")} Compilation */
|
|
11
11
|
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
|
12
12
|
|
|
13
|
-
/** @typedef {
|
|
13
|
+
/** @typedef {SortableSet<string>} RuntimeSpecSortableSet */
|
|
14
|
+
/** @typedef {string | RuntimeSpecSortableSet | undefined} RuntimeSpec */
|
|
14
15
|
/** @typedef {RuntimeSpec | boolean} RuntimeCondition */
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -20,7 +21,9 @@ const SortableSet = require("./SortableSet");
|
|
|
20
21
|
* @returns {RuntimeSpec} runtime
|
|
21
22
|
*/
|
|
22
23
|
const getEntryRuntime = (compilation, name, options) => {
|
|
24
|
+
/** @type {EntryOptions["dependOn"]} */
|
|
23
25
|
let dependOn;
|
|
26
|
+
/** @type {EntryOptions["runtime"]} */
|
|
24
27
|
let runtime;
|
|
25
28
|
if (options) {
|
|
26
29
|
({ dependOn, runtime } = options);
|
|
@@ -194,6 +197,7 @@ const mergeRuntime = (a, b) => {
|
|
|
194
197
|
return a;
|
|
195
198
|
} else if (typeof a === "string") {
|
|
196
199
|
if (typeof b === "string") {
|
|
200
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
197
201
|
const set = new SortableSet();
|
|
198
202
|
set.add(a);
|
|
199
203
|
set.add(b);
|
|
@@ -201,16 +205,19 @@ const mergeRuntime = (a, b) => {
|
|
|
201
205
|
} else if (b.has(a)) {
|
|
202
206
|
return b;
|
|
203
207
|
}
|
|
208
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
204
209
|
const set = new SortableSet(b);
|
|
205
210
|
set.add(a);
|
|
206
211
|
return set;
|
|
207
212
|
}
|
|
208
213
|
if (typeof b === "string") {
|
|
209
214
|
if (a.has(b)) return a;
|
|
215
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
210
216
|
const set = new SortableSet(a);
|
|
211
217
|
set.add(b);
|
|
212
218
|
return set;
|
|
213
219
|
}
|
|
220
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
214
221
|
const set = new SortableSet(a);
|
|
215
222
|
for (const item of b) set.add(item);
|
|
216
223
|
if (set.size === a.size) return a;
|
|
@@ -271,14 +278,17 @@ const mergeRuntimeOwned = (a, b) => {
|
|
|
271
278
|
if (typeof b === "string") {
|
|
272
279
|
return b;
|
|
273
280
|
}
|
|
281
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
274
282
|
return new SortableSet(b);
|
|
275
283
|
} else if (typeof a === "string") {
|
|
276
284
|
if (typeof b === "string") {
|
|
285
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
277
286
|
const set = new SortableSet();
|
|
278
287
|
set.add(a);
|
|
279
288
|
set.add(b);
|
|
280
289
|
return set;
|
|
281
290
|
}
|
|
291
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
282
292
|
const set = new SortableSet(b);
|
|
283
293
|
set.add(a);
|
|
284
294
|
return set;
|
|
@@ -315,6 +325,7 @@ const intersectRuntime = (a, b) => {
|
|
|
315
325
|
if (a.has(b)) return b;
|
|
316
326
|
return;
|
|
317
327
|
}
|
|
328
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
318
329
|
const set = new SortableSet();
|
|
319
330
|
for (const item of b) {
|
|
320
331
|
if (a.has(item)) set.add(item);
|
|
@@ -354,10 +365,12 @@ const subtractRuntime = (a, b) => {
|
|
|
354
365
|
if (item !== b) return item;
|
|
355
366
|
}
|
|
356
367
|
}
|
|
368
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
357
369
|
const set = new SortableSet(a);
|
|
358
370
|
set.delete(b);
|
|
359
371
|
return set;
|
|
360
372
|
}
|
|
373
|
+
/** @type {RuntimeSpecSortableSet} */
|
|
361
374
|
const set = new SortableSet();
|
|
362
375
|
for (const item of a) {
|
|
363
376
|
if (!b.has(item)) set.add(item);
|
|
@@ -394,6 +407,7 @@ const filterRuntime = (runtime, filter) => {
|
|
|
394
407
|
if (typeof runtime === "string") return filter(runtime);
|
|
395
408
|
let some = false;
|
|
396
409
|
let every = true;
|
|
410
|
+
/** @type {RuntimeSpec} */
|
|
397
411
|
let result;
|
|
398
412
|
for (const r of runtime) {
|
|
399
413
|
const v = filter(r);
|