webpack 5.91.0 → 5.92.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (174) hide show
  1. package/bin/webpack.js +1 -2
  2. package/lib/APIPlugin.js +6 -2
  3. package/lib/Cache.js +1 -1
  4. package/lib/Chunk.js +7 -4
  5. package/lib/ChunkGraph.js +20 -7
  6. package/lib/ChunkGroup.js +9 -3
  7. package/lib/CleanPlugin.js +1 -1
  8. package/lib/Compilation.js +33 -27
  9. package/lib/Compiler.js +28 -8
  10. package/lib/ConcatenationScope.js +3 -3
  11. package/lib/ContextModule.js +95 -43
  12. package/lib/DefinePlugin.js +14 -4
  13. package/lib/Dependency.js +8 -8
  14. package/lib/DependencyTemplate.js +10 -5
  15. package/lib/DllReferencePlugin.js +1 -1
  16. package/lib/EvalDevToolModulePlugin.js +11 -0
  17. package/lib/ExportsInfo.js +22 -4
  18. package/lib/ExternalModule.js +49 -18
  19. package/lib/FileSystemInfo.js +68 -41
  20. package/lib/FlagDependencyExportsPlugin.js +21 -7
  21. package/lib/Generator.js +2 -3
  22. package/lib/HotModuleReplacementPlugin.js +108 -45
  23. package/lib/IgnorePlugin.js +4 -1
  24. package/lib/LibManifestPlugin.js +2 -2
  25. package/lib/Module.js +11 -12
  26. package/lib/ModuleFactory.js +3 -3
  27. package/lib/ModuleFilenameHelpers.js +29 -16
  28. package/lib/ModuleGraph.js +5 -5
  29. package/lib/MultiCompiler.js +36 -1
  30. package/lib/NormalModule.js +10 -12
  31. package/lib/NormalModuleFactory.js +17 -8
  32. package/lib/Parser.js +1 -1
  33. package/lib/PlatformPlugin.js +39 -0
  34. package/lib/ProgressPlugin.js +1 -1
  35. package/lib/RecordIdsPlugin.js +4 -4
  36. package/lib/ResolverFactory.js +3 -3
  37. package/lib/RuntimeTemplate.js +22 -18
  38. package/lib/Stats.js +1 -1
  39. package/lib/Template.js +5 -5
  40. package/lib/TemplatedPathPlugin.js +16 -1
  41. package/lib/asset/AssetGenerator.js +15 -0
  42. package/lib/buildChunkGraph.js +3 -3
  43. package/lib/cache/MemoryWithGcCachePlugin.js +1 -1
  44. package/lib/cache/PackFileCacheStrategy.js +2 -2
  45. package/lib/cache/ResolverCachePlugin.js +8 -8
  46. package/lib/cache/getLazyHashedEtag.js +1 -1
  47. package/lib/cli.js +5 -5
  48. package/lib/config/browserslistTargetHandler.js +7 -1
  49. package/lib/config/defaults.js +85 -34
  50. package/lib/config/target.js +18 -11
  51. package/lib/container/ContainerEntryModule.js +1 -1
  52. package/lib/css/CssExportsGenerator.js +43 -17
  53. package/lib/css/CssGenerator.js +22 -12
  54. package/lib/css/CssLoadingRuntimeModule.js +8 -5
  55. package/lib/css/CssModulesPlugin.js +197 -100
  56. package/lib/css/CssParser.js +24 -15
  57. package/lib/css/walkCssTokens.js +1 -1
  58. package/lib/debug/ProfilingPlugin.js +1 -1
  59. package/lib/dependencies/ContextElementDependency.js +2 -2
  60. package/lib/dependencies/CssExportDependency.js +2 -2
  61. package/lib/dependencies/CssLocalIdentifierDependency.js +9 -2
  62. package/lib/dependencies/CssUrlDependency.js +5 -4
  63. package/lib/dependencies/ExportsInfoDependency.js +1 -1
  64. package/lib/dependencies/ExternalModuleDependency.js +4 -2
  65. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -2
  66. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -2
  67. package/lib/dependencies/HarmonyImportDependency.js +2 -2
  68. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +41 -18
  69. package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
  70. package/lib/dependencies/HarmonyImportSpecifierDependency.js +43 -32
  71. package/lib/dependencies/ImportDependency.js +2 -2
  72. package/lib/dependencies/ImportEagerDependency.js +2 -2
  73. package/lib/dependencies/ImportMetaPlugin.js +1 -1
  74. package/lib/dependencies/ImportParserPlugin.js +3 -1
  75. package/lib/dependencies/ImportWeakDependency.js +2 -2
  76. package/lib/dependencies/LoaderPlugin.js +2 -2
  77. package/lib/dependencies/ModuleDependency.js +2 -2
  78. package/lib/dependencies/PureExpressionDependency.js +63 -49
  79. package/lib/dependencies/WorkerDependency.js +1 -1
  80. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +90 -2
  81. package/lib/hmr/LazyCompilationPlugin.js +2 -2
  82. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
  83. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
  84. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  85. package/lib/ids/IdHelpers.js +6 -6
  86. package/lib/ids/NamedChunkIdsPlugin.js +1 -1
  87. package/lib/ids/NamedModuleIdsPlugin.js +1 -1
  88. package/lib/ids/SyncModuleIdsPlugin.js +2 -2
  89. package/lib/index.js +11 -0
  90. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  91. package/lib/javascript/JavascriptGenerator.js +0 -1
  92. package/lib/javascript/JavascriptModulesPlugin.js +174 -17
  93. package/lib/javascript/JavascriptParser.js +37 -16
  94. package/lib/library/AbstractLibraryPlugin.js +2 -2
  95. package/lib/library/AmdLibraryPlugin.js +2 -2
  96. package/lib/library/AssignLibraryPlugin.js +3 -3
  97. package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
  98. package/lib/library/JsonpLibraryPlugin.js +2 -2
  99. package/lib/library/ModuleLibraryPlugin.js +2 -2
  100. package/lib/library/SystemLibraryPlugin.js +2 -2
  101. package/lib/library/UmdLibraryPlugin.js +33 -12
  102. package/lib/logging/createConsoleLogger.js +2 -2
  103. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  104. package/lib/node/NodeEnvironmentPlugin.js +1 -1
  105. package/lib/node/NodeTemplatePlugin.js +1 -1
  106. package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
  107. package/lib/node/nodeConsole.js +1 -1
  108. package/lib/optimize/AggressiveMergingPlugin.js +1 -1
  109. package/lib/optimize/ConcatenatedModule.js +11 -76
  110. package/lib/optimize/InnerGraph.js +1 -1
  111. package/lib/optimize/LimitChunkCountPlugin.js +1 -2
  112. package/lib/optimize/ModuleConcatenationPlugin.js +1 -1
  113. package/lib/optimize/RealContentHashPlugin.js +3 -3
  114. package/lib/optimize/SideEffectsFlagPlugin.js +2 -2
  115. package/lib/optimize/SplitChunksPlugin.js +8 -8
  116. package/lib/performance/SizeLimitsPlugin.js +2 -2
  117. package/lib/rules/ObjectMatcherRulePlugin.js +11 -1
  118. package/lib/rules/RuleSetCompiler.js +9 -7
  119. package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
  120. package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
  121. package/lib/schemes/HttpUriPlugin.js +1 -1
  122. package/lib/serialization/BinaryMiddleware.js +4 -4
  123. package/lib/serialization/FileMiddleware.js +3 -3
  124. package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
  125. package/lib/serialization/ObjectMiddleware.js +6 -5
  126. package/lib/serialization/PlainObjectSerializer.js +2 -2
  127. package/lib/serialization/SerializerMiddleware.js +2 -2
  128. package/lib/serialization/SingleItemMiddleware.js +2 -2
  129. package/lib/serialization/types.js +1 -1
  130. package/lib/sharing/ConsumeSharedModule.js +1 -1
  131. package/lib/sharing/ProvideSharedPlugin.js +1 -1
  132. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  133. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
  134. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  135. package/lib/stats/StatsFactory.js +2 -2
  136. package/lib/stats/StatsPrinter.js +6 -6
  137. package/lib/util/ArrayQueue.js +14 -21
  138. package/lib/util/AsyncQueue.js +1 -1
  139. package/lib/util/Queue.js +8 -2
  140. package/lib/util/SortableSet.js +16 -4
  141. package/lib/util/TupleQueue.js +8 -2
  142. package/lib/util/WeakTupleMap.js +3 -3
  143. package/lib/util/binarySearchBounds.js +1 -1
  144. package/lib/util/cleverMerge.js +2 -2
  145. package/lib/util/comparators.js +4 -2
  146. package/lib/util/conventions.js +1 -1
  147. package/lib/util/createHash.js +3 -5
  148. package/lib/util/deprecation.js +3 -3
  149. package/lib/util/deterministicGrouping.js +2 -2
  150. package/lib/util/findGraphRoots.js +1 -1
  151. package/lib/util/fs.js +15 -15
  152. package/lib/util/identifier.js +5 -5
  153. package/lib/util/mergeScope.js +79 -0
  154. package/lib/util/runtime.js +2 -17
  155. package/lib/util/semver.js +3 -0
  156. package/lib/util/smartGrouping.js +3 -3
  157. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
  158. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
  159. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  160. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -1
  161. package/lib/wasm-sync/WebAssemblyGenerator.js +17 -17
  162. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
  163. package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
  164. package/lib/web/FetchCompileWasmPlugin.js +1 -1
  165. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  166. package/lib/webpack.js +12 -3
  167. package/package.json +20 -18
  168. package/schemas/WebpackOptions.check.js +1 -1
  169. package/schemas/WebpackOptions.json +30 -2
  170. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  171. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  172. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  173. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  174. 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 {Object} options options
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 {Object} KnownStatsFactoryContext
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<[Object, any, StatsFactoryContext]>>} */
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 {Object} PrintedElement
20
+ * @typedef {object} PrintedElement
21
21
  * @property {string} element
22
22
  * @property {string} content
23
23
  */
24
24
 
25
25
  /**
26
- * @typedef {Object} KnownStatsPrinterContext
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 {Object} object Object to print
151
- * @param {Object=} baseContext The base context
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 {Object} object object
172
- * @param {Object=} baseContext context
171
+ * @param {object} object object
172
+ * @param {object=} baseContext context
173
173
  * @returns {string} printed result
174
174
  */
175
175
  _print(type, object, baseContext) {
@@ -13,9 +13,15 @@ class ArrayQueue {
13
13
  * @param {Iterable<T>=} items The initial elements.
14
14
  */
15
15
  constructor(items) {
16
- /** @private @type {T[]} */
16
+ /**
17
+ * @private
18
+ * @type {T[]}
19
+ */
17
20
  this._list = items ? Array.from(items) : [];
18
- /** @private @type {T[]} */
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
- if (!reversed) {
85
- i++;
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: true,
99
- value: undefined
91
+ done: false,
92
+ value: item
100
93
  };
101
94
  }
102
95
  return {
103
- done: false,
104
- value: this._listReversed[i]
96
+ done: true,
97
+ value: undefined
105
98
  };
106
99
  }
107
100
  };
@@ -53,7 +53,7 @@ class AsyncQueueEntry {
53
53
  */
54
54
  class AsyncQueue {
55
55
  /**
56
- * @param {Object} options options object
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
- /** @private @type {Set<T>} */
16
+ /**
17
+ * @private
18
+ * @type {Set<T>}
19
+ */
17
20
  this._set = new Set(items);
18
- /** @private @type {Iterator<T>} */
21
+ /**
22
+ * @private
23
+ * @type {Iterator<T>}
24
+ */
19
25
  this._iterator = this._set[Symbol.iterator]();
20
26
  }
21
27
 
@@ -21,13 +21,25 @@ class SortableSet extends Set {
21
21
  */
22
22
  constructor(initialIterable, defaultSort) {
23
23
  super(initialIterable);
24
- /** @private @type {undefined | function(T, T): number}} */
24
+ /**
25
+ * @private
26
+ * @type {undefined | function(T, T): number}}
27
+ */
25
28
  this._sortFn = defaultSort;
26
- /** @private @type {typeof NONE | undefined | function(T, T): number}} */
29
+ /**
30
+ * @private
31
+ * @type {typeof NONE | undefined | function(T, T): number}}
32
+ */
27
33
  this._lastActiveSortFn = NONE;
28
- /** @private @type {Map<Function, any> | undefined} */
34
+ /**
35
+ * @private
36
+ * @type {Map<Function, any> | undefined}
37
+ */
29
38
  this._cache = undefined;
30
- /** @private @type {Map<Function, any> | undefined} */
39
+ /**
40
+ * @private
41
+ * @type {Map<Function, any> | undefined}
42
+ */
31
43
  this._cacheOrderIndependent = undefined;
32
44
  }
33
45
 
@@ -15,9 +15,15 @@ class TupleQueue {
15
15
  * @param {Iterable<T>=} items The initial elements.
16
16
  */
17
17
  constructor(items) {
18
- /** @private @type {TupleSet<T>} */
18
+ /**
19
+ * @private
20
+ * @type {TupleSet<T>}
21
+ */
19
22
  this._set = new TupleSet(items);
20
- /** @private @type {Iterator<T>} */
23
+ /**
24
+ * @private
25
+ * @type {Iterator<T>}
26
+ */
21
27
  this._iterator = this._set[Symbol.iterator]();
22
28
  }
23
29
 
@@ -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 {function} The compiled binary search function.
78
+ * @returns {Function} The compiled binary search function.
79
79
  */
80
80
  const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
81
81
  const arg1 = compileSearch(
@@ -81,14 +81,14 @@ const cachedSetProperty = (obj, property, value) => {
81
81
  };
82
82
 
83
83
  /**
84
- * @typedef {Object} ObjectParsedPropertyEntry
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 {Object} ParsedObject
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
  */
@@ -279,7 +279,10 @@ exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
279
279
  */
280
280
  class TwoKeyWeakMap {
281
281
  constructor() {
282
- /** @private @type {WeakMap<any, WeakMap<any, T | undefined>>} */
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();
@@ -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) => {
@@ -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 {Object<string, Map<string, string>>} */
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 | undefined} algorithm the algorithm name or a constructor creating a 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
  }
@@ -11,7 +11,7 @@ const util = require("util");
11
11
  const deprecationCache = new Map();
12
12
 
13
13
  /**
14
- * @typedef {Object} FakeHookMarker
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 {Object} obj object
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 {Object} frozen object with deprecation when modifying
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 {Object} GroupedItems<T>
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 {Object} Options
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
@@ -41,7 +41,7 @@ class Cycle {
41
41
 
42
42
  /**
43
43
  * @template T
44
- * @typedef {Object} StackEntry
44
+ * @typedef {object} StackEntry
45
45
  * @property {Node<T>} node
46
46
  * @property {Node<T>[]} openEdges
47
47
  */
package/lib/util/fs.js CHANGED
@@ -12,7 +12,7 @@ const path = require("path");
12
12
 
13
13
  /**
14
14
  * @template T
15
- * @typedef {Object} IStatsBase
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 {Object} Dirent
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 {Object} WatcherInfo
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 {Object} Watcher
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 {Object} ObjectEncodingOptions
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 {Object} StatOptions
156
+ * @typedef {object} StatOptions
157
157
  * @property {(boolean | undefined)=} bigint
158
158
  */
159
159
 
160
160
  /**
161
- * @typedef {Object} StatSyncOptions
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 {Object} InputFileSystem
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 {Object} OutputFileSystem
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 {Object} WatchFileSystem
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 {Object} StreamOptions
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 {Object} FSImplementation
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 {Object} ReadSyncOptions
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 {Object} ReadAsyncOptions
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 {Object} IntermediateFileSystemExtras
442
+ * @typedef {object} IntermediateFileSystemExtras
443
443
  * @property {MkdirSync} mkdirSync
444
444
  * @property {CreateWriteStream} createWriteStream
445
445
  * @property {Open} open
@@ -11,7 +11,7 @@ const SEGMENTS_SPLIT_REGEXP = /([|!])/;
11
11
  const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
12
12
 
13
13
  /**
14
- * @typedef {Object} MakeRelativePathsCache
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 {Object=} associatedObjectForCache an object to which the cache will be attached
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 {Object=} associatedObjectForCache an object to which the cache will be attached
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 {Object=} associatedObjectForCache an object to which the cache will be attached
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 {Object=} associatedObjectForCache an object to which the cache will be attached
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 };
@@ -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
@@ -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;