webpack 5.91.0 → 5.92.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/bin/webpack.js +1 -2
- package/lib/APIPlugin.js +6 -2
- package/lib/Cache.js +1 -1
- package/lib/Chunk.js +7 -4
- package/lib/ChunkGraph.js +20 -7
- package/lib/ChunkGroup.js +9 -3
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +33 -27
- package/lib/Compiler.js +28 -8
- package/lib/ConcatenationScope.js +3 -3
- package/lib/ContextModule.js +95 -43
- package/lib/DefinePlugin.js +14 -4
- package/lib/Dependency.js +8 -8
- package/lib/DependencyTemplate.js +10 -5
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +11 -0
- package/lib/ExportsInfo.js +22 -4
- package/lib/ExternalModule.js +49 -18
- package/lib/FileSystemInfo.js +68 -41
- package/lib/FlagDependencyExportsPlugin.js +21 -7
- package/lib/Generator.js +2 -3
- package/lib/HotModuleReplacementPlugin.js +108 -45
- package/lib/IgnorePlugin.js +4 -1
- package/lib/LibManifestPlugin.js +2 -2
- package/lib/Module.js +11 -12
- package/lib/ModuleFactory.js +3 -3
- package/lib/ModuleFilenameHelpers.js +29 -16
- package/lib/ModuleGraph.js +5 -5
- package/lib/MultiCompiler.js +36 -1
- package/lib/NormalModule.js +10 -12
- package/lib/NormalModuleFactory.js +17 -8
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/ResolverFactory.js +3 -3
- package/lib/RuntimeTemplate.js +22 -18
- package/lib/Stats.js +1 -1
- package/lib/Template.js +5 -5
- package/lib/TemplatedPathPlugin.js +16 -1
- package/lib/asset/AssetGenerator.js +15 -0
- package/lib/buildChunkGraph.js +3 -3
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +2 -2
- package/lib/cache/ResolverCachePlugin.js +8 -8
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/cli.js +5 -5
- package/lib/config/browserslistTargetHandler.js +7 -1
- package/lib/config/defaults.js +85 -34
- package/lib/config/target.js +18 -11
- package/lib/container/ContainerEntryModule.js +1 -1
- package/lib/css/CssExportsGenerator.js +43 -17
- package/lib/css/CssGenerator.js +22 -12
- package/lib/css/CssLoadingRuntimeModule.js +8 -5
- package/lib/css/CssModulesPlugin.js +197 -100
- package/lib/css/CssParser.js +24 -15
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +9 -2
- package/lib/dependencies/CssUrlDependency.js +5 -4
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/ExternalModuleDependency.js +4 -2
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +41 -18
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +43 -32
- package/lib/dependencies/ImportDependency.js +2 -2
- package/lib/dependencies/ImportEagerDependency.js +2 -2
- package/lib/dependencies/ImportMetaPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +3 -1
- package/lib/dependencies/ImportWeakDependency.js +2 -2
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/ModuleDependency.js +2 -2
- package/lib/dependencies/PureExpressionDependency.js +63 -49
- package/lib/dependencies/WorkerDependency.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +90 -2
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +6 -6
- package/lib/ids/NamedChunkIdsPlugin.js +1 -1
- package/lib/ids/NamedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/index.js +11 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +0 -1
- package/lib/javascript/JavascriptModulesPlugin.js +174 -17
- package/lib/javascript/JavascriptParser.js +37 -16
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +3 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +2 -2
- package/lib/library/SystemLibraryPlugin.js +2 -2
- package/lib/library/UmdLibraryPlugin.js +33 -12
- package/lib/logging/createConsoleLogger.js +2 -2
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeEnvironmentPlugin.js +1 -1
- package/lib/node/NodeTemplatePlugin.js +1 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
- package/lib/node/nodeConsole.js +1 -1
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +11 -76
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/LimitChunkCountPlugin.js +1 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +1 -1
- package/lib/optimize/RealContentHashPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +2 -2
- package/lib/optimize/SplitChunksPlugin.js +8 -8
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +11 -1
- package/lib/rules/RuleSetCompiler.js +9 -7
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +4 -4
- package/lib/serialization/FileMiddleware.js +3 -3
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
- package/lib/serialization/ObjectMiddleware.js +6 -5
- package/lib/serialization/PlainObjectSerializer.js +2 -2
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/stats/StatsPrinter.js +6 -6
- package/lib/util/ArrayQueue.js +14 -21
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Queue.js +8 -2
- package/lib/util/SortableSet.js +16 -4
- package/lib/util/TupleQueue.js +8 -2
- package/lib/util/WeakTupleMap.js +3 -3
- package/lib/util/binarySearchBounds.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +4 -2
- package/lib/util/conventions.js +1 -1
- package/lib/util/createHash.js +3 -5
- package/lib/util/deprecation.js +3 -3
- package/lib/util/deterministicGrouping.js +2 -2
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +15 -15
- package/lib/util/identifier.js +5 -5
- package/lib/util/mergeScope.js +79 -0
- package/lib/util/runtime.js +2 -17
- package/lib/util/semver.js +3 -0
- package/lib/util/smartGrouping.js +3 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +17 -17
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +12 -3
- package/package.json +20 -18
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +30 -2
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/types.d.ts +213 -81
@@ -22,7 +22,7 @@ const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
|
22
22
|
|
23
23
|
/**
|
24
24
|
* @param {Record<string, number>} sizes sizes by source type
|
25
|
-
* @param {
|
25
|
+
* @param {object} options options
|
26
26
|
* @param {(number) => string=} options.formatSize size formatter
|
27
27
|
* @returns {string} text
|
28
28
|
*/
|
@@ -18,7 +18,7 @@ const smartGrouping = require("../util/smartGrouping");
|
|
18
18
|
/** @typedef {import("../util/smartGrouping").GroupConfig<any, object>} GroupConfig */
|
19
19
|
|
20
20
|
/**
|
21
|
-
* @typedef {
|
21
|
+
* @typedef {object} KnownStatsFactoryContext
|
22
22
|
* @property {string} type
|
23
23
|
* @property {function(string): string=} makePathsRelative
|
24
24
|
* @property {Compilation=} compilation
|
@@ -35,7 +35,7 @@ const smartGrouping = require("../util/smartGrouping");
|
|
35
35
|
class StatsFactory {
|
36
36
|
constructor() {
|
37
37
|
this.hooks = Object.freeze({
|
38
|
-
/** @type {HookMap<SyncBailHook<[
|
38
|
+
/** @type {HookMap<SyncBailHook<[object, any, StatsFactoryContext]>>} */
|
39
39
|
extract: new HookMap(
|
40
40
|
() => new SyncBailHook(["object", "data", "context"])
|
41
41
|
),
|
@@ -17,13 +17,13 @@ const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
|
|
17
17
|
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleReason} StatsModuleReason */
|
18
18
|
|
19
19
|
/**
|
20
|
-
* @typedef {
|
20
|
+
* @typedef {object} PrintedElement
|
21
21
|
* @property {string} element
|
22
22
|
* @property {string} content
|
23
23
|
*/
|
24
24
|
|
25
25
|
/**
|
26
|
-
* @typedef {
|
26
|
+
* @typedef {object} KnownStatsPrinterContext
|
27
27
|
* @property {string=} type
|
28
28
|
* @property {StatsCompilation=} compilation
|
29
29
|
* @property {StatsChunkGroup=} chunkGroup
|
@@ -147,8 +147,8 @@ class StatsPrinter {
|
|
147
147
|
|
148
148
|
/**
|
149
149
|
* @param {string} type The type
|
150
|
-
* @param {
|
151
|
-
* @param {
|
150
|
+
* @param {object} object Object to print
|
151
|
+
* @param {object=} baseContext The base context
|
152
152
|
* @returns {string} printed result
|
153
153
|
*/
|
154
154
|
print(type, object, baseContext) {
|
@@ -168,8 +168,8 @@ class StatsPrinter {
|
|
168
168
|
/**
|
169
169
|
* @private
|
170
170
|
* @param {string} type type
|
171
|
-
* @param {
|
172
|
-
* @param {
|
171
|
+
* @param {object} object object
|
172
|
+
* @param {object=} baseContext context
|
173
173
|
* @returns {string} printed result
|
174
174
|
*/
|
175
175
|
_print(type, object, baseContext) {
|
package/lib/util/ArrayQueue.js
CHANGED
@@ -13,9 +13,15 @@ class ArrayQueue {
|
|
13
13
|
* @param {Iterable<T>=} items The initial elements.
|
14
14
|
*/
|
15
15
|
constructor(items) {
|
16
|
-
/**
|
16
|
+
/**
|
17
|
+
* @private
|
18
|
+
* @type {T[]}
|
19
|
+
*/
|
17
20
|
this._list = items ? Array.from(items) : [];
|
18
|
-
/**
|
21
|
+
/**
|
22
|
+
* @private
|
23
|
+
* @type {T[]}
|
24
|
+
*/
|
19
25
|
this._listReversed = [];
|
20
26
|
}
|
21
27
|
|
@@ -77,31 +83,18 @@ class ArrayQueue {
|
|
77
83
|
}
|
78
84
|
|
79
85
|
[Symbol.iterator]() {
|
80
|
-
let i = -1;
|
81
|
-
let reversed = false;
|
82
86
|
return {
|
83
87
|
next: () => {
|
84
|
-
|
85
|
-
|
86
|
-
if (i < this._list.length) {
|
87
|
-
return {
|
88
|
-
done: false,
|
89
|
-
value: this._list[i]
|
90
|
-
};
|
91
|
-
}
|
92
|
-
reversed = true;
|
93
|
-
i = this._listReversed.length;
|
94
|
-
}
|
95
|
-
i--;
|
96
|
-
if (i < 0) {
|
88
|
+
const item = this.dequeue();
|
89
|
+
if (item) {
|
97
90
|
return {
|
98
|
-
done:
|
99
|
-
value:
|
91
|
+
done: false,
|
92
|
+
value: item
|
100
93
|
};
|
101
94
|
}
|
102
95
|
return {
|
103
|
-
done:
|
104
|
-
value:
|
96
|
+
done: true,
|
97
|
+
value: undefined
|
105
98
|
};
|
106
99
|
}
|
107
100
|
};
|
package/lib/util/AsyncQueue.js
CHANGED
@@ -53,7 +53,7 @@ class AsyncQueueEntry {
|
|
53
53
|
*/
|
54
54
|
class AsyncQueue {
|
55
55
|
/**
|
56
|
-
* @param {
|
56
|
+
* @param {object} options options object
|
57
57
|
* @param {string=} options.name name of the queue
|
58
58
|
* @param {number=} options.parallelism how many items should be processed at once
|
59
59
|
* @param {AsyncQueue<any, any, any>=} options.parent parent queue, which will have priority over this queue and with shared parallelism
|
package/lib/util/Queue.js
CHANGED
@@ -13,9 +13,15 @@ class Queue {
|
|
13
13
|
* @param {Iterable<T>=} items The initial elements.
|
14
14
|
*/
|
15
15
|
constructor(items) {
|
16
|
-
/**
|
16
|
+
/**
|
17
|
+
* @private
|
18
|
+
* @type {Set<T>}
|
19
|
+
*/
|
17
20
|
this._set = new Set(items);
|
18
|
-
/**
|
21
|
+
/**
|
22
|
+
* @private
|
23
|
+
* @type {Iterator<T>}
|
24
|
+
*/
|
19
25
|
this._iterator = this._set[Symbol.iterator]();
|
20
26
|
}
|
21
27
|
|
package/lib/util/SortableSet.js
CHANGED
@@ -21,13 +21,25 @@ class SortableSet extends Set {
|
|
21
21
|
*/
|
22
22
|
constructor(initialIterable, defaultSort) {
|
23
23
|
super(initialIterable);
|
24
|
-
/**
|
24
|
+
/**
|
25
|
+
* @private
|
26
|
+
* @type {undefined | function(T, T): number}}
|
27
|
+
*/
|
25
28
|
this._sortFn = defaultSort;
|
26
|
-
/**
|
29
|
+
/**
|
30
|
+
* @private
|
31
|
+
* @type {typeof NONE | undefined | function(T, T): number}}
|
32
|
+
*/
|
27
33
|
this._lastActiveSortFn = NONE;
|
28
|
-
/**
|
34
|
+
/**
|
35
|
+
* @private
|
36
|
+
* @type {Map<Function, any> | undefined}
|
37
|
+
*/
|
29
38
|
this._cache = undefined;
|
30
|
-
/**
|
39
|
+
/**
|
40
|
+
* @private
|
41
|
+
* @type {Map<Function, any> | undefined}
|
42
|
+
*/
|
31
43
|
this._cacheOrderIndependent = undefined;
|
32
44
|
}
|
33
45
|
|
package/lib/util/TupleQueue.js
CHANGED
@@ -15,9 +15,15 @@ class TupleQueue {
|
|
15
15
|
* @param {Iterable<T>=} items The initial elements.
|
16
16
|
*/
|
17
17
|
constructor(items) {
|
18
|
-
/**
|
18
|
+
/**
|
19
|
+
* @private
|
20
|
+
* @type {TupleSet<T>}
|
21
|
+
*/
|
19
22
|
this._set = new TupleSet(items);
|
20
|
-
/**
|
23
|
+
/**
|
24
|
+
* @private
|
25
|
+
* @type {Iterator<T>}
|
26
|
+
*/
|
21
27
|
this._iterator = this._set[Symbol.iterator]();
|
22
28
|
}
|
23
29
|
|
package/lib/util/WeakTupleMap.js
CHANGED
@@ -33,17 +33,17 @@ class WeakTupleMap {
|
|
33
33
|
/**
|
34
34
|
* @private
|
35
35
|
* @type {any}
|
36
|
-
|
36
|
+
*/
|
37
37
|
this.v = undefined;
|
38
38
|
/**
|
39
39
|
* @private
|
40
40
|
* @type {M<T, V> | undefined}
|
41
|
-
|
41
|
+
*/
|
42
42
|
this.m = undefined;
|
43
43
|
/**
|
44
44
|
* @private
|
45
45
|
* @type {W<T, V> | undefined}
|
46
|
-
|
46
|
+
*/
|
47
47
|
this.w = undefined;
|
48
48
|
}
|
49
49
|
|
@@ -75,7 +75,7 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
|
|
75
75
|
* @param {boolean} reversed Whether the search should be reversed.
|
76
76
|
* @param {SearchPredicateSuffix} suffix The suffix to be used in the function name.
|
77
77
|
* @param {boolean=} earlyOut Whether the search should return as soon as a match is found.
|
78
|
-
* @returns {
|
78
|
+
* @returns {Function} The compiled binary search function.
|
79
79
|
*/
|
80
80
|
const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
|
81
81
|
const arg1 = compileSearch(
|
package/lib/util/cleverMerge.js
CHANGED
@@ -81,14 +81,14 @@ const cachedSetProperty = (obj, property, value) => {
|
|
81
81
|
};
|
82
82
|
|
83
83
|
/**
|
84
|
-
* @typedef {
|
84
|
+
* @typedef {object} ObjectParsedPropertyEntry
|
85
85
|
* @property {any | undefined} base base value
|
86
86
|
* @property {string | undefined} byProperty the name of the selector property
|
87
87
|
* @property {Map<string, any>} byValues value depending on selector property, merged with base
|
88
88
|
*/
|
89
89
|
|
90
90
|
/**
|
91
|
-
* @typedef {
|
91
|
+
* @typedef {object} ParsedObject
|
92
92
|
* @property {Map<string, ObjectParsedPropertyEntry>} static static properties (key is property name)
|
93
93
|
* @property {{ byProperty: string, fn: Function } | undefined} dynamic dynamic part
|
94
94
|
*/
|
package/lib/util/comparators.js
CHANGED
@@ -279,7 +279,10 @@ exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
|
279
279
|
*/
|
280
280
|
class TwoKeyWeakMap {
|
281
281
|
constructor() {
|
282
|
-
/**
|
282
|
+
/**
|
283
|
+
* @private
|
284
|
+
* @type {WeakMap<any, WeakMap<any, T | undefined>>}
|
285
|
+
*/
|
283
286
|
this._map = new WeakMap();
|
284
287
|
}
|
285
288
|
|
@@ -408,7 +411,6 @@ const compareIterables = elementComparator => {
|
|
408
411
|
const result = (a, b) => {
|
409
412
|
const aI = a[Symbol.iterator]();
|
410
413
|
const bI = b[Symbol.iterator]();
|
411
|
-
// eslint-disable-next-line no-constant-condition
|
412
414
|
while (true) {
|
413
415
|
const aItem = aI.next();
|
414
416
|
const bItem = bI.next();
|
package/lib/util/conventions.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
/**
|
11
11
|
* @param {string} input input
|
12
|
-
* @param {CssGeneratorExportsConvention} convention convention
|
12
|
+
* @param {CssGeneratorExportsConvention | undefined} convention convention
|
13
13
|
* @returns {Set<string>} results
|
14
14
|
*/
|
15
15
|
exports.cssExportConvention = (input, convention) => {
|
package/lib/util/createHash.js
CHANGED
@@ -11,7 +11,7 @@ const BULK_SIZE = 2000;
|
|
11
11
|
|
12
12
|
// We are using an object instead of a Map as this will stay static during the runtime
|
13
13
|
// so access to it can be optimized by v8
|
14
|
-
/** @type {
|
14
|
+
/** @type {{[key: string]: Map<string, string>}} */
|
15
15
|
const digestCaches = {};
|
16
16
|
|
17
17
|
/** @typedef {function(): Hash} HashFactory */
|
@@ -143,7 +143,7 @@ let BatchedHash = undefined;
|
|
143
143
|
|
144
144
|
/**
|
145
145
|
* Creates a hash by name or function
|
146
|
-
* @param {string | typeof Hash
|
146
|
+
* @param {string | typeof Hash} algorithm the algorithm name or a constructor creating a hash
|
147
147
|
* @returns {Hash} the hash
|
148
148
|
*/
|
149
149
|
module.exports = algorithm => {
|
@@ -184,9 +184,7 @@ module.exports = algorithm => {
|
|
184
184
|
if (crypto === undefined) crypto = require("crypto");
|
185
185
|
return new BulkUpdateDecorator(
|
186
186
|
() =>
|
187
|
-
/** @type {typeof import("crypto")} */ (crypto).createHash(
|
188
|
-
/** @type {string} */ (algorithm)
|
189
|
-
),
|
187
|
+
/** @type {typeof import("crypto")} */ (crypto).createHash(algorithm),
|
190
188
|
algorithm
|
191
189
|
);
|
192
190
|
}
|
package/lib/util/deprecation.js
CHANGED
@@ -11,7 +11,7 @@ const util = require("util");
|
|
11
11
|
const deprecationCache = new Map();
|
12
12
|
|
13
13
|
/**
|
14
|
-
* @typedef {
|
14
|
+
* @typedef {object} FakeHookMarker
|
15
15
|
* @property {true} _fakeHook it's a fake hook
|
16
16
|
*/
|
17
17
|
|
@@ -187,11 +187,11 @@ exports.createArrayToSetDeprecationSet = name => {
|
|
187
187
|
|
188
188
|
/**
|
189
189
|
* @template T
|
190
|
-
* @param {
|
190
|
+
* @param {object} obj object
|
191
191
|
* @param {string} name property name
|
192
192
|
* @param {string} code deprecation code
|
193
193
|
* @param {string} note additional note
|
194
|
-
* @returns {
|
194
|
+
* @returns {object} frozen object with deprecation when modifying
|
195
195
|
*/
|
196
196
|
exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
197
197
|
const message = `${name} will be frozen in future, all modifications are deprecated.${
|
@@ -272,7 +272,7 @@ const getSimilarities = nodes => {
|
|
272
272
|
|
273
273
|
/**
|
274
274
|
* @template T
|
275
|
-
* @typedef {
|
275
|
+
* @typedef {object} GroupedItems<T>
|
276
276
|
* @property {string} key
|
277
277
|
* @property {T[]} items
|
278
278
|
* @property {Record<string, number>} size
|
@@ -280,7 +280,7 @@ const getSimilarities = nodes => {
|
|
280
280
|
|
281
281
|
/**
|
282
282
|
* @template T
|
283
|
-
* @typedef {
|
283
|
+
* @typedef {object} Options
|
284
284
|
* @property {Record<string, number>} maxSize maximum size of a group
|
285
285
|
* @property {Record<string, number>} minSize minimum size of a group (preferred over maximum size)
|
286
286
|
* @property {Iterable<T>} items a list of items
|
package/lib/util/fs.js
CHANGED
@@ -12,7 +12,7 @@ const path = require("path");
|
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @template T
|
15
|
-
* @typedef {
|
15
|
+
* @typedef {object} IStatsBase
|
16
16
|
* @property {() => boolean} isFile
|
17
17
|
* @property {() => boolean} isDirectory
|
18
18
|
* @property {() => boolean} isBlockDevice
|
@@ -49,7 +49,7 @@ const path = require("path");
|
|
49
49
|
*/
|
50
50
|
|
51
51
|
/**
|
52
|
-
* @typedef {
|
52
|
+
* @typedef {object} Dirent
|
53
53
|
* @property {() => boolean} isFile
|
54
54
|
* @property {() => boolean} isDirectory
|
55
55
|
* @property {() => boolean} isBlockDevice
|
@@ -81,7 +81,7 @@ const path = require("path");
|
|
81
81
|
/** @typedef {function(NodeJS.ErrnoException | Error | null, JsonObject=): void} ReadJsonCallback */
|
82
82
|
|
83
83
|
/**
|
84
|
-
* @typedef {
|
84
|
+
* @typedef {object} WatcherInfo
|
85
85
|
* @property {Set<string>} changes get current aggregated changes that have not yet send to callback
|
86
86
|
* @property {Set<string>} removals get current aggregated removals that have not yet send to callback
|
87
87
|
* @property {Map<string, FileSystemInfoEntry | "ignore">} fileTimeInfoEntries get info about files
|
@@ -90,7 +90,7 @@ const path = require("path");
|
|
90
90
|
|
91
91
|
// TODO webpack 6 deprecate missing getInfo
|
92
92
|
/**
|
93
|
-
* @typedef {
|
93
|
+
* @typedef {object} Watcher
|
94
94
|
* @property {function(): void} close closes the watcher and all underlying file watchers
|
95
95
|
* @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
|
96
96
|
* @property {function(): Set<string>=} getAggregatedChanges get current aggregated changes that have not yet send to callback
|
@@ -123,7 +123,7 @@ const path = require("path");
|
|
123
123
|
*/
|
124
124
|
|
125
125
|
/**
|
126
|
-
* @typedef {
|
126
|
+
* @typedef {object} ObjectEncodingOptions
|
127
127
|
* @property {BufferEncoding | null | undefined} [encoding]
|
128
128
|
*/
|
129
129
|
|
@@ -153,12 +153,12 @@ const path = require("path");
|
|
153
153
|
*/
|
154
154
|
|
155
155
|
/**
|
156
|
-
* @typedef {
|
156
|
+
* @typedef {object} StatOptions
|
157
157
|
* @property {(boolean | undefined)=} bigint
|
158
158
|
*/
|
159
159
|
|
160
160
|
/**
|
161
|
-
* @typedef {
|
161
|
+
* @typedef {object} StatSyncOptions
|
162
162
|
* @property {(boolean | undefined)=} bigint
|
163
163
|
* @property {(boolean | undefined)=} throwIfNoEntry
|
164
164
|
*/
|
@@ -271,7 +271,7 @@ const path = require("path");
|
|
271
271
|
*/
|
272
272
|
|
273
273
|
/**
|
274
|
-
* @typedef {
|
274
|
+
* @typedef {object} InputFileSystem
|
275
275
|
* @property {ReadFile} readFile
|
276
276
|
* @property {ReadFileSync=} readFileSync
|
277
277
|
* @property {Readlink} readlink
|
@@ -336,7 +336,7 @@ const path = require("path");
|
|
336
336
|
*/
|
337
337
|
|
338
338
|
/**
|
339
|
-
* @typedef {
|
339
|
+
* @typedef {object} OutputFileSystem
|
340
340
|
* @property {WriteFile} writeFile
|
341
341
|
* @property {Mkdir} mkdir
|
342
342
|
* @property {Readdir=} readdir
|
@@ -351,7 +351,7 @@ const path = require("path");
|
|
351
351
|
*/
|
352
352
|
|
353
353
|
/**
|
354
|
-
* @typedef {
|
354
|
+
* @typedef {object} WatchFileSystem
|
355
355
|
* @property {WatchMethod} watch
|
356
356
|
*/
|
357
357
|
|
@@ -364,7 +364,7 @@ const path = require("path");
|
|
364
364
|
*/
|
365
365
|
|
366
366
|
/**
|
367
|
-
* @typedef {
|
367
|
+
* @typedef {object} StreamOptions
|
368
368
|
* @property {(string | undefined)=} flags
|
369
369
|
* @property {(BufferEncoding | undefined)} encoding
|
370
370
|
* @property {(number | any | undefined)=} fd
|
@@ -376,7 +376,7 @@ const path = require("path");
|
|
376
376
|
*/
|
377
377
|
|
378
378
|
/**
|
379
|
-
* @typedef {
|
379
|
+
* @typedef {object} FSImplementation
|
380
380
|
* @property {((...args: any[]) => any)=} open
|
381
381
|
* @property {((...args: any[]) => any)=} close
|
382
382
|
*/
|
@@ -410,7 +410,7 @@ const path = require("path");
|
|
410
410
|
*/
|
411
411
|
|
412
412
|
/**
|
413
|
-
* @typedef {
|
413
|
+
* @typedef {object} ReadSyncOptions
|
414
414
|
* @property {(number | undefined)=} offset
|
415
415
|
* @property {(number | undefined)=} length
|
416
416
|
* @property {(ReadPosition | null | undefined)=} position
|
@@ -418,7 +418,7 @@ const path = require("path");
|
|
418
418
|
|
419
419
|
/**
|
420
420
|
* @template {NodeJS.ArrayBufferView} TBuffer
|
421
|
-
* @typedef {
|
421
|
+
* @typedef {object} ReadAsyncOptions
|
422
422
|
* @property {(number | undefined)=} offset
|
423
423
|
* @property {(number | undefined)=} length
|
424
424
|
* @property {(ReadPosition | null | undefined)=} position
|
@@ -439,7 +439,7 @@ const path = require("path");
|
|
439
439
|
/** @typedef {function(PathLike, PathLike, NoParamCallback): void} Rename */
|
440
440
|
|
441
441
|
/**
|
442
|
-
* @typedef {
|
442
|
+
* @typedef {object} IntermediateFileSystemExtras
|
443
443
|
* @property {MkdirSync} mkdirSync
|
444
444
|
* @property {CreateWriteStream} createWriteStream
|
445
445
|
* @property {Open} open
|
package/lib/util/identifier.js
CHANGED
@@ -11,7 +11,7 @@ const SEGMENTS_SPLIT_REGEXP = /([|!])/;
|
|
11
11
|
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
12
12
|
|
13
13
|
/**
|
14
|
-
* @typedef {
|
14
|
+
* @typedef {object} MakeRelativePathsCache
|
15
15
|
* @property {Map<string, Map<string, string>>=} relativePaths
|
16
16
|
*/
|
17
17
|
|
@@ -100,7 +100,7 @@ const makeCacheable = realFn => {
|
|
100
100
|
|
101
101
|
/**
|
102
102
|
* @param {string} str the path with query and fragment
|
103
|
-
* @param {
|
103
|
+
* @param {object=} associatedObjectForCache an object to which the cache will be attached
|
104
104
|
* @returns {ParsedResource} parsed parts
|
105
105
|
*/
|
106
106
|
const fn = (str, associatedObjectForCache) => {
|
@@ -134,7 +134,7 @@ const makeCacheableWithContext = fn => {
|
|
134
134
|
/**
|
135
135
|
* @param {string} context context used to create relative path
|
136
136
|
* @param {string} identifier identifier used to create relative path
|
137
|
-
* @param {
|
137
|
+
* @param {object=} associatedObjectForCache an object to which the cache will be attached
|
138
138
|
* @returns {string} the returned relative path
|
139
139
|
*/
|
140
140
|
const cachedFn = (context, identifier, associatedObjectForCache) => {
|
@@ -164,7 +164,7 @@ const makeCacheableWithContext = fn => {
|
|
164
164
|
};
|
165
165
|
|
166
166
|
/**
|
167
|
-
* @param {
|
167
|
+
* @param {object=} associatedObjectForCache an object to which the cache will be attached
|
168
168
|
* @returns {function(string, string): string} cached function
|
169
169
|
*/
|
170
170
|
cachedFn.bindCache = associatedObjectForCache => {
|
@@ -207,7 +207,7 @@ const makeCacheableWithContext = fn => {
|
|
207
207
|
|
208
208
|
/**
|
209
209
|
* @param {string} context context used to create relative path
|
210
|
-
* @param {
|
210
|
+
* @param {object=} associatedObjectForCache an object to which the cache will be attached
|
211
211
|
* @returns {function(string): string} cached function
|
212
212
|
*/
|
213
213
|
cachedFn.bindContextCache = (context, associatedObjectForCache) => {
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/** @typedef {import("eslint-scope").Reference} Reference */
|
9
|
+
/** @typedef {import("eslint-scope").Variable} Variable */
|
10
|
+
/** @typedef {import("../javascript/JavascriptParser").AnyNode} AnyNode */
|
11
|
+
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @param {Variable} variable variable
|
15
|
+
* @returns {Reference[]} references
|
16
|
+
*/
|
17
|
+
const getAllReferences = variable => {
|
18
|
+
let set = variable.references;
|
19
|
+
// Look for inner scope variables too (like in class Foo { t() { Foo } })
|
20
|
+
const identifiers = new Set(variable.identifiers);
|
21
|
+
for (const scope of variable.scope.childScopes) {
|
22
|
+
for (const innerVar of scope.variables) {
|
23
|
+
if (innerVar.identifiers.some(id => identifiers.has(id))) {
|
24
|
+
set = set.concat(innerVar.references);
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return set;
|
30
|
+
};
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @param {Program | Program[]} ast ast
|
34
|
+
* @param {AnyNode} node node
|
35
|
+
* @returns {undefined | AnyNode[]} result
|
36
|
+
*/
|
37
|
+
const getPathInAst = (ast, node) => {
|
38
|
+
if (ast === node) {
|
39
|
+
return [];
|
40
|
+
}
|
41
|
+
|
42
|
+
const nr = node.range;
|
43
|
+
|
44
|
+
const enterNode = n => {
|
45
|
+
if (!n) return undefined;
|
46
|
+
const r = n.range;
|
47
|
+
if (r) {
|
48
|
+
if (r[0] <= nr[0] && r[1] >= nr[1]) {
|
49
|
+
const path = getPathInAst(n, node);
|
50
|
+
if (path) {
|
51
|
+
path.push(n);
|
52
|
+
return path;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
return undefined;
|
57
|
+
};
|
58
|
+
|
59
|
+
if (Array.isArray(ast)) {
|
60
|
+
for (let i = 0; i < ast.length; i++) {
|
61
|
+
const enterResult = enterNode(ast[i]);
|
62
|
+
if (enterResult !== undefined) return enterResult;
|
63
|
+
}
|
64
|
+
} else if (ast && typeof ast === "object") {
|
65
|
+
const keys = Object.keys(ast);
|
66
|
+
for (let i = 0; i < keys.length; i++) {
|
67
|
+
const value = ast[keys[i]];
|
68
|
+
if (Array.isArray(value)) {
|
69
|
+
const pathResult = getPathInAst(value, node);
|
70
|
+
if (pathResult !== undefined) return pathResult;
|
71
|
+
} else if (value && typeof value === "object") {
|
72
|
+
const enterResult = enterNode(value);
|
73
|
+
if (enterResult !== undefined) return enterResult;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
};
|
78
|
+
|
79
|
+
module.exports = { getAllReferences, getPathInAst };
|
package/lib/util/runtime.js
CHANGED
@@ -229,22 +229,6 @@ const mergeRuntime = (a, b) => {
|
|
229
229
|
};
|
230
230
|
exports.mergeRuntime = mergeRuntime;
|
231
231
|
|
232
|
-
/**
|
233
|
-
* @param {RuntimeSpec[] | undefined} runtimes first
|
234
|
-
* @param {RuntimeSpec} runtime second
|
235
|
-
* @returns {RuntimeSpec} merged
|
236
|
-
*/
|
237
|
-
exports.deepMergeRuntime = (runtimes, runtime) => {
|
238
|
-
if (!Array.isArray(runtimes)) {
|
239
|
-
return runtime;
|
240
|
-
}
|
241
|
-
let merged = runtime;
|
242
|
-
for (const r of runtimes) {
|
243
|
-
merged = mergeRuntime(runtime, r);
|
244
|
-
}
|
245
|
-
return merged;
|
246
|
-
};
|
247
|
-
|
248
232
|
/**
|
249
233
|
* @param {RuntimeCondition} a first
|
250
234
|
* @param {RuntimeCondition} b second
|
@@ -390,6 +374,7 @@ const subtractRuntime = (a, b) => {
|
|
390
374
|
}
|
391
375
|
const set = new SortableSet(a);
|
392
376
|
set.delete(b);
|
377
|
+
return set;
|
393
378
|
} else {
|
394
379
|
const set = new SortableSet();
|
395
380
|
for (const item of a) {
|
@@ -445,7 +430,7 @@ exports.filterRuntime = (runtime, filter) => {
|
|
445
430
|
/**
|
446
431
|
* @template T
|
447
432
|
* @typedef {Map<string, T>} RuntimeSpecMapInnerMap
|
448
|
-
|
433
|
+
*/
|
449
434
|
|
450
435
|
/**
|
451
436
|
* @template T
|
package/lib/util/semver.js
CHANGED
@@ -153,6 +153,9 @@ exports.parseRange = str => {
|
|
153
153
|
}
|
154
154
|
return [1, ...remainder.slice(1)];
|
155
155
|
case "~":
|
156
|
+
if (remainder.length === 2 && remainder[0] === 0) {
|
157
|
+
return [1, ...remainder.slice(1)];
|
158
|
+
}
|
156
159
|
return [2, ...remainder.slice(1)];
|
157
160
|
case ">=":
|
158
161
|
return remainder;
|