webpack 5.98.0 → 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 +7 -3
- 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 +326 -152
- 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 +40 -17
- 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 +13 -13
- 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 +50 -8
- 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 +93 -26
- 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/CssModulesPlugin.js +30 -5
- 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 +8 -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 +17 -14
- 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 +24 -8
- 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/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 +51 -31
- 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 -2
- package/lib/json/JsonParser.js +8 -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 +87 -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/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 +80 -78
- 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/serialization.js +5 -16
- package/lib/util/smartGrouping.js +3 -3
- 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/UniversalCompileAsyncWasmPlugin.js +4 -0
- package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +9 -4
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
- package/package.json +19 -17
- 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/SourceMapDevToolPlugin.json +2 -2
- package/types.d.ts +918 -615
- package/lib/library/ModernModuleLibraryPlugin.js +0 -144
package/lib/util/deprecation.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
const util = require("util");
|
9
9
|
|
10
|
-
/** @type {Map<string,
|
10
|
+
/** @type {Map<string, () => void>} */
|
11
11
|
const deprecationCache = new Map();
|
12
12
|
|
13
13
|
/**
|
@@ -23,7 +23,7 @@ const deprecationCache = new Map();
|
|
23
23
|
/**
|
24
24
|
* @param {string} message deprecation message
|
25
25
|
* @param {string} code deprecation code
|
26
|
-
* @returns {
|
26
|
+
* @returns {() => void} function to trigger deprecation
|
27
27
|
*/
|
28
28
|
const createDeprecation = (message, code) => {
|
29
29
|
const cached = deprecationCache.get(message);
|
@@ -37,6 +37,9 @@ const createDeprecation = (message, code) => {
|
|
37
37
|
return fn;
|
38
38
|
};
|
39
39
|
|
40
|
+
/** @typedef {"concat" | "entry" | "filter" | "find" | "findIndex" | "includes" | "indexOf" | "join" | "lastIndexOf" | "map" | "reduce" | "reduceRight" | "slice" | "some"} COPY_METHODS_NAMES */
|
41
|
+
|
42
|
+
/** @type {COPY_METHODS_NAMES[]} */
|
40
43
|
const COPY_METHODS = [
|
41
44
|
"concat",
|
42
45
|
"entry",
|
@@ -54,6 +57,9 @@ const COPY_METHODS = [
|
|
54
57
|
"some"
|
55
58
|
];
|
56
59
|
|
60
|
+
/** @typedef {"copyWithin" | "entries" | "fill" | "keys" | "pop" | "reverse" | "shift" | "splice" | "sort" | "unshift"} DISABLED_METHODS_NAMES */
|
61
|
+
|
62
|
+
/** @type {DISABLED_METHODS_NAMES[]} */
|
57
63
|
const DISABLED_METHODS = [
|
58
64
|
"copyWithin",
|
59
65
|
"entries",
|
@@ -68,7 +74,13 @@ const DISABLED_METHODS = [
|
|
68
74
|
];
|
69
75
|
|
70
76
|
/**
|
71
|
-
* @
|
77
|
+
* @template T
|
78
|
+
* @typedef {Set<T> & {[Symbol.isConcatSpreadable]?: boolean} & { push?: (...items: T[]) => void } & { [P in DISABLED_METHODS_NAMES]?: () => void } & { [P in COPY_METHODS_NAMES]?: () => TODO }} SetWithDeprecatedArrayMethods
|
79
|
+
*/
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @template T
|
83
|
+
* @param {SetWithDeprecatedArrayMethods<T>} set new set
|
72
84
|
* @param {string} name property name
|
73
85
|
* @returns {void}
|
74
86
|
*/
|
@@ -81,7 +93,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
|
81
93
|
);
|
82
94
|
/**
|
83
95
|
* @deprecated
|
84
|
-
* @this {Set<
|
96
|
+
* @this {Set<T>}
|
85
97
|
* @returns {number} count
|
86
98
|
*/
|
87
99
|
set[method] = function () {
|
@@ -108,7 +120,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
|
108
120
|
);
|
109
121
|
/**
|
110
122
|
* @deprecated
|
111
|
-
* @this {Set<
|
123
|
+
* @this {Set<T>}
|
112
124
|
* @returns {number} count
|
113
125
|
*/
|
114
126
|
set.push = function () {
|
@@ -121,6 +133,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
|
121
133
|
};
|
122
134
|
for (const method of DISABLED_METHODS) {
|
123
135
|
if (set[method]) continue;
|
136
|
+
|
124
137
|
set[method] = () => {
|
125
138
|
throw new Error(
|
126
139
|
`${name} was changed from Array to Set (using Array method '${method}' is not possible)`
|
@@ -129,12 +142,12 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
|
129
142
|
}
|
130
143
|
/**
|
131
144
|
* @param {number} index index
|
132
|
-
* @returns {
|
145
|
+
* @returns {() => T | undefined} value
|
133
146
|
*/
|
134
147
|
const createIndexGetter = index => {
|
135
148
|
/**
|
136
|
-
* @this {Set<
|
137
|
-
* @returns {
|
149
|
+
* @this {Set<T>} a Set
|
150
|
+
* @returns {T | undefined} the value at this location
|
138
151
|
*/
|
139
152
|
// eslint-disable-next-line func-style
|
140
153
|
const fn = function () {
|
@@ -214,67 +227,56 @@ module.exports.createArrayToSetDeprecationSet = name => {
|
|
214
227
|
* @param {string} name property name
|
215
228
|
* @param {string} code deprecation code
|
216
229
|
* @param {string} note additional note
|
217
|
-
* @returns {
|
230
|
+
* @returns {T} frozen object with deprecation when modifying
|
218
231
|
*/
|
219
232
|
module.exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
220
233
|
const message = `${name} will be frozen in future, all modifications are deprecated.${
|
221
234
|
note && `\n${note}`
|
222
235
|
}`;
|
223
|
-
return /** @type {
|
224
|
-
new Proxy(
|
236
|
+
return /** @type {T} */ (
|
237
|
+
new Proxy(obj, {
|
225
238
|
set: util.deprecate(
|
226
239
|
/**
|
227
|
-
* @param {
|
240
|
+
* @param {object} target target
|
228
241
|
* @param {string | symbol} property property
|
229
|
-
* @param {
|
230
|
-
* @param {
|
242
|
+
* @param {EXPECTED_ANY} value value
|
243
|
+
* @param {EXPECTED_ANY} receiver receiver
|
231
244
|
* @returns {boolean} result
|
232
245
|
*/
|
233
246
|
(target, property, value, receiver) =>
|
234
|
-
Reflect.set(
|
235
|
-
/** @type {object} */ (target),
|
236
|
-
property,
|
237
|
-
value,
|
238
|
-
receiver
|
239
|
-
),
|
247
|
+
Reflect.set(target, property, value, receiver),
|
240
248
|
message,
|
241
249
|
code
|
242
250
|
),
|
243
251
|
defineProperty: util.deprecate(
|
244
252
|
/**
|
245
|
-
* @param {
|
253
|
+
* @param {object} target target
|
246
254
|
* @param {string | symbol} property property
|
247
255
|
* @param {PropertyDescriptor} descriptor descriptor
|
248
256
|
* @returns {boolean} result
|
249
257
|
*/
|
250
258
|
(target, property, descriptor) =>
|
251
|
-
Reflect.defineProperty(
|
252
|
-
/** @type {object} */ (target),
|
253
|
-
property,
|
254
|
-
descriptor
|
255
|
-
),
|
259
|
+
Reflect.defineProperty(target, property, descriptor),
|
256
260
|
message,
|
257
261
|
code
|
258
262
|
),
|
259
263
|
deleteProperty: util.deprecate(
|
260
264
|
/**
|
261
|
-
* @param {
|
265
|
+
* @param {object} target target
|
262
266
|
* @param {string | symbol} property property
|
263
267
|
* @returns {boolean} result
|
264
268
|
*/
|
265
|
-
(target, property) =>
|
266
|
-
Reflect.deleteProperty(/** @type {object} */ (target), property),
|
269
|
+
(target, property) => Reflect.deleteProperty(target, property),
|
267
270
|
message,
|
268
271
|
code
|
269
272
|
),
|
270
273
|
setPrototypeOf: util.deprecate(
|
271
274
|
/**
|
272
|
-
* @param {
|
273
|
-
* @param {
|
275
|
+
* @param {object} target target
|
276
|
+
* @param {EXPECTED_OBJECT | null} proto proto
|
274
277
|
* @returns {boolean} result
|
275
278
|
*/
|
276
|
-
(target, proto) =>
|
277
|
-
Reflect.setPrototypeOf(/** @type {object} */ (target), proto),
|
279
|
+
(target, proto) => Reflect.setPrototypeOf(target, proto),
|
278
280
|
message,
|
279
281
|
code
|
280
282
|
)
|
@@ -152,15 +152,15 @@ const getTooSmallTypes = (size, minSize) => {
|
|
152
152
|
};
|
153
153
|
|
154
154
|
/**
|
155
|
-
* @template T
|
156
|
-
* @param {
|
155
|
+
* @template {object} T
|
156
|
+
* @param {T} size size
|
157
157
|
* @param {Set<string>} types types
|
158
158
|
* @returns {number} number of matching size types
|
159
159
|
*/
|
160
160
|
const getNumberOfMatchingSizeTypes = (size, types) => {
|
161
161
|
let i = 0;
|
162
162
|
for (const key of Object.keys(size)) {
|
163
|
-
if (size[key] !== 0 && types.has(key)) i++;
|
163
|
+
if (size[/** @type {keyof T} */ (key)] !== 0 && types.has(key)) i++;
|
164
164
|
}
|
165
165
|
return i;
|
166
166
|
};
|
@@ -212,7 +212,7 @@ class Group {
|
|
212
212
|
}
|
213
213
|
|
214
214
|
/**
|
215
|
-
* @param {
|
215
|
+
* @param {(node: Node<T>) => boolean} filter filter function
|
216
216
|
* @returns {Node<T>[] | undefined} removed nodes
|
217
217
|
*/
|
218
218
|
popNodes(filter) {
|
@@ -277,8 +277,8 @@ const getSimilarities = nodes => {
|
|
277
277
|
* @property {Record<string, number>} maxSize maximum size of a group
|
278
278
|
* @property {Record<string, number>} minSize minimum size of a group (preferred over maximum size)
|
279
279
|
* @property {Iterable<T>} items a list of items
|
280
|
-
* @property {
|
281
|
-
* @property {
|
280
|
+
* @property {(item: T) => Record<string, number>} getSize function to get size of an item
|
281
|
+
* @property {(item: T) => string} getKey function to get the key of an item
|
282
282
|
*/
|
283
283
|
|
284
284
|
/**
|
@@ -49,7 +49,7 @@ class Cycle {
|
|
49
49
|
/**
|
50
50
|
* @template T
|
51
51
|
* @param {Iterable<T>} items list of items
|
52
|
-
* @param {
|
52
|
+
* @param {(item: T) => Iterable<T>} getDependencies function to get dependencies of an item (items that are not in list are ignored)
|
53
53
|
* @returns {Iterable<T>} graph roots of the items
|
54
54
|
*/
|
55
55
|
module.exports = (items, getDependencies) => {
|
package/lib/util/fs.js
CHANGED
@@ -63,22 +63,22 @@ const path = require("path");
|
|
63
63
|
|
64
64
|
/** @typedef {string | number | boolean | null} JsonPrimitive */
|
65
65
|
/** @typedef {JsonValue[]} JsonArray */
|
66
|
-
/** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
|
67
66
|
/** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */
|
67
|
+
/** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
|
68
68
|
|
69
|
-
/** @typedef {
|
70
|
-
/** @typedef {
|
71
|
-
/** @typedef {
|
72
|
-
/** @typedef {
|
73
|
-
/** @typedef {
|
74
|
-
/** @typedef {
|
75
|
-
/** @typedef {
|
76
|
-
/** @typedef {
|
77
|
-
/** @typedef {
|
78
|
-
/** @typedef {
|
79
|
-
/** @typedef {
|
80
|
-
/** @typedef {
|
81
|
-
/** @typedef {
|
69
|
+
/** @typedef {(err: NodeJS.ErrnoException | null) => void} NoParamCallback */
|
70
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: string) => void} StringCallback */
|
71
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: Buffer) => void} BufferCallback */
|
72
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: string | Buffer) => void} StringOrBufferCallback */
|
73
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: string[]) => void} ReaddirStringCallback */
|
74
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: Buffer[]) => void} ReaddirBufferCallback */
|
75
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: string[] | Buffer[]) => void} ReaddirStringOrBufferCallback */
|
76
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: Dirent[]) => void} ReaddirDirentCallback */
|
77
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: IStats) => void} StatsCallback */
|
78
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: IBigIntStats) => void} BigIntStatsCallback */
|
79
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: IStats | IBigIntStats) => void} StatsOrBigIntStatsCallback */
|
80
|
+
/** @typedef {(err: NodeJS.ErrnoException | null, result?: number) => void} NumberCallback */
|
81
|
+
/** @typedef {(err: NodeJS.ErrnoException | Error | null, result?: JsonObject) => void} ReadJsonCallback */
|
82
82
|
|
83
83
|
/** @typedef {Map<string, FileSystemInfoEntry | "ignore">} TimeInfoEntries */
|
84
84
|
|
@@ -96,13 +96,13 @@ const path = require("path");
|
|
96
96
|
// TODO webpack 6 deprecate missing getInfo
|
97
97
|
/**
|
98
98
|
* @typedef {object} Watcher
|
99
|
-
* @property {
|
100
|
-
* @property {
|
101
|
-
* @property {(
|
102
|
-
* @property {(
|
103
|
-
* @property {
|
104
|
-
* @property {
|
105
|
-
* @property {
|
99
|
+
* @property {() => void} close closes the watcher and all underlying file watchers
|
100
|
+
* @property {() => void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
|
101
|
+
* @property {(() => Changes | null)=} getAggregatedChanges get current aggregated changes that have not yet send to callback
|
102
|
+
* @property {(() => Removals | null)=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
|
103
|
+
* @property {() => TimeInfoEntries} getFileTimeInfoEntries get info about files
|
104
|
+
* @property {() => TimeInfoEntries} getContextTimeInfoEntries get info about directories
|
105
|
+
* @property {() => WatcherInfo=} getInfo get info about timestamps and changes
|
106
106
|
*/
|
107
107
|
|
108
108
|
/**
|
@@ -112,8 +112,8 @@ const path = require("path");
|
|
112
112
|
* @param {Iterable<string>} missing watched existence entries
|
113
113
|
* @param {number} startTime timestamp of start time
|
114
114
|
* @param {WatchOptions} options options object
|
115
|
-
* @param {
|
116
|
-
* @param {
|
115
|
+
* @param {(err: Error | null, timeInfoEntries1?: TimeInfoEntries, timeInfoEntries2?: TimeInfoEntries, changes?: Changes, removals?: Removals) => void} callback aggregated callback
|
116
|
+
* @param {(value: string, num: number) => void} callbackUndelayed callback when the first change was detected
|
117
117
|
* @returns {Watcher} a watcher
|
118
118
|
*/
|
119
119
|
|
@@ -264,15 +264,15 @@ const path = require("path");
|
|
264
264
|
*/
|
265
265
|
|
266
266
|
/**
|
267
|
-
* @typedef {
|
267
|
+
* @typedef {(pathOrFileDescriptor: PathOrFileDescriptor, callback: ReadJsonCallback) => void} ReadJson
|
268
268
|
*/
|
269
269
|
|
270
270
|
/**
|
271
|
-
* @typedef {
|
271
|
+
* @typedef {(pathOrFileDescriptor: PathOrFileDescriptor) => JsonObject} ReadJsonSync
|
272
272
|
*/
|
273
273
|
|
274
274
|
/**
|
275
|
-
* @typedef {
|
275
|
+
* @typedef {(value?: string | string[] | Set<string>) => void} Purge
|
276
276
|
*/
|
277
277
|
|
278
278
|
/**
|
@@ -292,9 +292,9 @@ const path = require("path");
|
|
292
292
|
* @property {ReadJson=} readJson
|
293
293
|
* @property {ReadJsonSync=} readJsonSync
|
294
294
|
* @property {Purge=} purge
|
295
|
-
* @property {(
|
296
|
-
* @property {(
|
297
|
-
* @property {(
|
295
|
+
* @property {((path1: string, path2: string) => string)=} join
|
296
|
+
* @property {((from: string, to: string) => string)=} relative
|
297
|
+
* @property {((dirname: string) => string)=} dirname
|
298
298
|
*/
|
299
299
|
|
300
300
|
/**
|
@@ -337,7 +337,7 @@ const path = require("path");
|
|
337
337
|
*/
|
338
338
|
|
339
339
|
/**
|
340
|
-
* @typedef {
|
340
|
+
* @typedef {(pathLike: PathLike, callback: NoParamCallback) => void} Unlink
|
341
341
|
*/
|
342
342
|
|
343
343
|
/**
|
@@ -350,9 +350,9 @@ const path = require("path");
|
|
350
350
|
* @property {Stat} stat
|
351
351
|
* @property {LStat=} lstat
|
352
352
|
* @property {ReadFile} readFile
|
353
|
-
* @property {(
|
354
|
-
* @property {(
|
355
|
-
* @property {(
|
353
|
+
* @property {((path1: string, path2: string) => string)=} join
|
354
|
+
* @property {((from: string, to: string) => string)=} relative
|
355
|
+
* @property {((dirname: string) => string)=} dirname
|
356
356
|
*/
|
357
357
|
|
358
358
|
/**
|
@@ -395,7 +395,7 @@ const path = require("path");
|
|
395
395
|
*/
|
396
396
|
|
397
397
|
/**
|
398
|
-
* @typedef {
|
398
|
+
* @typedef {(pathLike: PathLike, result?: BufferEncoding | WriteStreamOptions) => NodeJS.WritableStream} CreateWriteStream
|
399
399
|
*/
|
400
400
|
|
401
401
|
/**
|
@@ -431,7 +431,7 @@ const path = require("path");
|
|
431
431
|
*/
|
432
432
|
|
433
433
|
/**
|
434
|
-
* @template {NodeJS.ArrayBufferView} [TBuffer=
|
434
|
+
* @template {NodeJS.ArrayBufferView} [TBuffer=NodeJS.ArrayBufferView]
|
435
435
|
* @typedef {{
|
436
436
|
* (fd: number, buffer: TBuffer, offset: number, length: number, position: ReadPosition | null, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
|
437
437
|
* (fd: number, options: ReadAsyncOptions<TBuffer>, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
|
@@ -439,9 +439,9 @@ const path = require("path");
|
|
439
439
|
* }} Read
|
440
440
|
*/
|
441
441
|
|
442
|
-
/** @typedef {
|
442
|
+
/** @typedef {(df: number, callback: NoParamCallback) => void} Close */
|
443
443
|
|
444
|
-
/** @typedef {
|
444
|
+
/** @typedef {(a: PathLike, b: PathLike, callback: NoParamCallback) => void} Rename */
|
445
445
|
|
446
446
|
/**
|
447
447
|
* @typedef {object} IntermediateFileSystemExtras
|
@@ -517,7 +517,7 @@ module.exports.dirname = dirname;
|
|
517
517
|
/**
|
518
518
|
* @param {OutputFileSystem} fs a file system
|
519
519
|
* @param {string} p an absolute path
|
520
|
-
* @param {
|
520
|
+
* @param {(err?: Error) => void} callback callback function for the error
|
521
521
|
* @returns {void}
|
522
522
|
*/
|
523
523
|
const mkdirp = (fs, p, callback) => {
|
@@ -613,7 +613,7 @@ module.exports.readJson = readJson;
|
|
613
613
|
/**
|
614
614
|
* @param {InputFileSystem} fs a file system
|
615
615
|
* @param {string} p an absolute path
|
616
|
-
* @param {
|
616
|
+
* @param {(err: NodeJS.ErrnoException | Error | null, stats?: IStats | string) => void} callback callback
|
617
617
|
* @returns {void}
|
618
618
|
*/
|
619
619
|
const lstatReadlinkAbsolute = (fs, p, callback) => {
|
@@ -19,7 +19,7 @@ class WasmHash {
|
|
19
19
|
* @param {number} digestSize size of digest returned by wasm
|
20
20
|
*/
|
21
21
|
constructor(instance, instancesPool, chunkSize, digestSize) {
|
22
|
-
const exports = /** @type {
|
22
|
+
const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
|
23
23
|
exports.init();
|
24
24
|
this.exports = exports;
|
25
25
|
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
@@ -149,7 +149,7 @@ class WasmHash {
|
|
149
149
|
}
|
150
150
|
|
151
151
|
/**
|
152
|
-
* @param {
|
152
|
+
* @param {WebAssembly.Module} wasmModule wasm module
|
153
153
|
* @param {WasmHash[]} instancesPool pool of instances
|
154
154
|
* @param {number} chunkSize size of data chunks passed to wasm
|
155
155
|
* @param {number} digestSize size of digest returned by wasm
|
package/lib/util/identifier.js
CHANGED
@@ -10,11 +10,6 @@ const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
|
|
10
10
|
const SEGMENTS_SPLIT_REGEXP = /([|!])/;
|
11
11
|
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
12
12
|
|
13
|
-
/**
|
14
|
-
* @typedef {object} MakeRelativePathsCache
|
15
|
-
* @property {Map<string, Map<string, string>>=} relativePaths
|
16
|
-
*/
|
17
|
-
|
18
13
|
/**
|
19
14
|
* @param {string} relativePath relative path
|
20
15
|
* @returns {string} request
|
@@ -85,24 +80,26 @@ const requestToAbsolute = (context, relativePath) => {
|
|
85
80
|
return relativePath;
|
86
81
|
};
|
87
82
|
|
83
|
+
/** @typedef {EXPECTED_OBJECT} AssociatedObjectForCache */
|
84
|
+
|
88
85
|
/**
|
89
86
|
* @template T
|
90
|
-
* @typedef {
|
87
|
+
* @typedef {(value: string, cache?: AssociatedObjectForCache) => T} MakeCacheableResult
|
91
88
|
*/
|
92
89
|
|
93
90
|
/**
|
94
91
|
* @template T
|
95
|
-
* @typedef {
|
92
|
+
* @typedef {(value: string) => T} BindCacheResultFn
|
96
93
|
*/
|
97
94
|
|
98
95
|
/**
|
99
96
|
* @template T
|
100
|
-
* @typedef {
|
97
|
+
* @typedef {(cache: AssociatedObjectForCache) => BindCacheResultFn<T>} BindCache
|
101
98
|
*/
|
102
99
|
|
103
100
|
/**
|
104
101
|
* @template T
|
105
|
-
* @param {(
|
102
|
+
* @param {((value: string) => T)} realFn real function
|
106
103
|
* @returns {MakeCacheableResult<T> & { bindCache: BindCache<T> }} cacheable function
|
107
104
|
*/
|
108
105
|
const makeCacheable = realFn => {
|
@@ -110,11 +107,11 @@ const makeCacheable = realFn => {
|
|
110
107
|
* @template T
|
111
108
|
* @typedef {Map<string, T>} CacheItem
|
112
109
|
*/
|
113
|
-
/** @type {WeakMap<
|
110
|
+
/** @type {WeakMap<AssociatedObjectForCache, CacheItem<T>>} */
|
114
111
|
const cache = new WeakMap();
|
115
112
|
|
116
113
|
/**
|
117
|
-
* @param {
|
114
|
+
* @param {AssociatedObjectForCache} associatedObjectForCache an object to which the cache will be attached
|
118
115
|
* @returns {CacheItem<T>} cache item
|
119
116
|
*/
|
120
117
|
const getCache = associatedObjectForCache => {
|
@@ -156,18 +153,18 @@ const makeCacheable = realFn => {
|
|
156
153
|
return fn;
|
157
154
|
};
|
158
155
|
|
159
|
-
/** @typedef {
|
160
|
-
/** @typedef {
|
161
|
-
/** @typedef {
|
162
|
-
/** @typedef {
|
163
|
-
/** @typedef {
|
156
|
+
/** @typedef {(context: string, value: string, associatedObjectForCache?: AssociatedObjectForCache) => string} MakeCacheableWithContextResult */
|
157
|
+
/** @typedef {(context: string, value: string) => string} BindCacheForContextResultFn */
|
158
|
+
/** @typedef {(value: string) => string} BindContextCacheForContextResultFn */
|
159
|
+
/** @typedef {(associatedObjectForCache?: AssociatedObjectForCache) => BindCacheForContextResultFn} BindCacheForContext */
|
160
|
+
/** @typedef {(value: string, associatedObjectForCache?: AssociatedObjectForCache) => BindContextCacheForContextResultFn} BindContextCacheForContext */
|
164
161
|
|
165
162
|
/**
|
166
|
-
* @param {
|
163
|
+
* @param {(context: string, identifier: string) => string} fn function
|
167
164
|
* @returns {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} cacheable function with context
|
168
165
|
*/
|
169
166
|
const makeCacheableWithContext = fn => {
|
170
|
-
/** @type {WeakMap<
|
167
|
+
/** @type {WeakMap<AssociatedObjectForCache, Map<string, Map<string, string>>>} */
|
171
168
|
const cache = new WeakMap();
|
172
169
|
|
173
170
|
/** @type {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} */
|
@@ -13,7 +13,7 @@ const { register } = require("./serialization");
|
|
13
13
|
/** @typedef {{ serialize: (context: ObjectSerializerContext) => void, deserialize: (context: ObjectDeserializerContext) => void }} SerializableClass */
|
14
14
|
/**
|
15
15
|
* @template {SerializableClass} T
|
16
|
-
* @typedef {(new (...params:
|
16
|
+
* @typedef {(new (...params: EXPECTED_ANY[]) => T) & { deserialize?: (context: ObjectDeserializerContext) => T }} SerializableClassConstructor
|
17
17
|
*/
|
18
18
|
|
19
19
|
/**
|
package/lib/util/memoize.js
CHANGED
package/lib/util/objectToMap.js
CHANGED
@@ -6,8 +6,9 @@
|
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Convert an object into an ES6 map
|
9
|
-
* @
|
10
|
-
* @
|
9
|
+
* @template {object} T
|
10
|
+
* @param {T} obj any object type that works with Object.entries()
|
11
|
+
* @returns {Map<string, T[keyof T]>} an ES6 Map of KV pairs
|
11
12
|
*/
|
12
13
|
module.exports = function objectToMap(obj) {
|
13
14
|
return new Map(Object.entries(obj));
|
@@ -10,8 +10,8 @@
|
|
10
10
|
* @template {Error} E
|
11
11
|
* @param {Iterable<T>} items initial items
|
12
12
|
* @param {number} concurrency number of items running in parallel
|
13
|
-
* @param {
|
14
|
-
* @param {
|
13
|
+
* @param {(item: T, push: (item: T) => void, callback: (err?: E) => void) => void} processor worker which pushes more items
|
14
|
+
* @param {(err?: E) => void} callback all items processed
|
15
15
|
* @returns {void}
|
16
16
|
*/
|
17
17
|
const processAsyncTree = (items, concurrency, processor, callback) => {
|