webpack 5.97.0 → 5.97.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.
@@ -14,7 +14,7 @@ const RuntimeGlobals = require("./RuntimeGlobals");
14
14
  const WebpackError = require("./WebpackError");
15
15
  const ConstDependency = require("./dependencies/ConstDependency");
16
16
  const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression");
17
-
17
+ const { VariableInfo } = require("./javascript/JavascriptParser");
18
18
  const {
19
19
  evaluateToString,
20
20
  toConstantDependency
@@ -455,10 +455,16 @@ class DefinePlugin {
455
455
  */
456
456
  const applyDefineKey = (prefix, key) => {
457
457
  const splittedKey = key.split(".");
458
+ const firstKey = splittedKey[0];
458
459
  for (const [i, _] of splittedKey.slice(1).entries()) {
459
460
  const fullKey = prefix + splittedKey.slice(0, i + 1).join(".");
460
461
  parser.hooks.canRename.for(fullKey).tap(PLUGIN_NAME, () => {
461
462
  addValueDependency(key);
463
+ if (
464
+ parser.scope.definitions.get(firstKey) instanceof VariableInfo
465
+ ) {
466
+ return false;
467
+ }
462
468
  return true;
463
469
  });
464
470
  }
@@ -21,7 +21,6 @@ class HotModuleReplacementRuntimeModule extends RuntimeModule {
21
21
  return Template.getFunctionContent(
22
22
  require("./HotModuleReplacement.runtime.js")
23
23
  )
24
- .replace(/\$getFullHash\$/g, RuntimeGlobals.getFullHash)
25
24
  .replace(
26
25
  /\$interceptModuleExecution\$/g,
27
26
  RuntimeGlobals.interceptModuleExecution
@@ -5004,3 +5004,4 @@ module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
5004
5004
  module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION =
5005
5005
  ALLOWED_MEMBER_TYPES_CALL_EXPRESSION;
5006
5006
  module.exports.getImportAttributes = getImportAttributes;
5007
+ module.exports.VariableInfo = VariableInfo;
package/lib/util/Queue.js CHANGED
@@ -8,25 +8,24 @@
8
8
  /**
9
9
  * @template T
10
10
  */
11
- class Node {
11
+ class Queue {
12
12
  /**
13
- * @param {T} value the value
13
+ * @param {Iterable<T>=} items The initial elements.
14
14
  */
15
- constructor(value) {
16
- this.value = value;
17
- /** @type {Node<T> | undefined} */
18
- this.next = undefined;
15
+ constructor(items) {
16
+ /**
17
+ * @private
18
+ * @type {Set<T>}
19
+ */
20
+ this._set = new Set(items);
19
21
  }
20
- }
21
22
 
22
- /**
23
- * @template T
24
- */
25
- class Queue {
26
- constructor() {
27
- this._head = undefined;
28
- this._tail = undefined;
29
- this._size = 0;
23
+ /**
24
+ * Returns the number of elements in this queue.
25
+ * @returns {number} The number of elements in this queue.
26
+ */
27
+ get length() {
28
+ return this._set.size;
30
29
  }
31
30
 
32
31
  /**
@@ -35,18 +34,7 @@ class Queue {
35
34
  * @returns {void}
36
35
  */
37
36
  enqueue(item) {
38
- const node = new Node(item);
39
-
40
- if (this._head) {
41
- /** @type {Node<T>} */
42
- (this._tail).next = node;
43
- this._tail = node;
44
- } else {
45
- this._head = node;
46
- this._tail = node;
47
- }
48
-
49
- this._size++;
37
+ this._set.add(item);
50
38
  }
51
39
 
52
40
  /**
@@ -54,31 +42,10 @@ class Queue {
54
42
  * @returns {T | undefined} The head of the queue of `undefined` if this queue is empty.
55
43
  */
56
44
  dequeue() {
57
- const current = this._head;
58
- if (!current) {
59
- return;
60
- }
61
-
62
- this._head = this._head.next;
63
- this._size--;
64
- return current.value;
65
- }
66
-
67
- /**
68
- * Returns the number of elements in this queue.
69
- * @returns {number} The number of elements in this queue.
70
- */
71
- get length() {
72
- return this._size;
73
- }
74
-
75
- *[Symbol.iterator]() {
76
- let current = this._head;
77
-
78
- while (current) {
79
- yield current.value;
80
- current = current.next;
81
- }
45
+ const result = this._set[Symbol.iterator]().next();
46
+ if (result.done) return;
47
+ this._set.delete(result.value);
48
+ return result.value;
82
49
  }
83
50
  }
84
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.97.0",
3
+ "version": "5.97.1",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
package/types.d.ts CHANGED
@@ -4546,7 +4546,7 @@ declare interface ExportSpec {
4546
4546
  */
4547
4547
  hidden?: boolean;
4548
4548
  }
4549
- type ExportedVariableInfo = string | ScopeInfo | VariableInfo;
4549
+ type ExportedVariableInfo = string | VariableInfo | ScopeInfo;
4550
4550
  declare abstract class ExportsInfo {
4551
4551
  get ownedExports(): Iterable<ExportInfo>;
4552
4552
  get orderedOwnedExports(): Iterable<ExportInfo>;
@@ -6810,7 +6810,7 @@ declare class JavascriptParser extends Parser {
6810
6810
  | undefined
6811
6811
  | ((
6812
6812
  arg0: string,
6813
- arg1: string | ScopeInfo | VariableInfo,
6813
+ arg1: string | VariableInfo | ScopeInfo,
6814
6814
  arg2: () => string[]
6815
6815
  ) => any),
6816
6816
  defined: undefined | ((arg0: string) => any),
@@ -7143,6 +7143,7 @@ declare class JavascriptParser extends Parser {
7143
7143
  | ExportAllDeclarationJavascriptParser
7144
7144
  | ImportExpressionJavascriptParser
7145
7145
  ) => undefined | ImportAttributes;
7146
+ static VariableInfo: typeof VariableInfo;
7146
7147
  }
7147
7148
 
7148
7149
  /**
@@ -13918,7 +13919,7 @@ declare interface RuntimeValueOptions {
13918
13919
  * to create the range of the _parent node_.
13919
13920
  */
13920
13921
  declare interface ScopeInfo {
13921
- definitions: StackedMap<string, ScopeInfo | VariableInfo>;
13922
+ definitions: StackedMap<string, VariableInfo | ScopeInfo>;
13922
13923
  topLevelScope: boolean | "arrow";
13923
13924
  inShorthand: string | boolean;
13924
13925
  inTaggedTemplateTag: boolean;
@@ -15249,7 +15250,12 @@ type UsageStateType = 0 | 1 | 2 | 3 | 4;
15249
15250
  type UsedName = string | false | string[];
15250
15251
  type Value = string | number | boolean | RegExp;
15251
15252
  type ValueCacheVersion = string | Set<string>;
15252
- declare abstract class VariableInfo {
15253
+ declare class VariableInfo {
15254
+ constructor(
15255
+ declaredScope: ScopeInfo,
15256
+ freeName?: string | true,
15257
+ tagInfo?: TagInfo
15258
+ );
15253
15259
  declaredScope: ScopeInfo;
15254
15260
  freeName?: string | true;
15255
15261
  tagInfo?: TagInfo;