webpack 5.108.3 → 5.109.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.
Files changed (191) hide show
  1. package/lib/APIPlugin.js +48 -29
  2. package/lib/CacheFacade.js +8 -0
  3. package/lib/ChunkGroup.js +1 -0
  4. package/lib/CompatibilityPlugin.js +31 -29
  5. package/lib/Compilation.js +50 -8
  6. package/lib/ConstPlugin.js +11 -11
  7. package/lib/ContextModule.js +239 -6
  8. package/lib/ContextModuleFactory.js +139 -14
  9. package/lib/DefinePlugin.js +396 -101
  10. package/lib/Entrypoint.js +1 -1
  11. package/lib/ExportsInfoApiPlugin.js +2 -2
  12. package/lib/ExternalModule.js +107 -5
  13. package/lib/ExternalModuleFactoryPlugin.js +20 -1
  14. package/lib/FileSystemInfo.js +130 -74
  15. package/lib/FlagDependencyExportsPlugin.js +55 -8
  16. package/lib/HotModuleReplacementPlugin.js +18 -15
  17. package/lib/LazyBarrel.js +30 -3
  18. package/lib/Module.js +3 -0
  19. package/lib/ModuleFilenameHelpers.js +2 -2
  20. package/lib/ModuleTypeConstants.js +8 -1
  21. package/lib/MultiCompiler.js +13 -2
  22. package/lib/MultiWatching.js +1 -0
  23. package/lib/NodeStuffPlugin.js +51 -33
  24. package/lib/NormalModule.js +169 -405
  25. package/lib/NormalModuleFactory.js +76 -2
  26. package/lib/ProgressPlugin.js +211 -119
  27. package/lib/ProvidePlugin.js +2 -2
  28. package/lib/RuntimeGlobals.js +47 -0
  29. package/lib/RuntimePlugin.js +33 -0
  30. package/lib/RuntimeTemplate.js +304 -16
  31. package/lib/UseStrictPlugin.js +1 -1
  32. package/lib/WebpackIsIncludedPlugin.js +1 -1
  33. package/lib/WebpackOptionsApply.js +24 -19
  34. package/lib/asset/AssetGenerator.js +110 -28
  35. package/lib/asset/AssetModulesPlugin.js +92 -2
  36. package/lib/asset/WebManifestGenerator.js +164 -0
  37. package/lib/asset/WebManifestParser.js +130 -0
  38. package/lib/async-modules/AwaitDependenciesInitFragment.js +14 -4
  39. package/lib/async-modules/isGeneratorLowered.js +26 -0
  40. package/lib/cache/PackFileCacheStrategy.js +9 -3
  41. package/lib/config/browserslistTargetHandler.js +40 -0
  42. package/lib/config/defaults.js +222 -32
  43. package/lib/config/normalization.js +26 -0
  44. package/lib/config/target.js +9 -1
  45. package/lib/css/CssGenerator.js +73 -73
  46. package/lib/css/CssLoadingRuntimeModule.js +5 -1
  47. package/lib/css/CssModulesPlugin.js +92 -53
  48. package/lib/css/CssParser.js +843 -302
  49. package/lib/css/syntax.js +1219 -483
  50. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -6
  51. package/lib/dependencies/AMDPlugin.js +2 -2
  52. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +13 -13
  53. package/lib/dependencies/CommonJsDependencyHelpers.js +39 -0
  54. package/lib/dependencies/CommonJsExportsDependency.js +47 -2
  55. package/lib/dependencies/CommonJsExportsParserPlugin.js +10 -10
  56. package/lib/dependencies/CommonJsImportsParserPlugin.js +18 -18
  57. package/lib/dependencies/CommonJsPlugin.js +2 -2
  58. package/lib/dependencies/CommonJsRequireDependency.js +26 -1
  59. package/lib/dependencies/CommonJsSelfReferenceDependency.js +32 -1
  60. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  61. package/lib/dependencies/CreateRequireParserPlugin.js +6 -6
  62. package/lib/dependencies/CssIcssExportDependency.js +190 -87
  63. package/lib/dependencies/CssUrlDependency.js +35 -4
  64. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -2
  65. package/lib/dependencies/HarmonyCompatibilityDependency.js +32 -14
  66. package/lib/dependencies/HarmonyDetectionParserPlugin.js +43 -13
  67. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +7 -19
  68. package/lib/dependencies/HarmonyImportDependency.js +12 -1
  69. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +34 -107
  70. package/lib/dependencies/HarmonyImportGuard.js +192 -20
  71. package/lib/dependencies/HarmonyModulesPlugin.js +6 -0
  72. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
  73. package/lib/dependencies/HtmlEntryDependency.js +797 -172
  74. package/lib/dependencies/HtmlSourceDependency.js +26 -0
  75. package/lib/dependencies/ImportDependency.js +43 -1
  76. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +31 -18
  77. package/lib/dependencies/ImportMetaContextPlugin.js +38 -7
  78. package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
  79. package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
  80. package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
  81. package/lib/dependencies/ImportMetaPlugin.js +532 -180
  82. package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
  83. package/lib/dependencies/ImportParserPlugin.js +87 -26
  84. package/lib/dependencies/ImportPhase.js +10 -8
  85. package/lib/dependencies/LoaderPlugin.js +5 -1
  86. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  87. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -6
  88. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -11
  89. package/lib/dependencies/SystemPlugin.js +2 -4
  90. package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
  91. package/lib/dependencies/URLDependency.js +141 -21
  92. package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +324 -112
  93. package/lib/dependencies/WorkerDependency.js +86 -18
  94. package/lib/dependencies/WorkletDependency.js +278 -0
  95. package/lib/dll/DelegatedModuleFactoryPlugin.js +19 -0
  96. package/lib/errors/EnvironmentNotSupportAsyncWarning.js +1 -1
  97. package/lib/errors/LoaderLoadingError.js +20 -0
  98. package/lib/errors/ModuleParseError.js +39 -22
  99. package/lib/errors/NodeStuffInWebError.js +1 -1
  100. package/lib/esm/ModuleChunkFormatPlugin.js +47 -14
  101. package/lib/esm/ModuleChunkLoadingPlugin.js +8 -1
  102. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +29 -1
  103. package/lib/hmr/lazyCompilationBackend.js +32 -8
  104. package/lib/html/HtmlGenerator.js +940 -91
  105. package/lib/html/HtmlModule.js +3 -2
  106. package/lib/html/HtmlModulesPlugin.js +625 -170
  107. package/lib/html/HtmlParser.js +812 -340
  108. package/lib/html/favicon.svg +1 -0
  109. package/lib/html/syntax.js +2116 -834
  110. package/lib/ids/IdHelpers.js +1 -1
  111. package/lib/index.js +6 -0
  112. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
  113. package/lib/javascript/BasicEvaluatedExpression.js +366 -48
  114. package/lib/javascript/JavascriptGenerator.js +197 -49
  115. package/lib/javascript/JavascriptModulesPlugin.js +178 -24
  116. package/lib/javascript/JavascriptParser.js +711 -355
  117. package/lib/javascript/JavascriptParserHelpers.js +3 -6
  118. package/lib/javascript/syntax.js +4380 -0
  119. package/lib/library/ModuleLibraryPlugin.js +38 -1
  120. package/lib/loaders/LoaderRunner.js +714 -0
  121. package/lib/loaders/loadLoader.js +100 -0
  122. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +19 -0
  123. package/lib/node/ReadFileCompileWasmPlugin.js +14 -0
  124. package/lib/optimize/ConcatenatedModule.js +120 -16
  125. package/lib/optimize/FlagIncludedChunksPlugin.js +13 -3
  126. package/lib/optimize/InnerGraphPlugin.js +50 -30
  127. package/lib/optimize/ModuleConcatenationPlugin.js +69 -3
  128. package/lib/optimize/SideEffectsFlagPlugin.js +86 -43
  129. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +15 -0
  130. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +24 -13
  131. package/lib/prefetch/ResourceHintPlugin.js +663 -0
  132. package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
  133. package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
  134. package/lib/prefetch/parseResourceHintOptions.js +103 -0
  135. package/lib/rules/RuleSetCompiler.js +114 -0
  136. package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
  137. package/lib/runtime/AsyncModuleRuntimeModule.js +24 -8
  138. package/lib/runtime/AutoPublicPathRuntimeModule.js +7 -1
  139. package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
  140. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
  141. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +204 -8
  142. package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +4 -1
  143. package/lib/schemes/HttpUriPlugin.js +40 -1
  144. package/lib/schemes/VirtualUrlPlugin.js +1 -2
  145. package/lib/serialization/FileMiddleware.js +29 -3
  146. package/lib/stats/DefaultStatsFactoryPlugin.js +32 -3
  147. package/lib/stats/DefaultStatsPresetPlugin.js +2 -0
  148. package/lib/stats/DefaultStatsPrinterPlugin.js +12 -2
  149. package/lib/stats/StatsFactory.js +15 -8
  150. package/lib/url/URLParserPlugin.js +98 -19
  151. package/lib/util/AsyncQueue.js +122 -72
  152. package/lib/util/LocConverter.js +9 -8
  153. package/lib/util/SetHelpers.js +1 -1
  154. package/lib/util/SourceProcessor.js +41 -28
  155. package/lib/util/StackedMap.js +122 -48
  156. package/lib/util/binarySearchBounds.js +2 -2
  157. package/lib/util/concatenate.js +40 -14
  158. package/lib/util/createHooksRegistry.js +13 -5
  159. package/lib/util/dataURL.js +2 -2
  160. package/lib/util/deterministicGrouping.js +7 -5
  161. package/lib/util/formatSize.js +6 -2
  162. package/lib/util/globUtils.js +710 -0
  163. package/lib/util/identifier.js +23 -6
  164. package/lib/util/implicitTypeLoaderFallback.js +62 -0
  165. package/lib/util/internalSerializables.js +88 -71
  166. package/lib/util/magicComment.js +121 -25
  167. package/lib/util/numberHash.js +2 -2
  168. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +24 -18
  169. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +33 -22
  170. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +79 -16
  171. package/lib/web/FetchCompileAsyncWasmPlugin.js +19 -0
  172. package/lib/web/FetchCompileWasmPlugin.js +14 -0
  173. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -0
  174. package/lib/webpack.js +65 -0
  175. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -0
  176. package/module.d.ts +21 -0
  177. package/package.json +14 -13
  178. package/schemas/WebpackOptions.check.js +1 -1
  179. package/schemas/WebpackOptions.json +759 -36
  180. package/schemas/plugins/HtmlParserOptions.check.js +1 -1
  181. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  182. package/schemas/plugins/ProgressPlugin.json +17 -1
  183. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  184. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  185. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  186. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  187. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  188. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
  189. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  190. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  191. package/types.d.ts +1300 -325
@@ -363,7 +363,7 @@ const assignNames = (
363
363
  items.sort(comparator);
364
364
  let i = 0;
365
365
  for (const item of items) {
366
- while (nameToItems2.has(name + i) && usedIds.has(name + i)) i++;
366
+ while (usedIds.has(name + i)) i++;
367
367
  assignName(item, name + i);
368
368
  usedIds.add(name + i);
369
369
  i++;
package/lib/index.js CHANGED
@@ -606,6 +606,12 @@ module.exports = mergeExports(fn, {
606
606
  }
607
607
  },
608
608
 
609
+ html: {
610
+ get HtmlModulesPlugin() {
611
+ return require("./html/HtmlModulesPlugin");
612
+ }
613
+ },
614
+
609
615
  library: {
610
616
  get AbstractLibraryPlugin() {
611
617
  return require("./library/AbstractLibraryPlugin");
@@ -65,12 +65,11 @@ class ArrayPushCallbackChunkFormatPlugin {
65
65
  } else {
66
66
  const chunkLoadingGlobal =
67
67
  runtimeTemplate.outputOptions.chunkLoadingGlobal;
68
+ const chunkLoadingGlobalExpr = `${globalObject}[${JSON.stringify(
69
+ chunkLoadingGlobal
70
+ )}]`;
68
71
  source.add(
69
- `(${globalObject}[${JSON.stringify(
70
- chunkLoadingGlobal
71
- )}] = ${globalObject}[${JSON.stringify(
72
- chunkLoadingGlobal
73
- )}] || []).push([`
72
+ `(${runtimeTemplate.assignOr(chunkLoadingGlobalExpr, "[]")}).push([`
74
73
  );
75
74
  source.add(`${JSON.stringify(chunk.ids)},`);
76
75
  source.add(modules);
@@ -31,36 +31,46 @@ const TypeBigInt = 13;
31
31
  /** @typedef {() => MembersOptionals} GetMembersOptionals */
32
32
  /** @typedef {() => MemberRanges} GetMemberRanges */
33
33
 
34
+ // _flags bit layout: bits 0-3 type, then the boolean facts
35
+ const FLAG_TYPE_MASK = 0b1111;
36
+ const FLAG_TRUTHY = 0b10000;
37
+ const FLAG_FALSY = 0b100000;
38
+ const FLAG_NULLISH_KNOWN = 0b1000000;
39
+ const FLAG_NULLISH = 0b10000000;
40
+ const FLAG_SIDE_EFFECTS = 0b100000000;
41
+
42
+ /**
43
+ * An instance is allocated for a large share of walked expressions, so the
44
+ * boolean facts live in one packed flags slot and the scalar/identifier
45
+ * fields in five slots shared by type, with accessors keeping every public
46
+ * field readable. This shrinks instances from 224 to 144 bytes on V8.
47
+ */
34
48
  class BasicEvaluatedExpression {
35
49
  constructor() {
36
- /** @type {number} */
37
- this.type = TypeUnknown;
50
+ this._flags = FLAG_SIDE_EFFECTS;
38
51
  /** @type {Range | undefined} */
39
- this.range = undefined;
40
- /** @type {boolean} */
41
- this.falsy = false;
42
- /** @type {boolean} */
43
- this.truthy = false;
44
- /** @type {boolean | undefined} */
45
- this.nullish = undefined;
46
- /** @type {boolean} */
47
- this.sideEffects = true;
48
- /** @type {boolean | undefined} */
49
- this.bool = undefined;
50
- /** @type {number | undefined} */
51
- this.number = undefined;
52
- /** @type {bigint | undefined} */
53
- this.bigint = undefined;
54
- /** @type {RegExp | undefined} */
55
- this.regExp = undefined;
56
- /** @type {string | undefined} */
57
- this.string = undefined;
52
+ this._range = undefined;
53
+ /** @type {Node | undefined} */
54
+ this.expression = undefined;
55
+ // _v1..._v5 hold the scalar type-specific fields, the accessors narrow
56
+ // them by type; expression-valued fields get typed slots below
57
+ /** @type {unknown} */
58
+ this._v1 = undefined;
59
+ /** @type {unknown} */
60
+ this._v2 = undefined;
61
+ /** @type {unknown} */
62
+ this._v3 = undefined;
63
+ /** @type {unknown} */
64
+ this._v4 = undefined;
65
+ /** @type {unknown} */
66
+ this._v5 = undefined;
67
+ // expression-valued fields stay plain data properties: a type that
68
+ // references the class inside one of its own accessors makes tsc fork
69
+ // the class into two unrelated identities
58
70
  /** @type {BasicEvaluatedExpression[] | undefined} */
59
71
  this.quasis = undefined;
60
72
  /** @type {BasicEvaluatedExpression[] | undefined} */
61
73
  this.parts = undefined;
62
- /** @type {EXPECTED_ANY[] | undefined} */
63
- this.array = undefined;
64
74
  /** @type {BasicEvaluatedExpression[] | undefined} */
65
75
  this.items = undefined;
66
76
  /** @type {BasicEvaluatedExpression[] | undefined} */
@@ -71,18 +81,304 @@ class BasicEvaluatedExpression {
71
81
  this.postfix = undefined;
72
82
  /** @type {BasicEvaluatedExpression[] | undefined} */
73
83
  this.wrappedInnerExpressions = undefined;
74
- /** @type {string | VariableInfo | undefined} */
75
- this.identifier = undefined;
76
- /** @type {string | VariableInfo | undefined} */
77
- this.rootInfo = undefined;
78
- /** @type {GetMembers | undefined} */
79
- this.getMembers = undefined;
80
- /** @type {GetMembersOptionals | undefined} */
81
- this.getMembersOptionals = undefined;
82
- /** @type {GetMemberRanges | undefined} */
83
- this.getMemberRanges = undefined;
84
- /** @type {Node | undefined} */
85
- this.expression = undefined;
84
+ }
85
+
86
+ /**
87
+ * Served lazily from the attached expression when not set explicitly:
88
+ * `evaluateExpression`'s plain results share the expression's range, and
89
+ * most evaluations never read it, so the node's range array is only
90
+ * materialized on demand.
91
+ * @returns {Range | undefined} range of the evaluated expression
92
+ */
93
+ get range() {
94
+ const range = this._range;
95
+ if (range !== undefined) return range;
96
+ const expression = this.expression;
97
+ return expression === undefined
98
+ ? undefined
99
+ : /** @type {Range} */ (
100
+ /** @type {{ range?: Range }} */ (expression).range
101
+ );
102
+ }
103
+
104
+ /**
105
+ * @param {Range | undefined} value range of the evaluated expression
106
+ */
107
+ set range(value) {
108
+ this._range = value;
109
+ }
110
+
111
+ /**
112
+ * @returns {number} expression type
113
+ */
114
+ get type() {
115
+ return this._flags & FLAG_TYPE_MASK;
116
+ }
117
+
118
+ /**
119
+ * @param {number} value expression type
120
+ */
121
+ set type(value) {
122
+ this._flags = (this._flags & ~FLAG_TYPE_MASK) | value;
123
+ }
124
+
125
+ /**
126
+ * @returns {boolean} true when the expression is known truthy
127
+ */
128
+ get truthy() {
129
+ return (this._flags & FLAG_TRUTHY) !== 0;
130
+ }
131
+
132
+ /**
133
+ * @param {boolean} value known truthy
134
+ */
135
+ set truthy(value) {
136
+ this._flags = value
137
+ ? this._flags | FLAG_TRUTHY
138
+ : this._flags & ~FLAG_TRUTHY;
139
+ }
140
+
141
+ /**
142
+ * @returns {boolean} true when the expression is known falsy
143
+ */
144
+ get falsy() {
145
+ return (this._flags & FLAG_FALSY) !== 0;
146
+ }
147
+
148
+ /**
149
+ * @param {boolean} value known falsy
150
+ */
151
+ set falsy(value) {
152
+ this._flags = value ? this._flags | FLAG_FALSY : this._flags & ~FLAG_FALSY;
153
+ }
154
+
155
+ /**
156
+ * @returns {boolean | undefined} whether the value is nullish, when known
157
+ */
158
+ get nullish() {
159
+ return (this._flags & FLAG_NULLISH_KNOWN) === 0
160
+ ? undefined
161
+ : (this._flags & FLAG_NULLISH) !== 0;
162
+ }
163
+
164
+ /**
165
+ * @param {boolean | undefined} value whether the value is nullish
166
+ */
167
+ set nullish(value) {
168
+ this._flags =
169
+ value === undefined
170
+ ? this._flags & ~(FLAG_NULLISH_KNOWN | FLAG_NULLISH)
171
+ : value
172
+ ? this._flags | FLAG_NULLISH_KNOWN | FLAG_NULLISH
173
+ : (this._flags | FLAG_NULLISH_KNOWN) & ~FLAG_NULLISH;
174
+ }
175
+
176
+ /**
177
+ * @returns {boolean} true when the expression could have side effects
178
+ */
179
+ get sideEffects() {
180
+ return (this._flags & FLAG_SIDE_EFFECTS) !== 0;
181
+ }
182
+
183
+ /**
184
+ * @param {boolean} value could have side effects
185
+ */
186
+ set sideEffects(value) {
187
+ this._flags = value
188
+ ? this._flags | FLAG_SIDE_EFFECTS
189
+ : this._flags & ~FLAG_SIDE_EFFECTS;
190
+ }
191
+
192
+ /**
193
+ * @returns {boolean | undefined} boolean value when boolean-typed
194
+ */
195
+ get bool() {
196
+ return this.type === TypeBoolean
197
+ ? /** @type {boolean} */ (this._v1)
198
+ : undefined;
199
+ }
200
+
201
+ /**
202
+ * @param {boolean | undefined} value boolean value
203
+ */
204
+ set bool(value) {
205
+ this._v1 = value;
206
+ }
207
+
208
+ /**
209
+ * @returns {number | undefined} number value when number-typed
210
+ */
211
+ get number() {
212
+ return this.type === TypeNumber
213
+ ? /** @type {number} */ (this._v1)
214
+ : undefined;
215
+ }
216
+
217
+ /**
218
+ * @param {number | undefined} value number value
219
+ */
220
+ set number(value) {
221
+ this._v1 = value;
222
+ }
223
+
224
+ /**
225
+ * @returns {bigint | undefined} bigint value when bigint-typed
226
+ */
227
+ get bigint() {
228
+ return this.type === TypeBigInt
229
+ ? /** @type {bigint} */ (this._v1)
230
+ : undefined;
231
+ }
232
+
233
+ /**
234
+ * @param {bigint | undefined} value bigint value
235
+ */
236
+ set bigint(value) {
237
+ this._v1 = value;
238
+ }
239
+
240
+ /**
241
+ * @returns {RegExp | undefined} regexp value when regexp-typed
242
+ */
243
+ get regExp() {
244
+ return this.type === TypeRegExp
245
+ ? /** @type {RegExp} */ (this._v1)
246
+ : undefined;
247
+ }
248
+
249
+ /**
250
+ * @param {RegExp | undefined} value regexp value
251
+ */
252
+ set regExp(value) {
253
+ this._v1 = value;
254
+ }
255
+
256
+ /**
257
+ * @returns {string | undefined} string value when string-typed
258
+ */
259
+ get string() {
260
+ return this.type === TypeString
261
+ ? /** @type {string} */ (this._v1)
262
+ : undefined;
263
+ }
264
+
265
+ /**
266
+ * @param {string | undefined} value string value
267
+ */
268
+ set string(value) {
269
+ this._v1 = value;
270
+ }
271
+
272
+ /**
273
+ * @returns {"cooked" | "raw" | undefined} template string kind
274
+ */
275
+ get templateStringKind() {
276
+ return this.type === TypeTemplateString
277
+ ? /** @type {"cooked" | "raw"} */ (this._v3)
278
+ : undefined;
279
+ }
280
+
281
+ /**
282
+ * @param {"cooked" | "raw" | undefined} value template string kind
283
+ */
284
+ set templateStringKind(value) {
285
+ this._v3 = value;
286
+ }
287
+
288
+ /**
289
+ * @returns {EXPECTED_ANY[] | undefined} const array values
290
+ */
291
+ get array() {
292
+ return this.type === TypeConstArray
293
+ ? /** @type {unknown[]} */ (this._v1)
294
+ : undefined;
295
+ }
296
+
297
+ /**
298
+ * @param {EXPECTED_ANY[] | undefined} value const array values
299
+ */
300
+ set array(value) {
301
+ this._v1 = value;
302
+ }
303
+
304
+ /**
305
+ * @returns {string | VariableInfo | undefined} identifier
306
+ */
307
+ get identifier() {
308
+ return this.type === TypeIdentifier
309
+ ? /** @type {string | VariableInfo} */ (this._v1)
310
+ : undefined;
311
+ }
312
+
313
+ /**
314
+ * @param {string | VariableInfo | undefined} value identifier
315
+ */
316
+ set identifier(value) {
317
+ this._v1 = value;
318
+ }
319
+
320
+ /**
321
+ * @returns {string | VariableInfo | undefined} root info
322
+ */
323
+ get rootInfo() {
324
+ return this.type === TypeIdentifier
325
+ ? /** @type {string | VariableInfo} */ (this._v2)
326
+ : undefined;
327
+ }
328
+
329
+ /**
330
+ * @param {string | VariableInfo | undefined} value root info
331
+ */
332
+ set rootInfo(value) {
333
+ this._v2 = value;
334
+ }
335
+
336
+ /**
337
+ * @returns {GetMembers | undefined} members getter
338
+ */
339
+ get getMembers() {
340
+ return this.type === TypeIdentifier
341
+ ? /** @type {GetMembers} */ (this._v3)
342
+ : undefined;
343
+ }
344
+
345
+ /**
346
+ * @param {GetMembers | undefined} value members getter
347
+ */
348
+ set getMembers(value) {
349
+ this._v3 = value;
350
+ }
351
+
352
+ /**
353
+ * @returns {GetMembersOptionals | undefined} members optionals getter
354
+ */
355
+ get getMembersOptionals() {
356
+ return this.type === TypeIdentifier
357
+ ? /** @type {GetMembersOptionals} */ (this._v4)
358
+ : undefined;
359
+ }
360
+
361
+ /**
362
+ * @param {GetMembersOptionals | undefined} value members optionals getter
363
+ */
364
+ set getMembersOptionals(value) {
365
+ this._v4 = value;
366
+ }
367
+
368
+ /**
369
+ * @returns {GetMemberRanges | undefined} member ranges getter
370
+ */
371
+ get getMemberRanges() {
372
+ return this.type === TypeIdentifier
373
+ ? /** @type {GetMemberRanges} */ (this._v5)
374
+ : undefined;
375
+ }
376
+
377
+ /**
378
+ * @param {GetMemberRanges | undefined} value member ranges getter
379
+ */
380
+ set getMemberRanges(value) {
381
+ this._v5 = value;
86
382
  }
87
383
 
88
384
  isUnknown() {
@@ -538,7 +834,7 @@ class BasicEvaluatedExpression {
538
834
  * @returns {this} this
539
835
  */
540
836
  setRange(range) {
541
- this.range = range;
837
+ this._range = range;
542
838
  return this;
543
839
  }
544
840
 
@@ -572,34 +868,56 @@ BasicEvaluatedExpression.isValidRegExpFlags = (flags) => {
572
868
  const len = flags.length;
573
869
 
574
870
  if (len === 0) return true;
575
- if (len > 4) return false;
576
-
577
- // cspell:word gimy
578
- let remaining = 0b0000; // bit per RegExp flag: gimy
871
+ // 8 standard flags: d g i m s u v y
872
+ if (len > 8) return false;
873
+
874
+ const D = 1; // d hasIndices
875
+ const G = 2; // g global
876
+ const I = 4; // i ignoreCase
877
+ const M = 8; // m multiline
878
+ const S = 16; // s dotAll
879
+ const U = 32; // u unicode
880
+ const V = 64; // v unicodeSets
881
+ const Y = 128; // y sticky
882
+ let seen = 0;
579
883
 
580
884
  for (let i = 0; i < len; i++) {
885
+ let bit;
581
886
  switch (flags.charCodeAt(i)) {
887
+ case 100 /* d */:
888
+ bit = D;
889
+ break;
582
890
  case 103 /* g */:
583
- if (remaining & 0b1000) return false;
584
- remaining |= 0b1000;
891
+ bit = G;
585
892
  break;
586
893
  case 105 /* i */:
587
- if (remaining & 0b0100) return false;
588
- remaining |= 0b0100;
894
+ bit = I;
589
895
  break;
590
896
  case 109 /* m */:
591
- if (remaining & 0b0010) return false;
592
- remaining |= 0b0010;
897
+ bit = M;
898
+ break;
899
+ case 115 /* s */:
900
+ bit = S;
901
+ break;
902
+ case 117 /* u */:
903
+ bit = U;
904
+ break;
905
+ case 118 /* v */:
906
+ bit = V;
593
907
  break;
594
908
  case 121 /* y */:
595
- if (remaining & 0b0001) return false;
596
- remaining |= 0b0001;
909
+ bit = Y;
597
910
  break;
598
911
  default:
599
912
  return false;
600
913
  }
914
+ if (seen & bit) return false; // duplicate flag
915
+ seen |= bit;
601
916
  }
602
917
 
918
+ // `u` and `v` are mutually exclusive
919
+ if (seen & U && seen & V) return false;
920
+
603
921
  return true;
604
922
  };
605
923