@bleedingdev/modern-js-code-tools 3.9.0-ultramodern.9 → 3.9.3-ultramodern.10

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 (38) hide show
  1. package/bin/modern-api-check-files.mjs +4 -1
  2. package/bin/modern-api-check.mjs +1 -1
  3. package/bin/modern-i18n-check.mjs +4 -0
  4. package/dist/cjs/cli/microvertical-api-check.cjs +36 -7
  5. package/dist/cjs/cli/workspace-source-check.cjs +90 -17
  6. package/dist/cjs/microvertical-api-baseline.cjs +89 -246
  7. package/dist/cjs/microvertical-api-boundary.cjs +507 -64
  8. package/dist/cjs/microvertical-api-owner.cjs +5 -2
  9. package/dist/cjs/module-graph.cjs +1862 -0
  10. package/dist/cjs/oxlint-plugin/rules/strict-effect-api-boundaries.cjs +1 -1
  11. package/dist/cjs/source-analysis.cjs +108 -0
  12. package/dist/cjs/strict-effect-runtime.cjs +75 -57
  13. package/dist/esm/cli/microvertical-api-check.js +26 -7
  14. package/dist/esm/cli/workspace-source-check.js +86 -13
  15. package/dist/esm/microvertical-api-baseline.js +66 -214
  16. package/dist/esm/microvertical-api-boundary.js +505 -65
  17. package/dist/esm/microvertical-api-owner.js +5 -2
  18. package/dist/esm/module-graph.js +1804 -0
  19. package/dist/esm/oxlint-plugin/rules/strict-effect-api-boundaries.js +1 -1
  20. package/dist/esm/source-analysis.js +48 -0
  21. package/dist/esm/strict-effect-runtime.js +75 -56
  22. package/dist/esm-node/cli/microvertical-api-check.js +26 -7
  23. package/dist/esm-node/cli/workspace-source-check.js +86 -13
  24. package/dist/esm-node/microvertical-api-baseline.js +66 -214
  25. package/dist/esm-node/microvertical-api-boundary.js +505 -65
  26. package/dist/esm-node/microvertical-api-owner.js +5 -2
  27. package/dist/esm-node/module-graph.js +1805 -0
  28. package/dist/esm-node/oxlint-plugin/rules/strict-effect-api-boundaries.js +1 -1
  29. package/dist/esm-node/source-analysis.js +49 -0
  30. package/dist/esm-node/strict-effect-runtime.js +75 -56
  31. package/dist/types/cli/microvertical-api-check.d.ts +1 -1
  32. package/dist/types/cli/workspace-source-check.d.ts +1 -1
  33. package/dist/types/microvertical-api-baseline.d.ts +4 -5
  34. package/dist/types/microvertical-api-boundary.d.ts +17 -2
  35. package/dist/types/microvertical-api-owner.d.ts +1 -1
  36. package/dist/types/module-graph.d.ts +100 -0
  37. package/dist/types/source-analysis.d.ts +13 -0
  38. package/package.json +17 -13
@@ -0,0 +1,1805 @@
1
+ import "node:module";
2
+ import node_fs from "node:fs";
3
+ import { createRequire } from "node:module";
4
+ import node_path from "node:path";
5
+ import { exports as external_resolve_exports_exports } from "resolve.exports";
6
+ import { SourceSyntaxError, parseSource, traverseSource, unwrapExpression } from "./source-analysis.js";
7
+ import * as __rspack_external__babel_types_6e8337dd from "@babel/types";
8
+ const MAX_LOOKUPS = 4096;
9
+ const MAX_DEPTH = 192;
10
+ const MAX_ALIASES = 512;
11
+ const staticKey = (node)=>{
12
+ const key = 'property' in node ? node.property : node.key;
13
+ return !node.computed || __rspack_external__babel_types_6e8337dd.isStringLiteral(key) || __rspack_external__babel_types_6e8337dd.isNumericLiteral(key) ? propertyName(key) : void 0;
14
+ };
15
+ const writeTarget = (node)=>{
16
+ let names = [];
17
+ let dynamic = false;
18
+ let depth = 0;
19
+ let current = unwrapExpression(node, true);
20
+ while(__rspack_external__babel_types_6e8337dd.isMemberExpression(current) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(current)){
21
+ const name = staticKey(current);
22
+ depth += 1;
23
+ if (void 0 === name) {
24
+ names = [];
25
+ dynamic = true;
26
+ } else names.unshift(name);
27
+ current = unwrapExpression(current.object, true);
28
+ }
29
+ return __rspack_external__babel_types_6e8337dd.isIdentifier(current) ? {
30
+ root: current,
31
+ path: names,
32
+ dynamic,
33
+ depth
34
+ } : void 0;
35
+ };
36
+ const OPAQUE_RECEIVER = {};
37
+ const opaqueReceiver = (target, scope)=>{
38
+ let current = unwrapExpression(target, true);
39
+ if (!__rspack_external__babel_types_6e8337dd.isMemberExpression(current) && !__rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(current)) return false;
40
+ let depth = 0;
41
+ while(__rspack_external__babel_types_6e8337dd.isMemberExpression(current) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(current)){
42
+ depth += 1;
43
+ current = unwrapExpression(current.object, true);
44
+ }
45
+ if (__rspack_external__babel_types_6e8337dd.isThisExpression(current)) {
46
+ if (depth > 1) return true;
47
+ let owner = scope.getFunctionParent();
48
+ while(owner && __rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(owner.block))owner = owner.parent?.getFunctionParent() ?? null;
49
+ return !(__rspack_external__babel_types_6e8337dd.isClassMethod(owner?.block) && 'constructor' === owner.block.kind);
50
+ }
51
+ return !(__rspack_external__babel_types_6e8337dd.isIdentifier(current) || __rspack_external__babel_types_6e8337dd.isSuper(current));
52
+ };
53
+ const CONTAINER_EXTRACTORS = new Set([
54
+ 'at',
55
+ 'concat',
56
+ 'copyWithin',
57
+ 'entries',
58
+ 'every',
59
+ 'fill',
60
+ 'filter',
61
+ 'find',
62
+ 'findIndex',
63
+ 'findLast',
64
+ 'findLastIndex',
65
+ 'flat',
66
+ 'flatMap',
67
+ 'forEach',
68
+ 'get',
69
+ 'map',
70
+ 'pop',
71
+ 'reduce',
72
+ 'reduceRight',
73
+ 'reverse',
74
+ 'shift',
75
+ 'slice',
76
+ 'some',
77
+ 'sort',
78
+ 'splice',
79
+ 'toReversed',
80
+ 'toSorted',
81
+ 'toSpliced',
82
+ 'values',
83
+ 'with'
84
+ ]);
85
+ const RECEIVER_RETURNING_METHODS = new Set([
86
+ 'copyWithin',
87
+ 'fill',
88
+ 'reverse',
89
+ 'sort',
90
+ 'valueOf'
91
+ ]);
92
+ const isModuleExports = (node)=>__rspack_external__babel_types_6e8337dd.isMemberExpression(node) && __rspack_external__babel_types_6e8337dd.isIdentifier(node.object, {
93
+ name: 'module'
94
+ }) && 'exports' === staticKey(node);
95
+ const readsModuleExports = (node)=>{
96
+ let current = unwrapExpression(node, true);
97
+ for(let hop = 0; hop < MAX_DEPTH; hop += 1){
98
+ if (isModuleExports(current)) return true;
99
+ if (!__rspack_external__babel_types_6e8337dd.isAssignmentExpression(current, {
100
+ operator: '='
101
+ })) break;
102
+ if (isModuleExports(current.left)) return true;
103
+ current = unwrapExpression(current.right, true);
104
+ }
105
+ return false;
106
+ };
107
+ const READ_ONLY_GLOBAL_CALLS = new Set([
108
+ 'Object.assign',
109
+ 'Object.defineProperties',
110
+ 'Object.defineProperty',
111
+ 'Object.setPrototypeOf',
112
+ 'Reflect.defineProperty',
113
+ 'Reflect.deleteProperty',
114
+ 'Reflect.set',
115
+ 'Reflect.setPrototypeOf',
116
+ 'Array.isArray',
117
+ 'Boolean',
118
+ 'JSON.stringify',
119
+ 'Number',
120
+ 'Object.is',
121
+ 'Object.isExtensible',
122
+ 'Object.isFrozen',
123
+ 'Object.isSealed',
124
+ 'Object.keys',
125
+ 'String'
126
+ ]);
127
+ const STORING_GLOBAL_CALLS = new Map([
128
+ [
129
+ 'Object.assign',
130
+ (depth)=>Math.max(depth, 1)
131
+ ],
132
+ [
133
+ 'Object.setPrototypeOf',
134
+ (depth)=>Math.max(depth, 1)
135
+ ],
136
+ [
137
+ 'Reflect.setPrototypeOf',
138
+ (depth)=>Math.max(depth, 1)
139
+ ],
140
+ [
141
+ 'Object.defineProperty',
142
+ (depth)=>Math.max(depth, 1)
143
+ ],
144
+ [
145
+ 'Reflect.defineProperty',
146
+ (depth)=>Math.max(depth, 1)
147
+ ],
148
+ [
149
+ 'Object.defineProperties',
150
+ ()=>1
151
+ ],
152
+ [
153
+ 'Reflect.set',
154
+ (depth)=>depth + 1
155
+ ]
156
+ ]);
157
+ const DYNAMIC_SETTER = Symbol('dynamic setter');
158
+ const setterCache = new WeakMap();
159
+ const setterNames = (program)=>{
160
+ const cached = setterCache.get(program.node);
161
+ if (cached) return cached;
162
+ const names = new Set();
163
+ __rspack_external__babel_types_6e8337dd.traverseFast(program.node, (node)=>{
164
+ if ((__rspack_external__babel_types_6e8337dd.isObjectMethod(node) || __rspack_external__babel_types_6e8337dd.isClassMethod(node)) && 'set' === node.kind) names.add(staticKey(node) ?? DYNAMIC_SETTER);
165
+ });
166
+ setterCache.set(program.node, names);
167
+ return names;
168
+ };
169
+ const patternMembers = (pattern, from = [])=>__rspack_external__babel_types_6e8337dd.isMemberExpression(pattern) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(pattern) ? [
170
+ {
171
+ target: pattern,
172
+ from
173
+ }
174
+ ] : __rspack_external__babel_types_6e8337dd.isObjectPattern(pattern) ? pattern.properties.flatMap((property)=>{
175
+ if (__rspack_external__babel_types_6e8337dd.isRestElement(property)) return patternMembers(property.argument, void 0);
176
+ const key = staticKey(property);
177
+ return patternMembers(property.value, from && void 0 !== key ? [
178
+ ...from,
179
+ key
180
+ ] : void 0);
181
+ }) : __rspack_external__babel_types_6e8337dd.isArrayPattern(pattern) ? pattern.elements.flatMap((element, index)=>element ? patternMembers(element, from && !__rspack_external__babel_types_6e8337dd.isRestElement(element) ? [
182
+ ...from,
183
+ String(index)
184
+ ] : void 0) : []) : __rspack_external__babel_types_6e8337dd.isRestElement(pattern) ? patternMembers(pattern.argument, void 0) : __rspack_external__babel_types_6e8337dd.isAssignmentPattern(pattern) ? patternMembers(pattern.left, void 0) : [];
185
+ function parseModule(filePath, workspace) {
186
+ if (node_fs.statSync(filePath).size > 1000000) throw new Error(`${filePath}: consumer source exceeds 1 MB analysis budget`);
187
+ const file = parseSource(node_fs.readFileSync(filePath, 'utf8'), filePath);
188
+ let scope;
189
+ const references = new Map();
190
+ const declarations = new Map();
191
+ const returns = new Map();
192
+ const bareReturns = new Set();
193
+ const functionScopes = new Map();
194
+ const writes = new Map();
195
+ const merged = new Set();
196
+ const mutations = [];
197
+ const commonJs = [];
198
+ let exportsDetachedAt;
199
+ const assertAssignable = (binding, at)=>{
200
+ if (binding?.kind === 'const' || binding?.kind === 'module') throw new SourceSyntaxError(`${'module' === binding.kind ? 'imports' : 'const bindings'} must not be reassigned at ${at.start}`);
201
+ };
202
+ const recordWrite = (scopeOf, target, node, value, from)=>{
203
+ const member = writeTarget(target);
204
+ if (!member) {
205
+ if (opaqueReceiver(target, scopeOf)) writes.set(OPAQUE_RECEIVER, [
206
+ ...writes.get(OPAQUE_RECEIVER) ?? [],
207
+ {
208
+ path: [],
209
+ dynamic: true,
210
+ depth: 0,
211
+ value,
212
+ from,
213
+ node
214
+ }
215
+ ]);
216
+ return;
217
+ }
218
+ let root = member;
219
+ let through = [];
220
+ for(let hop = 0; hop < MAX_DEPTH; hop += 1){
221
+ const alias = scopeOf.getBinding(root.root.name);
222
+ const init = alias?.kind === 'const' && __rspack_external__babel_types_6e8337dd.isVariableDeclarator(alias.path.node) ? alias.path.node.init : void 0;
223
+ const next = init ? writeTarget(init) : void 0;
224
+ if (!next || next.dynamic) break;
225
+ through = [
226
+ ...root.path,
227
+ ...through
228
+ ];
229
+ root = next;
230
+ }
231
+ const exported = 'module' === root.root.name && 'exports' === root.path[0] ? [
232
+ ...root.path.slice(1),
233
+ ...through
234
+ ] : 'exports' === root.root.name ? [
235
+ ...root.path,
236
+ ...through
237
+ ] : void 0;
238
+ const detached = 'exports' === root.root.name && (root.path.length + through.length === 0 || void 0 !== exportsDetachedAt && (node.start ?? 0) >= exportsDetachedAt);
239
+ if (exported && !detached && !scopeOf.getBinding(root.root.name)) commonJs.push({
240
+ path: exported,
241
+ dynamic: member.dynamic,
242
+ depth: member.depth,
243
+ value,
244
+ from,
245
+ node
246
+ });
247
+ const binding = member.dynamic || member.path.length > 0 ? scopeOf.getBinding(member.root.name) : void 0;
248
+ if (!binding) return;
249
+ writes.set(binding, [
250
+ ...writes.get(binding) ?? [],
251
+ {
252
+ path: member.path,
253
+ dynamic: member.dynamic,
254
+ depth: member.depth,
255
+ value,
256
+ from,
257
+ node
258
+ }
259
+ ]);
260
+ };
261
+ const indexBuiltInMutation = (p)=>{
262
+ const callee = unwrapExpression(p.node.callee, true);
263
+ const memberCallee = __rspack_external__babel_types_6e8337dd.isMemberExpression(callee) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(callee) ? callee : void 0;
264
+ const owner = memberCallee && __rspack_external__babel_types_6e8337dd.isIdentifier(memberCallee.object) ? memberCallee.object.name : void 0;
265
+ const method = memberCallee ? staticKey(memberCallee) : void 0;
266
+ const [target, ...rest] = p.node.arguments;
267
+ if (!owner || !method || !target || !__rspack_external__babel_types_6e8337dd.isExpression(target) || p.scope.getBinding(owner) || !('Object' === owner && [
268
+ 'assign',
269
+ 'defineProperty',
270
+ 'defineProperties',
271
+ 'setPrototypeOf'
272
+ ].includes(method) || 'Reflect' === owner && [
273
+ 'set',
274
+ 'defineProperty',
275
+ 'deleteProperty',
276
+ 'setPrototypeOf'
277
+ ].includes(method))) return;
278
+ mutations.push(p.node);
279
+ const anyMember = __rspack_external__babel_types_6e8337dd.memberExpression(target, __rspack_external__babel_types_6e8337dd.identifier('key'), true);
280
+ const sources = 'assign' === method ? rest : [
281
+ void 0
282
+ ];
283
+ for (const source of sources){
284
+ if (!__rspack_external__babel_types_6e8337dd.isObjectExpression(source)) {
285
+ recordWrite(p.scope, anyMember, p.node);
286
+ continue;
287
+ }
288
+ for (const property of source.properties){
289
+ const key = __rspack_external__babel_types_6e8337dd.isObjectProperty(property) ? staticKey(property) : void 0;
290
+ void 0 !== key && __rspack_external__babel_types_6e8337dd.isObjectProperty(property) ? recordWrite(p.scope, __rspack_external__babel_types_6e8337dd.memberExpression(target, __rspack_external__babel_types_6e8337dd.stringLiteral(key), true), p.node, property.value) : recordWrite(p.scope, anyMember, p.node);
291
+ }
292
+ }
293
+ };
294
+ traverseSource(file, {
295
+ Program (p) {
296
+ scope = p.scope;
297
+ },
298
+ ReferencedIdentifier (p) {
299
+ references.set(p.node, p.scope.getBinding(p.node.name));
300
+ },
301
+ BindingIdentifier (p) {
302
+ if (!__rspack_external__babel_types_6e8337dd.isIdentifier(p.node)) return;
303
+ const binding = p.scope.getBinding(p.node.name);
304
+ if (binding?.identifier === p.node) declarations.set(p.node, binding);
305
+ },
306
+ Function (p) {
307
+ functionScopes.set(p.node, p.scope);
308
+ },
309
+ ReturnStatement (p) {
310
+ const owner = p.getFunctionParent();
311
+ if (!owner) return;
312
+ if (p.node.argument) returns.set(owner.node, [
313
+ ...returns.get(owner.node) ?? [],
314
+ p.node.argument
315
+ ]);
316
+ else bareReturns.add(owner.node);
317
+ },
318
+ AssignmentExpression (p) {
319
+ mutations.push(p.node);
320
+ const stored = [
321
+ '=',
322
+ '&&=',
323
+ '||=',
324
+ '??='
325
+ ].includes(p.node.operator) ? p.node.right : void 0;
326
+ for (const name of Object.keys(__rspack_external__babel_types_6e8337dd.getBindingIdentifiers(p.node.left)))assertAssignable(p.scope.getBinding(name), p.node);
327
+ if (__rspack_external__babel_types_6e8337dd.isPattern(p.node.left)) for (const { target, from } of patternMembers(p.node.left))recordWrite(p.scope, target, p.node, from && '=' === p.node.operator ? p.node.right : void 0, from);
328
+ else recordWrite(p.scope, p.node.left, p.node, stored);
329
+ if ('=' === p.node.operator && __rspack_external__babel_types_6e8337dd.isIdentifier(p.node.left, {
330
+ name: 'exports'
331
+ }) && !p.scope.getBinding('exports') && p.parentPath.isExpressionStatement() && p.parentPath.parentPath?.isProgram()) exportsDetachedAt = readsModuleExports(p.node.right) ? void 0 : exportsDetachedAt ?? p.node.end ?? void 0;
332
+ else if (void 0 === exportsDetachedAt && '=' === p.node.operator && __rspack_external__babel_types_6e8337dd.isMemberExpression(p.node.left) && __rspack_external__babel_types_6e8337dd.isIdentifier(p.node.left.object, {
333
+ name: 'module'
334
+ }) && 'exports' === staticKey(p.node.left) && !p.scope.getBinding('module') && !(__rspack_external__babel_types_6e8337dd.isAssignmentExpression(p.node.right) && __rspack_external__babel_types_6e8337dd.isIdentifier(p.node.right.left, {
335
+ name: 'exports'
336
+ })) && p.parentPath.isExpressionStatement() && p.parentPath.parentPath?.isProgram()) exportsDetachedAt = p.node.end ?? void 0;
337
+ },
338
+ ForXStatement (p) {
339
+ const left = p.node.left;
340
+ if (__rspack_external__babel_types_6e8337dd.isVariableDeclaration(left)) return;
341
+ mutations.push(p.node);
342
+ for (const { target } of patternMembers(left))recordWrite(p.scope, target, p.node);
343
+ },
344
+ CallExpression (p) {
345
+ indexBuiltInMutation(p);
346
+ },
347
+ OptionalCallExpression (p) {
348
+ indexBuiltInMutation(p);
349
+ },
350
+ UnaryExpression (p) {
351
+ if ('delete' !== p.node.operator) return;
352
+ mutations.push(p.node);
353
+ recordWrite(p.scope, p.node.argument, p.node);
354
+ },
355
+ UpdateExpression (p) {
356
+ mutations.push(p.node);
357
+ if (__rspack_external__babel_types_6e8337dd.isIdentifier(p.node.argument)) assertAssignable(p.scope.getBinding(p.node.argument.name), p.node);
358
+ recordWrite(p.scope, p.node.argument, p.node);
359
+ },
360
+ TSModuleDeclaration (p) {
361
+ if (!__rspack_external__babel_types_6e8337dd.isIdentifier(p.node.id)) return;
362
+ merged.add(p.node.id.name);
363
+ mutations.push(p.node);
364
+ }
365
+ });
366
+ if (!scope) throw new Error(`${filePath}: program scope missing`);
367
+ const facts = {
368
+ scope,
369
+ workspace,
370
+ references,
371
+ declarations,
372
+ returns,
373
+ bareReturns,
374
+ functionScopes,
375
+ writes,
376
+ merged,
377
+ commonJs
378
+ };
379
+ return {
380
+ file,
381
+ facts,
382
+ mutations
383
+ };
384
+ }
385
+ const propertyName = (node)=>{
386
+ if (void 0 !== node && (__rspack_external__babel_types_6e8337dd.isIdentifier(node) || __rspack_external__babel_types_6e8337dd.isStringLiteral(node) || __rspack_external__babel_types_6e8337dd.isNumericLiteral(node))) return __rspack_external__babel_types_6e8337dd.isIdentifier(node) ? node.name : String(node.value);
387
+ };
388
+ const localConst = (sourceFile, name)=>{
389
+ for (const item of sourceFile.program.body){
390
+ const statement = __rspack_external__babel_types_6e8337dd.isExportNamedDeclaration(item) ? item.declaration : item;
391
+ if (!__rspack_external__babel_types_6e8337dd.isVariableDeclaration(statement) || 'const' !== statement.kind) continue;
392
+ const matches = statement.declarations.filter((declaration)=>__rspack_external__babel_types_6e8337dd.isIdentifier(declaration.id, {
393
+ name
394
+ }));
395
+ if (1 === matches.length) return matches[0];
396
+ }
397
+ };
398
+ const exportedConst = (sourceFile, name)=>{
399
+ for (const statement of sourceFile.program.body)if (__rspack_external__babel_types_6e8337dd.isExportNamedDeclaration(statement) && 'type' !== statement.exportKind) {
400
+ if (__rspack_external__babel_types_6e8337dd.isVariableDeclaration(statement.declaration) && 'const' === statement.declaration.kind) {
401
+ const declaration = statement.declaration.declarations.find((value)=>__rspack_external__babel_types_6e8337dd.isIdentifier(value.id, {
402
+ name
403
+ }));
404
+ if (declaration) return declaration;
405
+ }
406
+ if (!statement.source && statement.specifiers.some((value)=>__rspack_external__babel_types_6e8337dd.isExportSpecifier(value) && 'type' !== value.exportKind && __rspack_external__babel_types_6e8337dd.isIdentifier(value.local, {
407
+ name
408
+ }) && __rspack_external__babel_types_6e8337dd.isIdentifier(value.exported, {
409
+ name
410
+ }))) return localConst(sourceFile, name);
411
+ }
412
+ };
413
+ const inside = (file, boundary)=>file === boundary || file.startsWith(`${boundary}${node_path.sep}`);
414
+ const containingWorkspace = (file)=>{
415
+ for(let directory = node_path.dirname(file);; directory = node_path.dirname(directory)){
416
+ if (node_fs.existsSync(node_path.join(directory, 'pnpm-workspace.yaml'))) return node_fs.realpathSync(directory);
417
+ if (directory === node_path.dirname(directory)) return;
418
+ }
419
+ };
420
+ const sourceBoundary = (file, workspace)=>{
421
+ for(let directory = node_path.dirname(file);; directory = node_path.dirname(directory)){
422
+ if (node_fs.existsSync(node_path.join(directory, 'package.json')) && directory !== workspace) return node_fs.realpathSync(directory);
423
+ if (directory === workspace || directory === node_path.dirname(directory)) return node_fs.realpathSync(node_path.dirname(file));
424
+ }
425
+ };
426
+ const sourceFileAt = (target, boundary)=>{
427
+ const stem = target.replace(/\.(?:[cm]?[jt]sx?)$/u, '');
428
+ for (const candidate of [
429
+ `${stem}.ts`,
430
+ `${stem}.tsx`,
431
+ `${stem}.mts`,
432
+ `${stem}.cts`,
433
+ target,
434
+ `${stem}.js`,
435
+ `${stem}.jsx`,
436
+ `${stem}.mjs`,
437
+ `${stem}.cjs`,
438
+ node_path.join(target, 'index.ts'),
439
+ node_path.join(target, 'index.tsx'),
440
+ node_path.join(target, 'index.mts'),
441
+ node_path.join(target, 'index.cts'),
442
+ node_path.join(target, 'index.js'),
443
+ node_path.join(target, 'index.jsx'),
444
+ node_path.join(target, 'index.mjs'),
445
+ node_path.join(target, 'index.cjs')
446
+ ])try {
447
+ const real = node_fs.realpathSync(candidate);
448
+ if (inside(real, boundary) && node_fs.statSync(real).isFile()) return real;
449
+ } catch {}
450
+ };
451
+ const packageEntry = (specifier)=>{
452
+ if (specifier.startsWith('.') || specifier.startsWith('/') || specifier.startsWith('#')) return;
453
+ const parts = specifier.split('/');
454
+ const count = specifier.startsWith('@') ? 2 : 1;
455
+ if (parts.length < count || parts.slice(0, count).some((part)=>!part)) return;
456
+ return {
457
+ name: parts.slice(0, count).join('/'),
458
+ exportKey: parts.length === count ? '.' : `./${parts.slice(count).join('/')}`
459
+ };
460
+ };
461
+ const resolveModulePath = (module, specifier, workspace)=>{
462
+ if (/^\.\.?\//u.test(specifier)) {
463
+ const file = sourceFileAt(node_path.resolve(node_path.dirname(module.path), specifier), module.boundary);
464
+ return void 0 === file ? void 0 : {
465
+ kind: 'module',
466
+ path: file,
467
+ boundary: module.boundary
468
+ };
469
+ }
470
+ const entry = packageEntry(specifier);
471
+ if (!entry) return;
472
+ if (!workspace) return {
473
+ kind: 'external'
474
+ };
475
+ const paths = createRequire(module.path).resolve.paths(entry.name) ?? [];
476
+ for (const lookup of paths){
477
+ const directory = node_path.join(lookup, entry.name);
478
+ const manifest = node_path.join(directory, 'package.json');
479
+ if (!node_fs.existsSync(manifest)) continue;
480
+ const boundary = node_fs.realpathSync(directory);
481
+ if (!inside(boundary, workspace) || boundary.split(node_path.sep).includes('node_modules')) break;
482
+ const pkg = JSON.parse(node_fs.readFileSync(manifest, 'utf8'));
483
+ if (pkg.name !== entry.name || void 0 === pkg.exports) return;
484
+ let target;
485
+ try {
486
+ const targets = external_resolve_exports_exports({
487
+ ...pkg,
488
+ exports: selectExportPattern(pkg.exports, entry.exportKey)
489
+ }, entry.exportKey, {
490
+ conditions: [
491
+ 'modern:source'
492
+ ]
493
+ });
494
+ target = Array.isArray(targets) ? targets[0] : void 0;
495
+ } catch {
496
+ return;
497
+ }
498
+ if (!target || !target.startsWith('./')) return;
499
+ const file = sourceFileAt(node_path.resolve(boundary, target), boundary);
500
+ return void 0 === file ? void 0 : {
501
+ kind: 'module',
502
+ path: file,
503
+ boundary
504
+ };
505
+ }
506
+ return {
507
+ kind: 'external'
508
+ };
509
+ };
510
+ const patternKeyCompare = (a, b)=>{
511
+ const aBase = a.indexOf('*') + 1;
512
+ const bBase = b.indexOf('*') + 1;
513
+ if (aBase !== bBase) return bBase - aBase;
514
+ return b.length - a.length;
515
+ };
516
+ const selectExportPattern = (exports, key)=>{
517
+ if ('object' != typeof exports || null === exports || Array.isArray(exports)) return exports;
518
+ const subpaths = exports;
519
+ const keys = Object.keys(subpaths);
520
+ if (!keys.every((candidate)=>candidate.startsWith('.')) || key in subpaths) return exports;
521
+ let best;
522
+ for (const candidate of keys){
523
+ const star = candidate.indexOf('*');
524
+ if (-1 === star || -1 !== candidate.indexOf('*', star + 1)) continue;
525
+ const prefix = candidate.slice(0, star);
526
+ const suffix = candidate.slice(star + 1);
527
+ if (key.startsWith(prefix) && key !== prefix && key.endsWith(suffix) && key.length >= candidate.length && (void 0 === best || patternKeyCompare(candidate, best) < 0)) best = candidate;
528
+ }
529
+ return void 0 === best ? exports : {
530
+ [best]: subpaths[best]
531
+ };
532
+ };
533
+ const exportHop = (file, name)=>{
534
+ for (const statement of file.program.body){
535
+ if (__rspack_external__babel_types_6e8337dd.isExportDefaultDeclaration(statement)) {
536
+ if ('default' !== name) continue;
537
+ const declaration = statement.declaration;
538
+ if (__rspack_external__babel_types_6e8337dd.isIdentifier(declaration)) return {
539
+ kind: 'local',
540
+ name: declaration.name
541
+ };
542
+ if ((__rspack_external__babel_types_6e8337dd.isFunctionDeclaration(declaration) || __rspack_external__babel_types_6e8337dd.isClassDeclaration(declaration)) && declaration.id) return {
543
+ kind: 'local',
544
+ name: declaration.id.name
545
+ };
546
+ return {
547
+ kind: 'node',
548
+ node: declaration
549
+ };
550
+ }
551
+ if (!__rspack_external__babel_types_6e8337dd.isExportNamedDeclaration(statement) || 'type' === statement.exportKind) continue;
552
+ const declaration = statement.declaration;
553
+ if ((__rspack_external__babel_types_6e8337dd.isVariableDeclaration(declaration) || __rspack_external__babel_types_6e8337dd.isFunctionDeclaration(declaration) || __rspack_external__babel_types_6e8337dd.isClassDeclaration(declaration)) && !declaration.declare && name in __rspack_external__babel_types_6e8337dd.getBindingIdentifiers(declaration)) return {
554
+ kind: 'local',
555
+ name
556
+ };
557
+ for (const specifier of statement.specifiers){
558
+ if (propertyName(specifier.exported) !== name) continue;
559
+ if (__rspack_external__babel_types_6e8337dd.isExportNamespaceSpecifier(specifier) && statement.source) return {
560
+ kind: 'namespace',
561
+ specifier: statement.source.value
562
+ };
563
+ if (!__rspack_external__babel_types_6e8337dd.isExportSpecifier(specifier) || 'type' === specifier.exportKind) continue;
564
+ const local = propertyName(specifier.local) ?? name;
565
+ return statement.source ? {
566
+ kind: 'reexport',
567
+ specifier: statement.source.value,
568
+ name: local
569
+ } : {
570
+ kind: 'local',
571
+ name: local
572
+ };
573
+ }
574
+ }
575
+ };
576
+ const exportNames = (file)=>file.program.body.flatMap((statement)=>{
577
+ if (__rspack_external__babel_types_6e8337dd.isExportDefaultDeclaration(statement)) return [
578
+ 'default'
579
+ ];
580
+ if (!__rspack_external__babel_types_6e8337dd.isExportNamedDeclaration(statement) || 'type' === statement.exportKind) return [];
581
+ const declared = !statement.declaration || __rspack_external__babel_types_6e8337dd.isTSTypeAliasDeclaration(statement.declaration) || __rspack_external__babel_types_6e8337dd.isTSInterfaceDeclaration(statement.declaration) ? [] : Object.keys(__rspack_external__babel_types_6e8337dd.getBindingIdentifiers(statement.declaration));
582
+ return [
583
+ ...declared,
584
+ ...statement.specifiers.flatMap((specifier)=>__rspack_external__babel_types_6e8337dd.isExportSpecifier(specifier) && 'type' === specifier.exportKind ? [] : [
585
+ propertyName(specifier.exported) ?? ''
586
+ ])
587
+ ].filter(Boolean);
588
+ });
589
+ const starSources = (file, name)=>'default' === name ? [] : file.program.body.flatMap((statement)=>__rspack_external__babel_types_6e8337dd.isExportAllDeclaration(statement) && 'type' !== statement.exportKind ? [
590
+ statement.source.value
591
+ ] : []);
592
+ const importOf = (binding)=>{
593
+ const specifier = binding.path.node;
594
+ const declaration = binding.path.parent;
595
+ if (!__rspack_external__babel_types_6e8337dd.isImportDeclaration(declaration) || 'type' === declaration.importKind || 'typeof' === declaration.importKind || __rspack_external__babel_types_6e8337dd.isImportSpecifier(specifier) && 'type' === specifier.importKind) return;
596
+ const name = __rspack_external__babel_types_6e8337dd.isImportSpecifier(specifier) ? propertyName(specifier.imported) : __rspack_external__babel_types_6e8337dd.isImportDefaultSpecifier(specifier) ? 'default' : __rspack_external__babel_types_6e8337dd.isImportNamespaceSpecifier(specifier) ? '*' : void 0;
597
+ return void 0 === name ? void 0 : {
598
+ specifier: declaration.source.value,
599
+ name
600
+ };
601
+ };
602
+ const patternPath = (pattern, target)=>{
603
+ if (pattern === target) return {
604
+ members: [],
605
+ defaults: []
606
+ };
607
+ if (__rspack_external__babel_types_6e8337dd.isAssignmentPattern(pattern)) {
608
+ const inner = patternPath(pattern.left, target);
609
+ return void 0 === inner || 'dynamic' === inner ? inner : {
610
+ members: inner.members,
611
+ defaults: [
612
+ {
613
+ members: [],
614
+ value: pattern.right
615
+ },
616
+ ...inner.defaults
617
+ ]
618
+ };
619
+ }
620
+ if (__rspack_external__babel_types_6e8337dd.isObjectPattern(pattern)) for (const property of pattern.properties){
621
+ const inner = patternPath(__rspack_external__babel_types_6e8337dd.isRestElement(property) ? property.argument : property.value, target);
622
+ if (void 0 === inner) continue;
623
+ const key = __rspack_external__babel_types_6e8337dd.isObjectProperty(property) ? staticKey(property) : void 0;
624
+ if ('dynamic' === inner || void 0 === key) return 'dynamic';
625
+ return {
626
+ members: [
627
+ key,
628
+ ...inner.members
629
+ ],
630
+ defaults: inner.defaults.map((entry)=>({
631
+ members: [
632
+ key,
633
+ ...entry.members
634
+ ],
635
+ value: entry.value
636
+ }))
637
+ };
638
+ }
639
+ if (__rspack_external__babel_types_6e8337dd.isArrayPattern(pattern)) for (const [index, element] of pattern.elements.entries()){
640
+ const inner = element ? patternPath(element, target) : void 0;
641
+ if (void 0 !== inner) {
642
+ if ('dynamic' === inner || __rspack_external__babel_types_6e8337dd.isRestElement(element)) return 'dynamic';
643
+ return {
644
+ members: [
645
+ String(index),
646
+ ...inner.members
647
+ ],
648
+ defaults: inner.defaults.map((entry)=>({
649
+ members: [
650
+ String(index),
651
+ ...entry.members
652
+ ],
653
+ value: entry.value
654
+ }))
655
+ };
656
+ }
657
+ }
658
+ if (__rspack_external__babel_types_6e8337dd.isRestElement(pattern)) return Object.values(__rspack_external__babel_types_6e8337dd.getBindingIdentifiers(pattern)).includes(target) ? 'dynamic' : void 0;
659
+ };
660
+ const objectRestPath = (pattern, target)=>{
661
+ if (!__rspack_external__babel_types_6e8337dd.isObjectPattern(pattern)) return;
662
+ const excluded = new Set();
663
+ for (const property of pattern.properties){
664
+ if (__rspack_external__babel_types_6e8337dd.isRestElement(property)) {
665
+ if (property.argument === target) return {
666
+ members: [],
667
+ excluded
668
+ };
669
+ continue;
670
+ }
671
+ const key = staticKey(property);
672
+ if (void 0 === key) break;
673
+ excluded.add(key);
674
+ const inner = objectRestPath(__rspack_external__babel_types_6e8337dd.isAssignmentPattern(property.value) ? property.value.left : property.value, target);
675
+ if (inner) return {
676
+ members: [
677
+ key,
678
+ ...inner.members
679
+ ],
680
+ excluded: inner.excluded
681
+ };
682
+ }
683
+ };
684
+ const callSitesOf = (fn)=>{
685
+ const outer = fn.parentPath;
686
+ if (__rspack_external__babel_types_6e8337dd.isCallExpression(outer?.node) && outer.node.callee === fn.node) return {
687
+ calls: [
688
+ outer
689
+ ],
690
+ escaped: false
691
+ };
692
+ const member = __rspack_external__babel_types_6e8337dd.isObjectMethod(fn.node) ? fn : __rspack_external__babel_types_6e8337dd.isObjectProperty(outer?.node) && outer.node.value === fn.node ? outer : void 0;
693
+ const key = member && __rspack_external__babel_types_6e8337dd.isObjectMember(member.node) ? staticKey(member.node) : void 0;
694
+ const getter = __rspack_external__babel_types_6e8337dd.isObjectMethod(fn.node) && 'get' === fn.node.kind;
695
+ const object = void 0 === key ? void 0 : member.parentPath;
696
+ const runAt = (callee)=>{
697
+ if (getter) return callee;
698
+ let invoked = callee;
699
+ const via = invoked.parentPath;
700
+ if (via && __rspack_external__babel_types_6e8337dd.isMemberExpression(via.node) && via.node.object === invoked.node && [
701
+ 'call',
702
+ 'apply'
703
+ ].includes(staticKey(via.node) ?? '')) invoked = via;
704
+ const call = invoked.parentPath;
705
+ return call && __rspack_external__babel_types_6e8337dd.isCallExpression(call.node) && call.node.callee === invoked.node ? call : void 0;
706
+ };
707
+ const calls = [];
708
+ let escaped = false;
709
+ const inline = object?.parentPath;
710
+ if (object && (__rspack_external__babel_types_6e8337dd.isMemberExpression(inline?.node) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(inline?.node)) && inline.node.object === object.node) {
711
+ const run = staticKey(inline.node) === key ? runAt(inline) : void 0;
712
+ return run ? {
713
+ calls: [
714
+ run
715
+ ],
716
+ escaped: false
717
+ } : {
718
+ calls,
719
+ escaped: true
720
+ };
721
+ }
722
+ const owner = object?.parentPath;
723
+ const name = __rspack_external__babel_types_6e8337dd.isFunctionDeclaration(fn.node) ? fn.node.id?.name : __rspack_external__babel_types_6e8337dd.isVariableDeclarator(outer?.node) && __rspack_external__babel_types_6e8337dd.isIdentifier(outer.node.id) ? outer.node.id.name : __rspack_external__babel_types_6e8337dd.isVariableDeclarator(owner?.node) && __rspack_external__babel_types_6e8337dd.isIdentifier(owner.node.id) ? owner.node.id.name : void 0;
724
+ const first = name ? (void 0 === key ? fn.scope.parent : owner.scope)?.getBinding(name) : void 0;
725
+ if (!first) return {
726
+ calls,
727
+ escaped: true
728
+ };
729
+ const bindings = [
730
+ first
731
+ ];
732
+ for(let index = 0; index < bindings.length && index < MAX_ALIASES; index += 1)for (let reference of bindings[index].referencePaths){
733
+ while(reference.parentPath && unwrapExpression(reference.parent, true) !== reference.parent)reference = reference.parentPath;
734
+ const parent = reference.parent;
735
+ if (__rspack_external__babel_types_6e8337dd.isVariableDeclarator(parent) && parent.init === reference.node && __rspack_external__babel_types_6e8337dd.isIdentifier(parent.id)) {
736
+ const alias = reference.scope.getBinding(parent.id.name);
737
+ if (alias && !bindings.includes(alias)) bindings.push(alias);
738
+ continue;
739
+ }
740
+ const callee = void 0 === key ? reference : (__rspack_external__babel_types_6e8337dd.isMemberExpression(parent) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(parent)) && parent.object === reference.node && staticKey(parent) === key ? reference.parentPath : void 0;
741
+ const run = callee ? runAt(callee) : void 0;
742
+ if (run) calls.push(run);
743
+ else if (callee && (void 0 !== key || !isReadOnlyUse(reference))) escaped = true;
744
+ else if (!callee && !isReadOnlyUse(reference)) escaped = true;
745
+ }
746
+ return {
747
+ calls,
748
+ escaped
749
+ };
750
+ };
751
+ const methodOf = (literal, key, depth = 0)=>{
752
+ for (const entry of literal.get('properties').toReversed()){
753
+ if (entry.isObjectMethod() || entry.isObjectProperty()) {
754
+ let name = staticKey(entry.node);
755
+ if (void 0 === name) {
756
+ const folded = entry.get('key').evaluate();
757
+ if (!folded.confident || 'string' != typeof folded.value) return 'unknown';
758
+ name = folded.value;
759
+ }
760
+ if (name === key) return entry;
761
+ }
762
+ if (!entry.isSpreadElement()) continue;
763
+ const argument = unwrapExpression(entry.node.argument, true);
764
+ const binding = __rspack_external__babel_types_6e8337dd.isIdentifier(argument) ? entry.scope.getBinding(argument.name) : void 0;
765
+ const init = binding?.kind === 'const' && binding.path.isVariableDeclarator() ? binding.path.get('init') : void 0;
766
+ if (!init?.isObjectExpression() || depth >= MAX_DEPTH) return 'unknown';
767
+ const found = methodOf(init, key, depth + 1);
768
+ if (void 0 !== found) return found;
769
+ }
770
+ };
771
+ const functionOf = (binding)=>{
772
+ for(let hop = 0; binding && hop < MAX_DEPTH; hop += 1){
773
+ const declared = binding.path;
774
+ if (declared.isFunctionDeclaration()) return declared;
775
+ if (!declared.isVariableDeclarator() || 'const' !== binding.kind) break;
776
+ const init = declared.get('init');
777
+ let value = init;
778
+ while(unwrapExpression(value.node, true) !== value.node)value = value.get('expression');
779
+ if (value.isFunction()) return value;
780
+ if (!value.isIdentifier()) break;
781
+ binding = value.scope.getBinding(value.node.name);
782
+ }
783
+ };
784
+ const isReadOnlyUse = (reference)=>{
785
+ const parent = reference.parent;
786
+ const node = reference.node;
787
+ return !__rspack_external__babel_types_6e8337dd.isExpression(node) || __rspack_external__babel_types_6e8337dd.isExportSpecifier(parent) || __rspack_external__babel_types_6e8337dd.isExportDefaultDeclaration(parent) || __rspack_external__babel_types_6e8337dd.isCallExpression(parent) && parent.callee === node || (__rspack_external__babel_types_6e8337dd.isMemberExpression(parent) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(parent)) && parent.object === node || __rspack_external__babel_types_6e8337dd.isExpressionStatement(parent) || __rspack_external__babel_types_6e8337dd.isUnaryExpression(parent) || __rspack_external__babel_types_6e8337dd.isBinaryExpression(parent) || __rspack_external__babel_types_6e8337dd.isTemplateLiteral(parent) || __rspack_external__babel_types_6e8337dd.isAssignmentExpression(parent) && parent.left === node || __rspack_external__babel_types_6e8337dd.isUpdateExpression(parent) && parent.argument === node || (__rspack_external__babel_types_6e8337dd.isIfStatement(parent) || __rspack_external__babel_types_6e8337dd.isConditionalExpression(parent) || __rspack_external__babel_types_6e8337dd.isWhileStatement(parent) || __rspack_external__babel_types_6e8337dd.isDoWhileStatement(parent) || __rspack_external__babel_types_6e8337dd.isForStatement(parent)) && 'test' in parent && parent.test === node || __rspack_external__babel_types_6e8337dd.isSwitchStatement(parent) && parent.discriminant === node;
788
+ };
789
+ const aliasCache = new WeakMap();
790
+ const aliasesOf = (binding, writes)=>{
791
+ if (0 === writes.size) return [
792
+ {
793
+ binding,
794
+ prefix: []
795
+ }
796
+ ];
797
+ if (writes.has(OPAQUE_RECEIVER)) return;
798
+ if (aliasCache.has(binding)) return aliasCache.get(binding);
799
+ const result = collectAliases(binding, writes);
800
+ aliasCache.set(binding, result);
801
+ return result;
802
+ };
803
+ const collectAliases = (binding, writes)=>{
804
+ const found = [
805
+ {
806
+ binding,
807
+ prefix: [],
808
+ dynamic: false,
809
+ depth: 0
810
+ }
811
+ ];
812
+ let escaped = false;
813
+ const add = (entry)=>{
814
+ if (!found.some((known)=>known.binding === entry.binding && known.dynamic === entry.dynamic && known.depth === entry.depth && JSON.stringify(known.prefix) === JSON.stringify(entry.prefix))) found.push(entry);
815
+ };
816
+ for(let index = 0; index < found.length && index < MAX_ALIASES; index += 1)for (const start of found[index].binding.referencePaths){
817
+ const origin = found[index];
818
+ const pending = [
819
+ {
820
+ reference: start,
821
+ path: [
822
+ ...origin.prefix
823
+ ],
824
+ dynamic: origin.dynamic,
825
+ depth: origin.depth
826
+ }
827
+ ];
828
+ const returnedFrom = new Set();
829
+ for(let flow = pending.pop(); flow; flow = pending.pop()){
830
+ let { reference, dynamic, depth } = flow;
831
+ const { path } = flow;
832
+ const holds = (holder, deeper)=>{
833
+ if (holder) add({
834
+ binding: holder,
835
+ prefix: path,
836
+ dynamic,
837
+ depth: depth + deeper
838
+ });
839
+ };
840
+ const into = (pattern, lookup)=>{
841
+ for (const identifier of Object.values(__rspack_external__babel_types_6e8337dd.getBindingIdentifiers(pattern))){
842
+ const route = patternPath(pattern, identifier);
843
+ const alias = lookup(identifier.name);
844
+ if (void 0 === route || !alias) continue;
845
+ if ('dynamic' === route) {
846
+ add({
847
+ binding: alias,
848
+ prefix: path,
849
+ dynamic: true,
850
+ depth
851
+ });
852
+ continue;
853
+ }
854
+ const consumed = Math.min(depth, route.members.length);
855
+ add({
856
+ binding: alias,
857
+ prefix: [
858
+ ...path,
859
+ ...route.members.slice(consumed)
860
+ ],
861
+ dynamic,
862
+ depth: depth - consumed
863
+ });
864
+ }
865
+ };
866
+ for(;;){
867
+ const parent = reference.parent;
868
+ const up = reference.parentPath;
869
+ if (!up) break;
870
+ if (unwrapExpression(parent, true) !== parent || __rspack_external__babel_types_6e8337dd.isConditionalExpression(parent) && parent.test !== reference.node || __rspack_external__babel_types_6e8337dd.isLogicalExpression(parent) || __rspack_external__babel_types_6e8337dd.isAwaitExpression(parent) || __rspack_external__babel_types_6e8337dd.isSequenceExpression(parent) && parent.expressions.at(-1) === reference.node) {
871
+ reference = up;
872
+ continue;
873
+ }
874
+ if ((__rspack_external__babel_types_6e8337dd.isMemberExpression(parent) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(parent)) && parent.object === reference.node) {
875
+ if (depth > 0 && (__rspack_external__babel_types_6e8337dd.isCallExpression(up.parent) || __rspack_external__babel_types_6e8337dd.isOptionalCallExpression(up.parent)) && up.parent.callee === parent && CONTAINER_EXTRACTORS.has(staticKey(parent) ?? '')) {
876
+ escaped = true;
877
+ break;
878
+ }
879
+ if (0 === depth && (__rspack_external__babel_types_6e8337dd.isCallExpression(up.parent) || __rspack_external__babel_types_6e8337dd.isOptionalCallExpression(up.parent)) && up.parent.callee === parent && RECEIVER_RETURNING_METHODS.has(staticKey(parent) ?? '')) {
880
+ reference = up.parentPath;
881
+ continue;
882
+ }
883
+ if (depth > 0) depth -= 1;
884
+ else {
885
+ const name = staticKey(parent);
886
+ if (void 0 === name) dynamic = true;
887
+ else path.push(name);
888
+ }
889
+ reference = up;
890
+ continue;
891
+ }
892
+ if (__rspack_external__babel_types_6e8337dd.isReturnStatement(parent) && parent.argument === reference.node || __rspack_external__babel_types_6e8337dd.isArrowFunctionExpression(parent) && parent.body === reference.node) {
893
+ const fn = reference.getFunctionParent();
894
+ if (fn && !returnedFrom.has(fn.node)) {
895
+ returnedFrom.add(fn.node);
896
+ const sites = callSitesOf(fn);
897
+ escaped ||= sites.escaped;
898
+ for (const call of sites.calls)pending.push({
899
+ reference: call,
900
+ path: [
901
+ ...path
902
+ ],
903
+ dynamic,
904
+ depth
905
+ });
906
+ }
907
+ break;
908
+ }
909
+ if (__rspack_external__babel_types_6e8337dd.isForOfStatement(parent) && parent.right === reference.node || __rspack_external__babel_types_6e8337dd.isTemplateLiteral(parent) && __rspack_external__babel_types_6e8337dd.isTaggedTemplateExpression(up.parent) || __rspack_external__babel_types_6e8337dd.isJSXExpressionContainer(parent) || __rspack_external__babel_types_6e8337dd.isJSXSpreadAttribute(parent) || __rspack_external__babel_types_6e8337dd.isJSXSpreadChild(parent) || __rspack_external__babel_types_6e8337dd.isYieldExpression(parent)) {
910
+ escaped = true;
911
+ break;
912
+ }
913
+ if (__rspack_external__babel_types_6e8337dd.isObjectProperty(parent) && parent.value === reference.node && __rspack_external__babel_types_6e8337dd.isObjectExpression(up.parent) || __rspack_external__babel_types_6e8337dd.isSpreadElement(parent) && __rspack_external__babel_types_6e8337dd.isObjectExpression(up.parent)) {
914
+ reference = up.parentPath;
915
+ if (!__rspack_external__babel_types_6e8337dd.isSpreadElement(parent) || 0 === depth) depth += 1;
916
+ continue;
917
+ }
918
+ if (__rspack_external__babel_types_6e8337dd.isArrayExpression(parent) || __rspack_external__babel_types_6e8337dd.isSpreadElement(parent) && __rspack_external__babel_types_6e8337dd.isArrayExpression(up.parent)) {
919
+ reference = __rspack_external__babel_types_6e8337dd.isSpreadElement(parent) ? up.parentPath : up;
920
+ if (!__rspack_external__babel_types_6e8337dd.isSpreadElement(parent) || 0 === depth) depth += 1;
921
+ continue;
922
+ }
923
+ if (__rspack_external__babel_types_6e8337dd.isSpreadElement(parent)) {
924
+ escaped = true;
925
+ break;
926
+ }
927
+ if ((__rspack_external__babel_types_6e8337dd.isCallExpression(parent) || __rspack_external__babel_types_6e8337dd.isOptionalCallExpression(parent) || __rspack_external__babel_types_6e8337dd.isNewExpression(parent)) && parent.callee !== reference.node) {
928
+ let calleePath = up.get('callee');
929
+ while(unwrapExpression(calleePath.node, true) !== calleePath.node)calleePath = calleePath.get('expression');
930
+ const callee = calleePath.node;
931
+ const member = __rspack_external__babel_types_6e8337dd.isMemberExpression(callee) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(callee);
932
+ const receiver = member ? writeTarget(callee)?.root : void 0;
933
+ if (receiver) holds(reference.scope.getBinding(receiver.name), 1);
934
+ const receiverObject = member ? unwrapExpression(callee.object, true) : void 0;
935
+ const method = member && (__rspack_external__babel_types_6e8337dd.isIdentifier(receiverObject) || __rspack_external__babel_types_6e8337dd.isObjectExpression(receiverObject)) ? staticKey(callee) : void 0;
936
+ let fn = __rspack_external__babel_types_6e8337dd.isIdentifier(callee) ? reference.scope.getBinding(callee.name) : __rspack_external__babel_types_6e8337dd.isIdentifier(receiverObject) ? reference.scope.getBinding(receiverObject.name) : void 0;
937
+ for(let hop = 0; fn && hop < MAX_DEPTH; hop += 1){
938
+ const aliased = fn.path.isVariableDeclarator() ? unwrapExpression(fn.path.node.init ?? fn.path.node.id, true) : void 0;
939
+ if ('const' !== fn.kind || !__rspack_external__babel_types_6e8337dd.isIdentifier(aliased)) break;
940
+ const next = fn.path.scope.getBinding(aliased.name);
941
+ if (!next || next === fn) break;
942
+ fn = next;
943
+ }
944
+ const declared = fn?.path;
945
+ const init = declared?.isVariableDeclarator() ? declared.get('init') : void 0;
946
+ let literal = init;
947
+ if (__rspack_external__babel_types_6e8337dd.isObjectExpression(receiverObject)) {
948
+ literal = calleePath.get('object');
949
+ while(unwrapExpression(literal.node, true) !== literal.node)literal = literal.get('expression');
950
+ }
951
+ const lookup = void 0 !== method && literal?.isObjectExpression() ? methodOf(literal, method) : void 0;
952
+ if ('unknown' === lookup) escaped = true;
953
+ const property = 'unknown' === lookup ? void 0 : lookup;
954
+ const held = property?.isObjectProperty() ? property.get('value') : property;
955
+ const heldName = held?.isIdentifier() ? held.node.name : void 0;
956
+ const heldFunction = heldName ? functionOf(held.scope.getBinding(heldName)) : void 0;
957
+ const target = calleePath.isFunction() ? calleePath : void 0 !== method ? heldName ? heldFunction : held : declared?.isFunctionDeclaration() ? declared : init;
958
+ if (heldName && !heldFunction?.isFunction()) {
959
+ const binding = held.scope.getBinding(heldName);
960
+ if (binding && 'module' !== binding.kind) escaped = true;
961
+ }
962
+ const initValue = init?.node ? unwrapExpression(init.node, true) : void 0;
963
+ const unseen = !target?.isFunction() && ([
964
+ 'param',
965
+ 'let',
966
+ 'var'
967
+ ].includes(fn?.kind ?? '') || !__rspack_external__babel_types_6e8337dd.isIdentifier(callee) && !member || member && !__rspack_external__babel_types_6e8337dd.isIdentifier(receiverObject) && !__rspack_external__babel_types_6e8337dd.isObjectExpression(receiverObject) && (void 0 === receiver || reference.scope.getBinding(receiver.name)?.kind !== 'module') || void 0 !== method && fn?.kind === 'const' && !property && (__rspack_external__babel_types_6e8337dd.isNewExpression(initValue) || __rspack_external__babel_types_6e8337dd.isCallExpression(initValue)) && (()=>{
968
+ const root = writeTarget(unwrapExpression(initValue.callee, true))?.root;
969
+ const owner = root ? fn.path.scope.getBinding(root.name) : void 0;
970
+ return !root || void 0 !== owner && 'module' !== owner.kind;
971
+ })() || fn?.kind === 'const' && void 0 === method && void 0 !== initValue && !__rspack_external__babel_types_6e8337dd.isMemberExpression(initValue) && !__rspack_external__babel_types_6e8337dd.isIdentifier(initValue));
972
+ const globalName = __rspack_external__babel_types_6e8337dd.isIdentifier(callee) ? callee.name : member && __rspack_external__babel_types_6e8337dd.isIdentifier(receiverObject) ? receiverObject.name : void 0;
973
+ const unboundGlobal = void 0 !== globalName && !reference.scope.getBinding(globalName) && !READ_ONLY_GLOBAL_CALLS.has(__rspack_external__babel_types_6e8337dd.isIdentifier(callee) ? globalName : `${globalName}.${staticKey(callee) ?? ''}`) && 'console' !== globalName;
974
+ if (unseen || unboundGlobal) escaped = true;
975
+ const index = parent.arguments.indexOf(reference.node);
976
+ const storing = member && void 0 !== globalName && !reference.scope.getBinding(globalName) ? STORING_GLOBAL_CALLS.get(`${globalName}.${staticKey(callee) ?? ''}`) : void 0;
977
+ if (storing && index >= 1) {
978
+ const stored = parent.arguments[0] ? writeTarget(parent.arguments[0]) : void 0;
979
+ const holder = stored ? reference.scope.getBinding(stored.root.name) : void 0;
980
+ if (holder) holds(holder, stored.depth + storing(depth) - depth);
981
+ else escaped = true;
982
+ }
983
+ if (('call' === method || 'apply' === method || 'bind' === method) && __rspack_external__babel_types_6e8337dd.isIdentifier(receiverObject)) {
984
+ const receiverBinding = reference.scope.getBinding(receiverObject.name);
985
+ const invoked = functionOf(receiverBinding);
986
+ const param = invoked?.isFunction() ? invoked.node.params[index - 1] : void 0;
987
+ if ('call' === method && index >= 1 && param && !__rspack_external__babel_types_6e8337dd.isRestElement(param) && invoked?.isFunction()) into(param, (name)=>invoked.scope.getBinding(name));
988
+ else if (receiverBinding && 'module' !== receiverBinding.kind) escaped = true;
989
+ }
990
+ if (target?.isFunction()) {
991
+ const param = target.node.params[index];
992
+ if (param && !__rspack_external__babel_types_6e8337dd.isRestElement(param)) into(param, (name)=>target.scope.getBinding(name));
993
+ else escaped = true;
994
+ }
995
+ reference = up;
996
+ dynamic = true;
997
+ continue;
998
+ }
999
+ if ((__rspack_external__babel_types_6e8337dd.isClassProperty(parent) || __rspack_external__babel_types_6e8337dd.isClassPrivateProperty(parent) || __rspack_external__babel_types_6e8337dd.isClassAccessorProperty(parent)) && parent.value === reference.node) {
1000
+ const owner = up.parentPath?.parentPath;
1001
+ if (!parent.static || __rspack_external__babel_types_6e8337dd.isPrivateName(parent.key) || !owner) {
1002
+ escaped = true;
1003
+ break;
1004
+ }
1005
+ if (owner.isClassDeclaration()) {
1006
+ const id = owner.node.id;
1007
+ const binding = id ? owner.parentPath.scope.getBinding(id.name) : void 0;
1008
+ if (binding) holds(binding, 1);
1009
+ else escaped = true;
1010
+ break;
1011
+ }
1012
+ reference = owner;
1013
+ depth += 1;
1014
+ continue;
1015
+ }
1016
+ if (__rspack_external__babel_types_6e8337dd.isAssignmentExpression(parent) && parent.right === reference.node && !__rspack_external__babel_types_6e8337dd.isIdentifier(parent.left) && !__rspack_external__babel_types_6e8337dd.isPattern(parent.left)) {
1017
+ const stored = writeTarget(parent.left);
1018
+ const setters = setterNames(reference.scope.getProgramParent().path);
1019
+ const key = __rspack_external__babel_types_6e8337dd.isMemberExpression(parent.left) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(parent.left) ? staticKey(parent.left) : void 0;
1020
+ if (setters.has(DYNAMIC_SETTER) || setters.size > 0 && (void 0 === key || setters.has(key))) {
1021
+ escaped = true;
1022
+ break;
1023
+ }
1024
+ if (stored) holds(reference.scope.getBinding(stored.root.name), stored.depth);
1025
+ reference = up;
1026
+ continue;
1027
+ }
1028
+ break;
1029
+ }
1030
+ const parent = reference.parent;
1031
+ const target = __rspack_external__babel_types_6e8337dd.isVariableDeclarator(parent) && parent.init === reference.node ? parent.id : __rspack_external__babel_types_6e8337dd.isAssignmentExpression(parent) && [
1032
+ '=',
1033
+ '&&=',
1034
+ '||=',
1035
+ '??='
1036
+ ].includes(parent.operator) || __rspack_external__babel_types_6e8337dd.isAssignmentPattern(parent) ? parent.right === reference.node ? parent.left : void 0 : void 0;
1037
+ if (__rspack_external__babel_types_6e8337dd.isLVal(target)) {
1038
+ into(target, (name)=>reference.scope.getBinding(name));
1039
+ if (__rspack_external__babel_types_6e8337dd.isAssignmentExpression(parent) && reference.parentPath) pending.push({
1040
+ reference: reference.parentPath,
1041
+ path: [
1042
+ ...path
1043
+ ],
1044
+ dynamic,
1045
+ depth
1046
+ });
1047
+ }
1048
+ }
1049
+ }
1050
+ const reaches = (entry)=>(writes.get(entry.binding) ?? []).some((write)=>0 === entry.depth ? entry.dynamic : write.depth > entry.depth);
1051
+ const tracked = new Set(found.map((entry)=>entry.binding));
1052
+ if (found.length > MAX_ALIASES || found.some(reaches) || escaped && [
1053
+ ...writes.keys()
1054
+ ].some((owner)=>!tracked.has(owner))) return;
1055
+ return found.filter((entry)=>!entry.dynamic && 0 === entry.depth);
1056
+ };
1057
+ function createModuleGraph() {
1058
+ const modules = new Map();
1059
+ const facts = new WeakMap();
1060
+ const workspaces = new Map();
1061
+ const load = (filePath, boundary)=>{
1062
+ const real = node_fs.realpathSync(filePath);
1063
+ let entry = modules.get(real);
1064
+ if (void 0 === entry) {
1065
+ const directory = node_path.dirname(real);
1066
+ if (!workspaces.has(directory)) workspaces.set(directory, containingWorkspace(real));
1067
+ const workspace = workspaces.get(directory);
1068
+ try {
1069
+ const parsed = parseModule(real, workspace);
1070
+ const module = {
1071
+ file: parsed.file,
1072
+ path: real,
1073
+ boundary: boundary ?? sourceBoundary(real, workspace),
1074
+ mutations: parsed.mutations
1075
+ };
1076
+ facts.set(module, parsed.facts);
1077
+ entry = {
1078
+ module,
1079
+ facts: parsed.facts
1080
+ };
1081
+ } catch (error) {
1082
+ if (!(error instanceof SourceSyntaxError)) throw error;
1083
+ entry = error;
1084
+ }
1085
+ modules.set(real, entry);
1086
+ }
1087
+ if (entry instanceof SourceSyntaxError) throw entry;
1088
+ return entry.module;
1089
+ };
1090
+ const factsOf = (module)=>{
1091
+ const known = facts.get(module);
1092
+ if (known) return known;
1093
+ throw new Error(`${module.path}: module does not belong to this graph`);
1094
+ };
1095
+ const follow = (module, specifier)=>{
1096
+ const target = resolveModulePath(module, specifier, factsOf(module).workspace);
1097
+ if (target?.kind === 'external') return 'external';
1098
+ if (void 0 === target) return;
1099
+ try {
1100
+ return load(target.path, target.boundary);
1101
+ } catch (error) {
1102
+ if (error instanceof SourceSyntaxError) return;
1103
+ throw error;
1104
+ }
1105
+ };
1106
+ const mutated = (module, binding)=>binding.constantViolations.length > 0 || factsOf(module).merged.has(binding.identifier.name) || (aliasesOf(binding, factsOf(module).writes)?.some((alias)=>factsOf(module).writes.has(alias.binding)) ?? true);
1107
+ const resolveBinding = (module, name, scope, chain, seen, lexical)=>{
1108
+ const key = `${scope}:${module.path}#${name}`;
1109
+ if (seen.has(key) || seen.size >= MAX_LOOKUPS) return;
1110
+ seen.add(key);
1111
+ const last = chain.at(-1);
1112
+ const hops = last?.path === module.path && last.name === name ? chain : [
1113
+ ...chain,
1114
+ {
1115
+ path: module.path,
1116
+ name
1117
+ }
1118
+ ];
1119
+ const throughModule = (specifier, imported, allowExternal)=>{
1120
+ const next = follow(module, specifier);
1121
+ if ('external' === next) return allowExternal ? {
1122
+ kind: 'external',
1123
+ specifier,
1124
+ name: imported,
1125
+ chain: hops
1126
+ } : void 0;
1127
+ return void 0 === next ? void 0 : resolveBinding(next, imported, 'export', hops, seen);
1128
+ };
1129
+ if ('local' === scope) {
1130
+ const binding = lexical ?? factsOf(module).scope.getBinding(name);
1131
+ if (!binding || mutated(module, binding)) return;
1132
+ if ('module' === binding.kind) {
1133
+ const imported = importOf(binding);
1134
+ return void 0 === imported || '*' === imported.name ? void 0 : throughModule(imported.specifier, imported.name, true);
1135
+ }
1136
+ const declarator = binding.path.node;
1137
+ return 'const' === binding.kind && __rspack_external__babel_types_6e8337dd.isVariableDeclarator(declarator) && __rspack_external__babel_types_6e8337dd.isIdentifier(declarator.id) && declarator.init ? {
1138
+ kind: 'declaration',
1139
+ expression: declarator.init,
1140
+ module,
1141
+ chain: hops
1142
+ } : void 0;
1143
+ }
1144
+ const hop = exportHop(module.file, name);
1145
+ if (hop?.kind === 'local') return resolveBinding(module, hop.name, 'local', hops, seen);
1146
+ if (hop?.kind === 'reexport') return throughModule(hop.specifier, hop.name, true);
1147
+ if (hop?.kind === 'node') return __rspack_external__babel_types_6e8337dd.isExpression(hop.node) ? {
1148
+ kind: 'declaration',
1149
+ expression: hop.node,
1150
+ module,
1151
+ chain: hops
1152
+ } : void 0;
1153
+ if (void 0 !== hop) return;
1154
+ for (const specifier of starSources(module.file, name)){
1155
+ const resolved = throughModule(specifier, name, false);
1156
+ if (void 0 !== resolved) return resolved;
1157
+ }
1158
+ };
1159
+ const resolveReference = (module, reference)=>{
1160
+ const node = unwrapExpression(reference, true);
1161
+ const moduleFacts = factsOf(module);
1162
+ const bindingAt = (identifier)=>moduleFacts.references.get(identifier) ?? moduleFacts.declarations.get(identifier);
1163
+ if (__rspack_external__babel_types_6e8337dd.isIdentifier(node)) {
1164
+ const binding = bindingAt(node);
1165
+ return binding ? resolveBinding(module, node.name, 'local', [], new Set(), binding) : void 0;
1166
+ }
1167
+ if (!__rspack_external__babel_types_6e8337dd.isMemberExpression(node) || node.computed || !__rspack_external__babel_types_6e8337dd.isIdentifier(node.object) || !__rspack_external__babel_types_6e8337dd.isIdentifier(node.property)) return;
1168
+ const binding = bindingAt(node.object);
1169
+ if (!binding || 'module' !== binding.kind || mutated(module, binding)) return;
1170
+ const imported = importOf(binding);
1171
+ if (imported?.name !== '*') return;
1172
+ const target = follow(module, imported.specifier);
1173
+ const chain = [
1174
+ {
1175
+ path: module.path,
1176
+ name: node.object.name
1177
+ }
1178
+ ];
1179
+ if ('external' === target) return {
1180
+ kind: 'external',
1181
+ specifier: imported.specifier,
1182
+ name: node.property.name,
1183
+ chain
1184
+ };
1185
+ return void 0 === target ? void 0 : resolveBinding(target, node.property.name, 'export', chain, new Set());
1186
+ };
1187
+ const isUnboundReference = (module, reference)=>{
1188
+ const node = unwrapExpression(reference, true);
1189
+ const { references } = factsOf(module);
1190
+ return __rspack_external__babel_types_6e8337dd.isIdentifier(node) && references.has(node) && void 0 === references.get(node);
1191
+ };
1192
+ const evaluation = (walking)=>{
1193
+ const active = new Set();
1194
+ let frames = 0;
1195
+ let frame = {
1196
+ id: 0,
1197
+ parameters: new Map()
1198
+ };
1199
+ let steps = 0;
1200
+ const boundArguments = new WeakMap();
1201
+ const closureFrames = new WeakMap();
1202
+ const unresolved = (module, node)=>[
1203
+ {
1204
+ kind: 'unresolved',
1205
+ node,
1206
+ module
1207
+ }
1208
+ ];
1209
+ const namespaceValues = (module, specifier, members, at)=>{
1210
+ const next = follow(module, specifier);
1211
+ if ('external' === next) return [
1212
+ 0 === members.length ? {
1213
+ kind: 'external',
1214
+ specifier,
1215
+ name: '*',
1216
+ members: []
1217
+ } : {
1218
+ kind: 'external',
1219
+ specifier,
1220
+ name: members[0],
1221
+ members: members.slice(1)
1222
+ }
1223
+ ];
1224
+ if (void 0 === next) return unresolved(module, at);
1225
+ if (0 === members.length) {
1226
+ const written = (write)=>write.value ? values(next, write.value, [
1227
+ ...write.from ?? []
1228
+ ]) : unresolved(next, write.node);
1229
+ const whole = factsOf(next).commonJs.filter((write)=>0 === write.path.length && !write.dynamic);
1230
+ const found = whole.flatMap(written);
1231
+ if (walking) {
1232
+ for (const write of factsOf(next).commonJs)if (write.path.length > 0 || write.dynamic) found.push(...written(write));
1233
+ const key = `namespace:${next.path}`;
1234
+ if (!active.has(key)) {
1235
+ active.add(key);
1236
+ try {
1237
+ for (const name of exportNames(next.file))found.push(...exportValues(next, name, []) ?? []);
1238
+ for (const specifier of starSources(next.file, ''))found.push(...namespaceValues(next, specifier, [], at));
1239
+ } finally{
1240
+ active.delete(key);
1241
+ }
1242
+ }
1243
+ }
1244
+ return whole.length > 0 ? found : [
1245
+ ...unresolved(module, at),
1246
+ ...found
1247
+ ];
1248
+ }
1249
+ return exportValues(next, members[0], members.slice(1)) ?? unresolved(module, at);
1250
+ };
1251
+ const importValues = (module, specifier, name, members, at)=>{
1252
+ if ('*' === name) return namespaceValues(module, specifier, members, at);
1253
+ const next = follow(module, specifier);
1254
+ if ('external' === next) return [
1255
+ {
1256
+ kind: 'external',
1257
+ specifier,
1258
+ name,
1259
+ members
1260
+ }
1261
+ ];
1262
+ return (next && exportValues(next, name, members)) ?? unresolved(module, at);
1263
+ };
1264
+ const exportValues = (module, name, members)=>{
1265
+ const key = `export:${module.path}#${name}:${members.join('.')}`;
1266
+ if (active.has(key)) return;
1267
+ if (++steps > MAX_LOOKUPS || active.size >= MAX_DEPTH) return unresolved(module, module.file);
1268
+ active.add(key);
1269
+ try {
1270
+ return exportedValues(module, name, members);
1271
+ } finally{
1272
+ active.delete(key);
1273
+ }
1274
+ };
1275
+ const exportedValues = (module, name, members)=>{
1276
+ const hop = exportHop(module.file, name);
1277
+ if (hop?.kind === 'local') {
1278
+ const binding = factsOf(module).scope.getBinding(hop.name);
1279
+ return binding ? bindingValues(module, binding, members, binding.identifier) : unresolved(module, module.file);
1280
+ }
1281
+ if (hop?.kind === 'reexport') return importValues(module, hop.specifier, hop.name, members, module.file);
1282
+ if (hop?.kind === 'namespace') return namespaceValues(module, hop.specifier, members, module.file);
1283
+ if (hop?.kind === 'node') return values(module, hop.node, members);
1284
+ for (const specifier of starSources(module.file, name)){
1285
+ const next = follow(module, specifier);
1286
+ const found = void 0 === next || 'external' === next ? void 0 : exportValues(next, name, members);
1287
+ if (void 0 !== found) return found;
1288
+ }
1289
+ return commonJsExport(module, name, members);
1290
+ };
1291
+ const commonJsExport = (module, name, members)=>{
1292
+ const found = [];
1293
+ for (const [requested, explicit] of 'default' === name ? [
1294
+ [
1295
+ [
1296
+ ...members
1297
+ ],
1298
+ false
1299
+ ],
1300
+ [
1301
+ [
1302
+ 'default',
1303
+ ...members
1304
+ ],
1305
+ true
1306
+ ]
1307
+ ] : [
1308
+ [
1309
+ [
1310
+ name,
1311
+ ...members
1312
+ ],
1313
+ false
1314
+ ]
1315
+ ])for (const write of factsOf(module).commonJs){
1316
+ if (explicit && 0 === write.path.length) continue;
1317
+ const reads = write.path.length <= requested.length;
1318
+ const [shorter, longer] = reads ? [
1319
+ write.path,
1320
+ requested
1321
+ ] : [
1322
+ requested,
1323
+ write.path
1324
+ ];
1325
+ if (!(!reads && !walking || shorter.some((key, index)=>longer[index] !== key))) found.push(...write.dynamic || !write.value ? unresolved(module, write.node) : values(module, write.value, [
1326
+ ...write.from ?? [],
1327
+ ...reads ? requested.slice(write.path.length) : []
1328
+ ]));
1329
+ }
1330
+ return found.length > 0 ? found : void 0;
1331
+ };
1332
+ const bindingValues = (module, binding, members, at)=>{
1333
+ const moduleFacts = factsOf(module);
1334
+ if (binding.scope === moduleFacts.scope && moduleFacts.merged.has(binding.identifier.name)) return unresolved(module, at);
1335
+ const found = [];
1336
+ const node = binding.path.node;
1337
+ if ('module' === binding.kind) {
1338
+ const imported = importOf(binding);
1339
+ found.push(...void 0 === imported ? unresolved(module, at) : importValues(module, imported.specifier, imported.name, members, binding.path.parent));
1340
+ } else if (__rspack_external__babel_types_6e8337dd.isVariableDeclarator(node)) {
1341
+ const route = patternPath(node.id, binding.identifier);
1342
+ const rest = 'dynamic' === route && node.init && members.length > 0 ? objectRestPath(node.id, binding.identifier) : void 0;
1343
+ if (rest && !rest.excluded.has(members[0])) found.push(...values(module, node.init, [
1344
+ ...rest.members,
1345
+ ...members
1346
+ ]));
1347
+ else if (void 0 === route || 'dynamic' === route) found.push(...unresolved(module, at));
1348
+ else {
1349
+ if (node.init) found.push(...values(module, node.init, [
1350
+ ...route.members,
1351
+ ...members
1352
+ ]));
1353
+ else if (0 === binding.constantViolations.length || __rspack_external__babel_types_6e8337dd.isForXStatement(binding.path.parentPath?.parent)) found.push(...unresolved(module, at));
1354
+ for (const fallback of route.defaults)found.push(...values(module, fallback.value, [
1355
+ ...route.members.slice(fallback.members.length),
1356
+ ...members
1357
+ ]));
1358
+ }
1359
+ } else if (__rspack_external__babel_types_6e8337dd.isClassDeclaration(node) && members.length > 0) found.push(...staticMemberValues(module, node, members));
1360
+ else if (__rspack_external__babel_types_6e8337dd.isFunctionDeclaration(node) || __rspack_external__babel_types_6e8337dd.isClassDeclaration(node)) found.push(...0 === members.length ? [
1361
+ {
1362
+ kind: 'node',
1363
+ node,
1364
+ module
1365
+ }
1366
+ ] : unresolved(module, at));
1367
+ else {
1368
+ const parameter = 'param' === binding.kind ? frame.parameters.get(binding) : void 0;
1369
+ const route = parameter ? patternPath(parameter.pattern, binding.identifier) : void 0;
1370
+ if (parameter && route && 'dynamic' !== route) {
1371
+ const { argument } = parameter;
1372
+ if (argument) {
1373
+ const current = frame;
1374
+ frame = parameter.context;
1375
+ try {
1376
+ found.push(...values(argument.module, argument.node, [
1377
+ ...route.members,
1378
+ ...members
1379
+ ]));
1380
+ } finally{
1381
+ frame = current;
1382
+ }
1383
+ } else if (0 === route.defaults.length) found.push(...unresolved(module, at));
1384
+ for (const fallback of route.defaults)found.push(...values(module, fallback.value, [
1385
+ ...route.members.slice(fallback.members.length),
1386
+ ...members
1387
+ ]));
1388
+ } else found.push(...unresolved(module, at));
1389
+ }
1390
+ for (const violation of binding.constantViolations){
1391
+ const write = violation.node;
1392
+ const target = __rspack_external__babel_types_6e8337dd.isAssignmentExpression(write) && [
1393
+ '=',
1394
+ '&&=',
1395
+ '||=',
1396
+ '??='
1397
+ ].includes(write.operator) ? __rspack_external__babel_types_6e8337dd.getBindingIdentifiers(write.left)[binding.identifier.name] : void 0;
1398
+ const route = target && __rspack_external__babel_types_6e8337dd.isAssignmentExpression(write) ? patternPath(write.left, target) : void 0;
1399
+ if (!route || 'dynamic' === route || !__rspack_external__babel_types_6e8337dd.isAssignmentExpression(write)) {
1400
+ found.push(...unresolved(module, write));
1401
+ continue;
1402
+ }
1403
+ found.push(...values(module, write.right, [
1404
+ ...route.members,
1405
+ ...members
1406
+ ]));
1407
+ for (const fallback of route.defaults)found.push(...values(module, fallback.value, [
1408
+ ...route.members.slice(fallback.members.length),
1409
+ ...members
1410
+ ]));
1411
+ }
1412
+ const aliases = aliasesOf(binding, moduleFacts.writes);
1413
+ if (!aliases) found.push(...unresolved(module, at));
1414
+ for (const write of (aliases ?? []).flatMap((alias)=>(moduleFacts.writes.get(alias.binding) ?? []).map((entry)=>({
1415
+ ...entry,
1416
+ path: [
1417
+ ...alias.prefix,
1418
+ ...entry.path
1419
+ ]
1420
+ })))){
1421
+ const reads = write.dynamic ? write.path.length < members.length : write.path.length <= members.length;
1422
+ const [shorter, longer] = reads ? [
1423
+ write.path,
1424
+ members
1425
+ ] : [
1426
+ members,
1427
+ write.path
1428
+ ];
1429
+ if (!(!reads && !walking || shorter.some((name, index)=>longer[index] !== name))) {
1430
+ if (write.dynamic && reads) found.push(...unresolved(module, write.node));
1431
+ found.push(...void 0 === write.value ? unresolved(module, write.node) : values(module, write.value, [
1432
+ ...write.from ?? [],
1433
+ ...reads ? members.slice(write.path.length + (write.dynamic ? 1 : 0)) : []
1434
+ ]));
1435
+ }
1436
+ }
1437
+ return found;
1438
+ };
1439
+ const propertyValues = (module, object, members)=>{
1440
+ const [name, ...rest] = members;
1441
+ const found = [];
1442
+ for (const property of object.properties.toReversed()){
1443
+ if (__rspack_external__babel_types_6e8337dd.isSpreadElement(property)) {
1444
+ found.push(values(module, property.argument, members));
1445
+ const spread = values(module, property.argument, []);
1446
+ if (void 0 !== name && spread.length > 0 && spread.every((value)=>'node' === value.kind && __rspack_external__babel_types_6e8337dd.isObjectExpression(value.node) && value.node.properties.some((entry)=>!__rspack_external__babel_types_6e8337dd.isSpreadElement(entry) && (staticKey(entry) ?? (entry.computed ? constantString(value.module, entry.key) : void 0)) === name && !(__rspack_external__babel_types_6e8337dd.isObjectMethod(entry) && 'set' === entry.kind)))) break;
1447
+ continue;
1448
+ }
1449
+ const key = staticKey(property) ?? (property.computed ? constantString(module, property.key) : void 0);
1450
+ if (void 0 === key) {
1451
+ found.push(unresolved(module, property));
1452
+ continue;
1453
+ }
1454
+ if (key === name) {
1455
+ found.push(__rspack_external__babel_types_6e8337dd.isObjectMethod(property) ? 'get' === property.kind ? returnValues(module, property, rest) : 0 === rest.length ? [
1456
+ {
1457
+ kind: 'node',
1458
+ node: property,
1459
+ module
1460
+ }
1461
+ ] : unresolved(module, property) : values(module, property.value, rest));
1462
+ if (!__rspack_external__babel_types_6e8337dd.isObjectMethod(property) || 'set' !== property.kind) break;
1463
+ }
1464
+ }
1465
+ const ordered = found.toReversed().flat();
1466
+ return ordered.length > 0 ? ordered : unresolved(module, object);
1467
+ };
1468
+ const staticMemberValues = (module, declaration, members)=>{
1469
+ const [name, ...rest] = members;
1470
+ const found = [];
1471
+ let definite = false;
1472
+ for (const member of declaration.body.body.toReversed()){
1473
+ if (definite) break;
1474
+ if (__rspack_external__babel_types_6e8337dd.isStaticBlock(member)) {
1475
+ found.push(...unresolved(module, member));
1476
+ continue;
1477
+ }
1478
+ if (!(__rspack_external__babel_types_6e8337dd.isClassProperty(member) || __rspack_external__babel_types_6e8337dd.isClassAccessorProperty(member) || __rspack_external__babel_types_6e8337dd.isClassMethod(member)) || !member.static) continue;
1479
+ const key = staticKey(member) ?? (member.computed ? constantString(module, member.key) : void 0);
1480
+ if (void 0 === key) {
1481
+ found.push(...unresolved(module, member));
1482
+ continue;
1483
+ }
1484
+ if (key === name) {
1485
+ if (__rspack_external__babel_types_6e8337dd.isClassProperty(member) || __rspack_external__babel_types_6e8337dd.isClassAccessorProperty(member)) {
1486
+ definite = true;
1487
+ found.push(...member.value ? values(module, member.value, rest) : unresolved(module, member));
1488
+ } else if ('get' === member.kind) {
1489
+ definite = true;
1490
+ found.push(...returnValues(module, member, rest));
1491
+ } else if ('method' === member.kind) {
1492
+ definite = true;
1493
+ found.push(...0 === rest.length ? [
1494
+ {
1495
+ kind: 'node',
1496
+ node: member,
1497
+ module
1498
+ }
1499
+ ] : unresolved(module, member));
1500
+ }
1501
+ }
1502
+ }
1503
+ if (!definite || declaration.superClass) found.push(...unresolved(module, declaration));
1504
+ return found;
1505
+ };
1506
+ const returnValues = (module, fn, members)=>{
1507
+ const body = fn.body;
1508
+ if (__rspack_external__babel_types_6e8337dd.isExpression(body)) return values(module, body, members);
1509
+ const moduleFacts = factsOf(module);
1510
+ const found = moduleFacts.bareReturns.has(fn) || !(__rspack_external__babel_types_6e8337dd.isReturnStatement(body.body.at(-1)) || __rspack_external__babel_types_6e8337dd.isThrowStatement(body.body.at(-1))) ? unresolved(module, fn) : [];
1511
+ for (const expression of moduleFacts.returns.get(fn) ?? [])found.push(...values(module, expression, members));
1512
+ return found;
1513
+ };
1514
+ const callable = (value)=>'external' === value.kind || 'node' === value.kind && __rspack_external__babel_types_6e8337dd.isFunction(value.node);
1515
+ const callValues = (module, call, members)=>{
1516
+ const found = [];
1517
+ let terminal = false;
1518
+ const argumentsOf = (args)=>args.map((node)=>({
1519
+ module,
1520
+ node,
1521
+ context: frame
1522
+ }));
1523
+ const run = (callee, callArgs)=>{
1524
+ const args = [
1525
+ ...boundArguments.get(callee) ?? [],
1526
+ ...callArgs
1527
+ ];
1528
+ if ('unresolved' === callee.kind) return void found.push(...unresolved(module, call));
1529
+ if ('node' !== callee.kind || !__rspack_external__babel_types_6e8337dd.isFunction(callee.node)) {
1530
+ terminal = true;
1531
+ return;
1532
+ }
1533
+ const outer = frame;
1534
+ const parameters = new Map([
1535
+ ...outer.parameters,
1536
+ ...closureFrames.get(callee)?.parameters ?? []
1537
+ ]);
1538
+ const fnScope = factsOf(callee.module).functionScopes.get(callee.node);
1539
+ const spread = args.findIndex(({ node })=>__rspack_external__babel_types_6e8337dd.isSpreadElement(node) || __rspack_external__babel_types_6e8337dd.isArgumentPlaceholder(node));
1540
+ callee.node.params.forEach((param, index)=>{
1541
+ if (-1 !== spread && index >= spread) return;
1542
+ const remaining = args.slice(index);
1543
+ const restArray = __rspack_external__babel_types_6e8337dd.isRestElement(param) && __rspack_external__babel_types_6e8337dd.isIdentifier(param.argument) && remaining.every(({ module: from, context })=>from === remaining[0]?.module && context === remaining[0]?.context) ? {
1544
+ ...__rspack_external__babel_types_6e8337dd.arrayExpression(remaining.map(({ node })=>node)),
1545
+ start: param.start,
1546
+ end: param.end
1547
+ } : void 0;
1548
+ if (restArray && __rspack_external__babel_types_6e8337dd.isRestElement(param)) {
1549
+ const binding = fnScope?.getOwnBinding(param.argument.name);
1550
+ if (binding) parameters.set(binding, {
1551
+ pattern: param.argument,
1552
+ argument: {
1553
+ module: remaining[0]?.module ?? module,
1554
+ node: restArray
1555
+ },
1556
+ context: remaining[0]?.context ?? outer
1557
+ });
1558
+ return;
1559
+ }
1560
+ const argument = args[index];
1561
+ for (const name of Object.keys(__rspack_external__babel_types_6e8337dd.getBindingIdentifiers(param))){
1562
+ const binding = fnScope?.getOwnBinding(name);
1563
+ if (binding) parameters.set(binding, {
1564
+ pattern: param,
1565
+ argument: argument ? {
1566
+ module: argument.module,
1567
+ node: argument.node
1568
+ } : void 0,
1569
+ context: argument?.context ?? outer
1570
+ });
1571
+ }
1572
+ });
1573
+ const inner = {
1574
+ id: frames += 1,
1575
+ parameters
1576
+ };
1577
+ frame = inner;
1578
+ try {
1579
+ for (const value of returnValues(callee.module, callee.node, members))if ('node' === value.kind && __rspack_external__babel_types_6e8337dd.isFunction(value.node)) {
1580
+ const closure = {
1581
+ ...value
1582
+ };
1583
+ closureFrames.set(closure, inner);
1584
+ const bound = boundArguments.get(value);
1585
+ if (bound) boundArguments.set(closure, bound);
1586
+ found.push(closure);
1587
+ } else found.push(value);
1588
+ } finally{
1589
+ frame = outer;
1590
+ }
1591
+ };
1592
+ const via = unwrapExpression(call.callee, true);
1593
+ const invocation = (__rspack_external__babel_types_6e8337dd.isMemberExpression(via) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(via)) && [
1594
+ 'call',
1595
+ 'apply',
1596
+ 'bind'
1597
+ ].includes(staticKey(via) ?? '') ? {
1598
+ name: staticKey(via),
1599
+ object: via.object
1600
+ } : void 0;
1601
+ const reflected = (__rspack_external__babel_types_6e8337dd.isMemberExpression(via) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(via)) && __rspack_external__babel_types_6e8337dd.isIdentifier(via.object, {
1602
+ name: 'Reflect'
1603
+ }) && 'apply' === staticKey(via) && !(factsOf(module).references.get(via.object) ?? factsOf(module).scope.getBinding('Reflect')) && void 0 !== call.arguments[0];
1604
+ if (reflected) {
1605
+ const listed = call.arguments[2];
1606
+ const list = __rspack_external__babel_types_6e8337dd.isArrayExpression(listed) && listed.elements.every((element)=>null !== element && !__rspack_external__babel_types_6e8337dd.isSpreadElement(element)) ? listed.elements : void 0;
1607
+ for (const callee of values(module, call.arguments[0], []))if (list) run(callee, argumentsOf(list));
1608
+ else found.push(...unresolved(module, call));
1609
+ } else if (invocation) {
1610
+ const receivers = values(module, invocation.object, []);
1611
+ if (!receivers.every(callable)) for (const callee of values(module, invocation.object, [
1612
+ invocation.name
1613
+ ]))run(callee, argumentsOf(call.arguments));
1614
+ for (const receiver of receivers.filter(callable)){
1615
+ if ('bind' === invocation.name) {
1616
+ if (members.length > 0) {
1617
+ found.push(...unresolved(module, call));
1618
+ continue;
1619
+ }
1620
+ const bound = argumentsOf(call.arguments.slice(1));
1621
+ if (0 === bound.length) {
1622
+ found.push(receiver);
1623
+ continue;
1624
+ }
1625
+ const boundReceiver = {
1626
+ ...receiver
1627
+ };
1628
+ const closure = closureFrames.get(receiver);
1629
+ if (closure) closureFrames.set(boundReceiver, closure);
1630
+ boundArguments.set(boundReceiver, [
1631
+ ...boundArguments.get(receiver) ?? [],
1632
+ ...bound
1633
+ ]);
1634
+ found.push(boundReceiver);
1635
+ continue;
1636
+ }
1637
+ const listed = call.arguments[1];
1638
+ run(receiver, argumentsOf('call' === invocation.name ? call.arguments.slice(1) : __rspack_external__babel_types_6e8337dd.isArrayExpression(listed) && listed.elements.every((element)=>null !== element && !__rspack_external__babel_types_6e8337dd.isSpreadElement(element)) ? listed.elements : []));
1639
+ }
1640
+ } else for (const callee of values(module, call.callee, []))run(callee, argumentsOf(call.arguments));
1641
+ if (terminal) found.push(...0 === members.length ? [
1642
+ {
1643
+ kind: 'node',
1644
+ node: call,
1645
+ module
1646
+ }
1647
+ ] : unresolved(module, call));
1648
+ return found;
1649
+ };
1650
+ const constantString = (module, expression, depth = 0)=>{
1651
+ const node = unwrapExpression(expression, true);
1652
+ if (depth > MAX_DEPTH) return;
1653
+ if (__rspack_external__babel_types_6e8337dd.isStringLiteral(node)) return node.value;
1654
+ if (__rspack_external__babel_types_6e8337dd.isNumericLiteral(node)) return String(node.value);
1655
+ if (__rspack_external__babel_types_6e8337dd.isTemplateLiteral(node) && 0 === node.expressions.length) return node.quasis[0]?.value.cooked ?? void 0;
1656
+ if (__rspack_external__babel_types_6e8337dd.isBinaryExpression(node, {
1657
+ operator: '+'
1658
+ })) {
1659
+ const left = constantString(module, node.left, depth + 1);
1660
+ const right = constantString(module, node.right, depth + 1);
1661
+ return void 0 === left || void 0 === right ? void 0 : left + right;
1662
+ }
1663
+ if (!__rspack_external__babel_types_6e8337dd.isIdentifier(node)) return;
1664
+ const binding = factsOf(module).references.get(node) ?? factsOf(module).scope.getBinding(node.name);
1665
+ const declarator = binding?.path.node;
1666
+ return binding?.kind === 'const' && __rspack_external__babel_types_6e8337dd.isVariableDeclarator(declarator) && declarator.id === binding.identifier && declarator.init ? constantString(module, declarator.init, depth + 1) : void 0;
1667
+ };
1668
+ const values = (module, expression, members)=>{
1669
+ const node = unwrapExpression(expression, true);
1670
+ const key = `${frame.id}:${module.path}:${node.start}:${node.end}:${node.type}:${members.join('.')}`;
1671
+ if (active.has(key)) return unresolved(module, node);
1672
+ if (++steps > MAX_LOOKUPS || active.size >= MAX_DEPTH) return unresolved(module, node);
1673
+ active.add(key);
1674
+ try {
1675
+ if (__rspack_external__babel_types_6e8337dd.isIdentifier(node) || __rspack_external__babel_types_6e8337dd.isJSXIdentifier(node)) {
1676
+ const binding = factsOf(module).references.get(node) ?? factsOf(module).scope.getBinding(node.name);
1677
+ return binding ? bindingValues(module, binding, members, node) : unresolved(module, node);
1678
+ }
1679
+ if (__rspack_external__babel_types_6e8337dd.isJSXMemberExpression(node)) return values(module, node.object, [
1680
+ node.property.name,
1681
+ ...members
1682
+ ]);
1683
+ if (__rspack_external__babel_types_6e8337dd.isMemberExpression(node) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(node)) {
1684
+ const name = staticKey(node) ?? (node.computed ? constantString(module, node.property) : void 0);
1685
+ if (void 0 === name) return unresolved(module, node);
1686
+ if (0 === members.length && [
1687
+ 'call',
1688
+ 'apply',
1689
+ 'bind'
1690
+ ].includes(name)) {
1691
+ const receivers = values(module, node.object, []);
1692
+ const functions = receivers.filter(callable);
1693
+ return functions.length === receivers.length ? functions : [
1694
+ ...functions,
1695
+ ...values(module, node.object, [
1696
+ name
1697
+ ])
1698
+ ];
1699
+ }
1700
+ return values(module, node.object, [
1701
+ name,
1702
+ ...members
1703
+ ]);
1704
+ }
1705
+ if (__rspack_external__babel_types_6e8337dd.isImportExpression(node) && __rspack_external__babel_types_6e8337dd.isStringLiteral(node.source)) return namespaceValues(module, node.source.value, members, node);
1706
+ if (__rspack_external__babel_types_6e8337dd.isCallExpression(node) && __rspack_external__babel_types_6e8337dd.isIdentifier(node.callee, {
1707
+ name: 'require'
1708
+ }) && !(factsOf(module).references.has(node.callee) ? factsOf(module).references.get(node.callee) : factsOf(module).scope.getBinding('require')) && 1 === node.arguments.length && __rspack_external__babel_types_6e8337dd.isStringLiteral(node.arguments[0])) return namespaceValues(module, node.arguments[0].value, members, node);
1709
+ if (__rspack_external__babel_types_6e8337dd.isCallExpression(node) || __rspack_external__babel_types_6e8337dd.isOptionalCallExpression(node)) return callValues(module, node, members);
1710
+ if (__rspack_external__babel_types_6e8337dd.isConditionalExpression(node)) return [
1711
+ ...values(module, node.consequent, members),
1712
+ ...values(module, node.alternate, members)
1713
+ ];
1714
+ if (__rspack_external__babel_types_6e8337dd.isLogicalExpression(node)) return [
1715
+ ...values(module, node.left, members),
1716
+ ...values(module, node.right, members)
1717
+ ];
1718
+ if (__rspack_external__babel_types_6e8337dd.isAwaitExpression(node)) return values(module, node.argument, members);
1719
+ if (__rspack_external__babel_types_6e8337dd.isAssignmentExpression(node)) return '=' === node.operator ? values(module, node.right, members) : [
1720
+ '&&=',
1721
+ '||=',
1722
+ '??='
1723
+ ].includes(node.operator) ? [
1724
+ ...values(module, node.left, members),
1725
+ ...values(module, node.right, members)
1726
+ ] : unresolved(module, node);
1727
+ if (__rspack_external__babel_types_6e8337dd.isSequenceExpression(node)) return values(module, node.expressions.at(-1), members);
1728
+ if (0 === members.length) return [
1729
+ {
1730
+ kind: 'node',
1731
+ node,
1732
+ module
1733
+ }
1734
+ ];
1735
+ if (__rspack_external__babel_types_6e8337dd.isObjectExpression(node)) return propertyValues(module, node, members);
1736
+ if (__rspack_external__babel_types_6e8337dd.isClassExpression(node) || __rspack_external__babel_types_6e8337dd.isClassDeclaration(node)) return staticMemberValues(module, node, members);
1737
+ const [index, ...rest] = members;
1738
+ const element = __rspack_external__babel_types_6e8337dd.isArrayExpression(node) && void 0 !== index && /^\d+$/u.test(index) ? node.elements.slice(0, Number(index) + 1) : void 0;
1739
+ return element && element.length === Number(index) + 1 && !element.some((item)=>__rspack_external__babel_types_6e8337dd.isSpreadElement(item)) && element.at(-1) ? values(module, element.at(-1), rest) : unresolved(module, node);
1740
+ } finally{
1741
+ active.delete(key);
1742
+ }
1743
+ };
1744
+ const reachable = (module, expression)=>{
1745
+ const found = [];
1746
+ const walked = new Set();
1747
+ const pending = [
1748
+ [
1749
+ module,
1750
+ expression
1751
+ ]
1752
+ ];
1753
+ const walk = (owner, node)=>pending.push([
1754
+ owner,
1755
+ node
1756
+ ]);
1757
+ for(let next = pending.pop(); next; next = pending.pop()){
1758
+ const [owner, node] = next;
1759
+ const key = `${owner.path}:${node.start}:${node.end}:${node.type}`;
1760
+ if (walked.has(key)) continue;
1761
+ walked.add(key);
1762
+ if (walked.size > MAX_LOOKUPS) {
1763
+ found.push(...unresolved(owner, node));
1764
+ continue;
1765
+ }
1766
+ const reference = (__rspack_external__babel_types_6e8337dd.isIdentifier(node) || __rspack_external__babel_types_6e8337dd.isJSXIdentifier(node)) && factsOf(owner).references.has(node) || __rspack_external__babel_types_6e8337dd.isJSXMemberExpression(node) || __rspack_external__babel_types_6e8337dd.isMemberExpression(node) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(node);
1767
+ const call = __rspack_external__babel_types_6e8337dd.isCallExpression(node) || __rspack_external__babel_types_6e8337dd.isOptionalCallExpression(node);
1768
+ if (reference || call) {
1769
+ steps = 0;
1770
+ const evaluated = values(owner, node, []);
1771
+ for (const value of evaluated)if ('node' !== value.kind) found.push(value);
1772
+ else if (value.node !== node) walk(value.module, value.node);
1773
+ if (reference) {
1774
+ if ((__rspack_external__babel_types_6e8337dd.isMemberExpression(node) || __rspack_external__babel_types_6e8337dd.isOptionalMemberExpression(node) || __rspack_external__babel_types_6e8337dd.isJSXMemberExpression(node)) && evaluated.some((value)=>'unresolved' === value.kind)) {
1775
+ walk(owner, node.object);
1776
+ if (!__rspack_external__babel_types_6e8337dd.isJSXMemberExpression(node) && node.computed) walk(owner, node.property);
1777
+ }
1778
+ continue;
1779
+ }
1780
+ }
1781
+ if (!(__rspack_external__babel_types_6e8337dd.isIdentifier(node) || node.type.startsWith('TS') && !__rspack_external__babel_types_6e8337dd.isExpression(node))) for (const field of __rspack_external__babel_types_6e8337dd.VISITOR_KEYS[node.type] ?? []){
1782
+ if (/^(?:typeAnnotation|returnType|typeParameters|typeArguments|superTypeParameters)$/u.test(field)) continue;
1783
+ const child = node[field];
1784
+ for (const item of Array.isArray(child) ? child : [
1785
+ child
1786
+ ])if (__rspack_external__babel_types_6e8337dd.isNode(item)) walk(owner, item);
1787
+ }
1788
+ }
1789
+ return found;
1790
+ };
1791
+ return {
1792
+ values,
1793
+ reachable
1794
+ };
1795
+ };
1796
+ return {
1797
+ module: (filePath)=>load(filePath),
1798
+ resolve: (module, name, scope)=>resolveBinding(module, name, scope, [], new Set()),
1799
+ resolveReference,
1800
+ isUnboundReference,
1801
+ evaluate: (module, expression)=>evaluation(false).values(module, expression, []),
1802
+ reachable: (module, expression)=>evaluation(true).reachable(module, expression)
1803
+ };
1804
+ }
1805
+ export { createModuleGraph, exportedConst, localConst, propertyName };