@tanstack/router-plugin 1.168.5 → 1.168.7

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 (44) hide show
  1. package/dist/cjs/core/code-splitter/compilers.cjs +32 -233
  2. package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
  3. package/dist/cjs/core/code-splitter/compilers.d.cts +2 -57
  4. package/dist/cjs/core/code-splitter/plugins.d.cts +1 -0
  5. package/dist/cjs/core/config.cjs +1 -1
  6. package/dist/cjs/core/config.cjs.map +1 -1
  7. package/dist/cjs/core/config.d.cts +44 -163
  8. package/dist/cjs/core/hmr/handle-route-update.cjs +17 -18
  9. package/dist/cjs/core/hmr/handle-route-update.cjs.map +1 -1
  10. package/dist/cjs/core/router-code-splitter-plugin.cjs +5 -6
  11. package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
  12. package/dist/cjs/esbuild.d.cts +26 -26
  13. package/dist/cjs/index.cjs +2 -0
  14. package/dist/cjs/index.d.cts +2 -0
  15. package/dist/cjs/vite.d.cts +26 -26
  16. package/dist/esm/core/code-splitter/compilers.d.ts +2 -57
  17. package/dist/esm/core/code-splitter/compilers.js +15 -216
  18. package/dist/esm/core/code-splitter/compilers.js.map +1 -1
  19. package/dist/esm/core/code-splitter/plugins.d.ts +1 -0
  20. package/dist/esm/core/config.d.ts +44 -163
  21. package/dist/esm/core/config.js +1 -1
  22. package/dist/esm/core/config.js.map +1 -1
  23. package/dist/esm/core/hmr/handle-route-update.js +17 -18
  24. package/dist/esm/core/hmr/handle-route-update.js.map +1 -1
  25. package/dist/esm/core/router-code-splitter-plugin.js +5 -6
  26. package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
  27. package/dist/esm/esbuild.d.ts +26 -26
  28. package/dist/esm/index.d.ts +2 -0
  29. package/dist/esm/index.js +2 -1
  30. package/dist/esm/vite.d.ts +26 -26
  31. package/package.json +7 -7
  32. package/src/core/code-splitter/compilers.ts +51 -411
  33. package/src/core/code-splitter/plugins.ts +3 -0
  34. package/src/core/config.ts +12 -1
  35. package/src/core/hmr/handle-route-update.ts +30 -35
  36. package/src/core/router-code-splitter-plugin.ts +11 -9
  37. package/src/index.ts +5 -0
  38. package/dist/cjs/core/code-splitter/path-ids.cjs +0 -32
  39. package/dist/cjs/core/code-splitter/path-ids.cjs.map +0 -1
  40. package/dist/cjs/core/code-splitter/path-ids.d.cts +0 -2
  41. package/dist/esm/core/code-splitter/path-ids.d.ts +0 -2
  42. package/dist/esm/core/code-splitter/path-ids.js +0 -31
  43. package/dist/esm/core/code-splitter/path-ids.js.map +0 -1
  44. package/src/core/code-splitter/path-ids.ts +0 -39
@@ -2,7 +2,6 @@ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_constants = require("../constants.cjs");
3
3
  const require_select_adapter = require("../hmr/select-adapter.cjs");
4
4
  const require_utils = require("../utils.cjs");
5
- const require_path_ids = require("./path-ids.cjs");
6
5
  const require_framework_options = require("./framework-options.cjs");
7
6
  let _tanstack_router_utils = require("@tanstack/router-utils");
8
7
  let _babel_types = require("@babel/types");
@@ -53,7 +52,7 @@ var KNOWN_SPLIT_ROUTE_IDENTS = [...SPLIT_NODES_CONFIG.keys()];
53
52
  function addSplitSearchParamToFilename(filename, grouping) {
54
53
  const [bareFilename] = filename.split("?");
55
54
  const params = new URLSearchParams();
56
- params.append(require_constants.tsrSplit, require_path_ids.createIdentifier(grouping));
55
+ params.append(require_constants.tsrSplit, (0, _tanstack_router_utils.createIdentifier)(grouping));
57
56
  return `${bareFilename}?${params.toString()}`;
58
57
  }
59
58
  function removeSplitSearchParamFromFilename(filename) {
@@ -68,69 +67,6 @@ var splittableCreateRouteFns = ["createFileRoute"];
68
67
  var unsplittableCreateRouteFns = ["createRootRoute", "createRootRouteWithContext"];
69
68
  var allCreateRouteFns = [...splittableCreateRouteFns, ...unsplittableCreateRouteFns];
70
69
  /**
71
- * Recursively walk an AST node and collect referenced identifier-like names.
72
- * Much cheaper than babel.traverse — no path/scope overhead.
73
- *
74
- * Notes:
75
- * - Uses @babel/types `isReferenced` to avoid collecting non-references like
76
- * object keys, member expression properties, or binding identifiers.
77
- * - Also handles JSX identifiers for component references.
78
- */
79
- function collectIdentifiersFromNode(node) {
80
- const ids = /* @__PURE__ */ new Set();
81
- (function walk(n, parent, grandparent, parentKey) {
82
- if (!n) return;
83
- if (_babel_types.isIdentifier(n)) {
84
- if (!parent || _babel_types.isReferenced(n, parent, grandparent)) ids.add(n.name);
85
- return;
86
- }
87
- if (_babel_types.isJSXIdentifier(n)) {
88
- if (parent && _babel_types.isJSXAttribute(parent) && parentKey === "name") return;
89
- if (parent && _babel_types.isJSXMemberExpression(parent) && parentKey === "property") return;
90
- const first = n.name[0];
91
- if (first && first === first.toLowerCase()) return;
92
- ids.add(n.name);
93
- return;
94
- }
95
- for (const key of _babel_types.VISITOR_KEYS[n.type] || []) {
96
- const child = n[key];
97
- if (Array.isArray(child)) {
98
- for (const c of child) if (c && typeof c.type === "string") walk(c, n, parent, key);
99
- } else if (child && typeof child.type === "string") walk(child, n, parent, key);
100
- }
101
- })(node);
102
- return ids;
103
- }
104
- /**
105
- * Build a map from binding name → declaration AST node for all
106
- * locally-declared module-level bindings. Built once, O(1) lookup.
107
- */
108
- function buildDeclarationMap(ast) {
109
- const map = /* @__PURE__ */ new Map();
110
- for (const stmt of ast.program.body) {
111
- const decl = _babel_types.isExportNamedDeclaration(stmt) && stmt.declaration ? stmt.declaration : stmt;
112
- if (_babel_types.isVariableDeclaration(decl)) for (const declarator of decl.declarations) for (const name of collectIdentifiersFromPattern(declarator.id)) map.set(name, declarator);
113
- else if (_babel_types.isFunctionDeclaration(decl) && decl.id) map.set(decl.id.name, decl);
114
- else if (_babel_types.isClassDeclaration(decl) && decl.id) map.set(decl.id.name, decl);
115
- }
116
- return map;
117
- }
118
- /**
119
- * Build a dependency graph: for each local binding, the set of other local
120
- * bindings its declaration references. Built once via simple node walking.
121
- */
122
- function buildDependencyGraph(declMap, localBindings) {
123
- const graph = /* @__PURE__ */ new Map();
124
- for (const [name, declNode] of declMap) {
125
- if (!localBindings.has(name)) continue;
126
- const allIds = collectIdentifiersFromNode(declNode);
127
- const deps = /* @__PURE__ */ new Set();
128
- for (const id of allIds) if (id !== name && localBindings.has(id)) deps.add(id);
129
- graph.set(name, deps);
130
- }
131
- return graph;
132
- }
133
- /**
134
70
  * Computes module-level bindings that are shared between split and non-split
135
71
  * route properties. These bindings need to be extracted into a shared virtual
136
72
  * module to avoid double-initialization.
@@ -142,7 +78,7 @@ function buildDependencyGraph(declMap, localBindings) {
142
78
  function computeSharedBindings(opts) {
143
79
  const ast = (0, _tanstack_router_utils.parseAst)(opts);
144
80
  const localModuleLevelBindings = /* @__PURE__ */ new Set();
145
- for (const node of ast.program.body) collectLocalBindingsFromStatement(node, localModuleLevelBindings);
81
+ for (const node of ast.program.body) (0, _tanstack_router_utils.collectLocalBindingsFromStatement)(node, localModuleLevelBindings);
146
82
  localModuleLevelBindings.delete("Route");
147
83
  if (localModuleLevelBindings.size === 0) return /* @__PURE__ */ new Set();
148
84
  function findIndexForSplitNode(str) {
@@ -177,11 +113,11 @@ function computeSharedBindings(opts) {
177
113
  else splitGroupsPresent.add(groupIndex);
178
114
  }
179
115
  if (!hasNonSplit && splitGroupsPresent.size < 2) return /* @__PURE__ */ new Set();
180
- const declMap = buildDeclarationMap(ast);
181
- const depGraph = buildDependencyGraph(declMap, localModuleLevelBindings);
116
+ const declMap = (0, _tanstack_router_utils.buildDeclarationMap)(ast);
117
+ const depGraph = (0, _tanstack_router_utils.buildDependencyGraph)(declMap, localModuleLevelBindings);
182
118
  const allLocalBindings = new Set(localModuleLevelBindings);
183
119
  allLocalBindings.add("Route");
184
- const fullDepGraph = buildDependencyGraph(declMap, allLocalBindings);
120
+ const fullDepGraph = (0, _tanstack_router_utils.buildDependencyGraph)(declMap, allLocalBindings);
185
121
  const refsByGroup = /* @__PURE__ */ new Map();
186
122
  for (const prop of routeOptions.properties) {
187
123
  if (!_babel_types.isObjectProperty(prop)) continue;
@@ -189,9 +125,9 @@ function computeSharedBindings(opts) {
189
125
  if (!key) continue;
190
126
  if (key === "codeSplitGroupings") continue;
191
127
  const groupIndex = findIndexForSplitNode(key);
192
- const directRefs = collectModuleLevelRefsFromNode(prop.value, localModuleLevelBindings);
128
+ const directRefs = (0, _tanstack_router_utils.collectModuleLevelRefsFromNode)(prop.value, localModuleLevelBindings);
193
129
  const allRefs = new Set(directRefs);
194
- expandTransitively(allRefs, depGraph);
130
+ (0, _tanstack_router_utils.expandTransitively)(allRefs, depGraph);
195
131
  for (const ref of allRefs) {
196
132
  let groups = refsByGroup.get(ref);
197
133
  if (!groups) {
@@ -203,120 +139,13 @@ function computeSharedBindings(opts) {
203
139
  }
204
140
  const shared = /* @__PURE__ */ new Set();
205
141
  for (const [name, groups] of refsByGroup) if (groups.size >= 2) shared.add(name);
206
- expandSharedDestructuredDeclarators(ast, refsByGroup, shared);
142
+ (0, _tanstack_router_utils.expandSharedDestructuredDeclarators)(ast, refsByGroup, shared);
207
143
  if (shared.size === 0) return shared;
208
- expandDestructuredDeclarations(ast, shared);
209
- removeBindingsDependingOnRoute(shared, fullDepGraph);
144
+ (0, _tanstack_router_utils.expandDestructuredDeclarations)(ast, shared);
145
+ (0, _tanstack_router_utils.removeBindingsTransitivelyDependingOn)(shared, fullDepGraph, ["Route"]);
210
146
  return shared;
211
147
  }
212
148
  /**
213
- * If bindings from the same destructured declarator are referenced by
214
- * different groups, mark all bindings from that declarator as shared.
215
- */
216
- function expandSharedDestructuredDeclarators(ast, refsByGroup, shared) {
217
- for (const stmt of ast.program.body) {
218
- const decl = _babel_types.isExportNamedDeclaration(stmt) && stmt.declaration ? stmt.declaration : stmt;
219
- if (!_babel_types.isVariableDeclaration(decl)) continue;
220
- for (const declarator of decl.declarations) {
221
- if (!_babel_types.isObjectPattern(declarator.id) && !_babel_types.isArrayPattern(declarator.id)) continue;
222
- const names = collectIdentifiersFromPattern(declarator.id);
223
- const usedGroups = /* @__PURE__ */ new Set();
224
- for (const name of names) {
225
- const groups = refsByGroup.get(name);
226
- if (!groups) continue;
227
- for (const g of groups) usedGroups.add(g);
228
- }
229
- if (usedGroups.size >= 2) for (const name of names) shared.add(name);
230
- }
231
- }
232
- }
233
- /**
234
- * Collect locally-declared module-level binding names from a statement.
235
- * Pure node inspection, no traversal.
236
- */
237
- function collectLocalBindingsFromStatement(node, bindings) {
238
- const decl = _babel_types.isExportNamedDeclaration(node) && node.declaration ? node.declaration : node;
239
- if (_babel_types.isVariableDeclaration(decl)) for (const declarator of decl.declarations) for (const name of collectIdentifiersFromPattern(declarator.id)) bindings.add(name);
240
- else if (_babel_types.isFunctionDeclaration(decl) && decl.id) bindings.add(decl.id.name);
241
- else if (_babel_types.isClassDeclaration(decl) && decl.id) bindings.add(decl.id.name);
242
- }
243
- /**
244
- * Collect direct module-level binding names referenced from a given AST node.
245
- * Uses a simple recursive walk instead of babel.traverse.
246
- */
247
- function collectModuleLevelRefsFromNode(node, localModuleLevelBindings) {
248
- const allIds = collectIdentifiersFromNode(node);
249
- const refs = /* @__PURE__ */ new Set();
250
- for (const name of allIds) if (localModuleLevelBindings.has(name)) refs.add(name);
251
- return refs;
252
- }
253
- /**
254
- * Expand the shared set transitively using a prebuilt dependency graph.
255
- * No AST traversals — pure graph BFS.
256
- */
257
- function expandTransitively(shared, depGraph) {
258
- const queue = [...shared];
259
- const visited = /* @__PURE__ */ new Set();
260
- while (queue.length > 0) {
261
- const name = queue.pop();
262
- if (visited.has(name)) continue;
263
- visited.add(name);
264
- const deps = depGraph.get(name);
265
- if (!deps) continue;
266
- for (const dep of deps) if (!shared.has(dep)) {
267
- shared.add(dep);
268
- queue.push(dep);
269
- }
270
- }
271
- }
272
- /**
273
- * Remove any bindings from `shared` that transitively depend on `Route`.
274
- * The Route singleton must remain in the reference file; if a shared binding
275
- * references it (directly or transitively), extracting that binding would
276
- * duplicate Route in the shared module.
277
- *
278
- * Uses `depGraph` which must include `Route` as a node so the dependency
279
- * chain is visible.
280
- */
281
- function removeBindingsDependingOnRoute(shared, depGraph) {
282
- const reverseGraph = /* @__PURE__ */ new Map();
283
- for (const [name, deps] of depGraph) for (const dep of deps) {
284
- let parents = reverseGraph.get(dep);
285
- if (!parents) {
286
- parents = /* @__PURE__ */ new Set();
287
- reverseGraph.set(dep, parents);
288
- }
289
- parents.add(name);
290
- }
291
- const visited = /* @__PURE__ */ new Set();
292
- const queue = ["Route"];
293
- while (queue.length > 0) {
294
- const cur = queue.pop();
295
- if (visited.has(cur)) continue;
296
- visited.add(cur);
297
- const parents = reverseGraph.get(cur);
298
- if (!parents) continue;
299
- for (const parent of parents) if (!visited.has(parent)) queue.push(parent);
300
- }
301
- for (const name of [...shared]) if (visited.has(name)) shared.delete(name);
302
- }
303
- /**
304
- * If any binding from a destructured declaration is shared,
305
- * ensure all bindings from that same declaration are also shared.
306
- * Pure node inspection of program.body, no traversal.
307
- */
308
- function expandDestructuredDeclarations(ast, shared) {
309
- for (const stmt of ast.program.body) {
310
- const decl = _babel_types.isExportNamedDeclaration(stmt) && stmt.declaration ? stmt.declaration : stmt;
311
- if (!_babel_types.isVariableDeclaration(decl)) continue;
312
- for (const declarator of decl.declarations) {
313
- if (!_babel_types.isObjectPattern(declarator.id) && !_babel_types.isArrayPattern(declarator.id)) continue;
314
- const names = collectIdentifiersFromPattern(declarator.id);
315
- if (names.some((n) => shared.has(n))) for (const n of names) shared.add(n);
316
- }
317
- }
318
- }
319
- /**
320
149
  * Find which shared bindings are user-exported in the original source.
321
150
  * These need to be re-exported from the shared module.
322
151
  */
@@ -325,7 +154,7 @@ function findExportedSharedBindings(ast, sharedBindings) {
325
154
  for (const stmt of ast.program.body) {
326
155
  if (!_babel_types.isExportNamedDeclaration(stmt) || !stmt.declaration) continue;
327
156
  if (_babel_types.isVariableDeclaration(stmt.declaration)) {
328
- for (const decl of stmt.declaration.declarations) for (const name of collectIdentifiersFromPattern(decl.id)) if (sharedBindings.has(name)) exported.add(name);
157
+ for (const decl of stmt.declaration.declarations) for (const name of (0, _tanstack_router_utils.collectIdentifiersFromPattern)(decl.id)) if (sharedBindings.has(name)) exported.add(name);
329
158
  } else if (_babel_types.isFunctionDeclaration(stmt.declaration) && stmt.declaration.id) {
330
159
  if (sharedBindings.has(stmt.declaration.id.name)) exported.add(stmt.declaration.id.name);
331
160
  } else if (_babel_types.isClassDeclaration(stmt.declaration) && stmt.declaration.id) {
@@ -344,7 +173,7 @@ function removeSharedDeclarations(ast, sharedBindings) {
344
173
  const decl = _babel_types.isExportNamedDeclaration(stmt) && stmt.declaration ? stmt.declaration : stmt;
345
174
  if (_babel_types.isVariableDeclaration(decl)) {
346
175
  decl.declarations = decl.declarations.filter((declarator) => {
347
- return !collectIdentifiersFromPattern(declarator.id).every((n) => sharedBindings.has(n));
176
+ return !(0, _tanstack_router_utils.collectIdentifiersFromPattern)(declarator.id).every((n) => sharedBindings.has(n));
348
177
  });
349
178
  if (decl.declarations.length === 0) return false;
350
179
  } else if (_babel_types.isFunctionDeclaration(decl) && decl.id) {
@@ -412,6 +241,16 @@ function compileCodeSplitReferenceRoute(opts) {
412
241
  };
413
242
  if (_babel_types.isObjectExpression(routeOptions)) {
414
243
  const insertionPath = path.getStatementParent() ?? path;
244
+ opts.compilerPlugins?.forEach((plugin) => {
245
+ if ((plugin.onRouteOptions?.({
246
+ programPath,
247
+ callExpressionPath: path,
248
+ insertionPath,
249
+ routeOptions,
250
+ createRouteFn,
251
+ opts
252
+ }))?.modified) modified = true;
253
+ });
415
254
  if (opts.deleteNodes && opts.deleteNodes.size > 0) routeOptions.properties = routeOptions.properties.filter((prop) => {
416
255
  if (_babel_types.isObjectProperty(prop)) {
417
256
  const key = require_utils.getObjectPropertyKeyName(prop);
@@ -661,8 +500,8 @@ function compileCodeSplitVirtualRoute(opts) {
661
500
  if (_babel_types.isVariableDeclaration(path.node.declaration)) {
662
501
  const specifiers = path.node.declaration.declarations.flatMap((decl) => {
663
502
  if (_babel_types.isIdentifier(decl.id)) return [_babel_types.importSpecifier(_babel_types.identifier(decl.id.name), _babel_types.identifier(decl.id.name))];
664
- if (_babel_types.isObjectPattern(decl.id)) return collectIdentifiersFromPattern(decl.id).map((name) => _babel_types.importSpecifier(_babel_types.identifier(name), _babel_types.identifier(name)));
665
- if (_babel_types.isArrayPattern(decl.id)) return collectIdentifiersFromPattern(decl.id).map((name) => _babel_types.importSpecifier(_babel_types.identifier(name), _babel_types.identifier(name)));
503
+ if (_babel_types.isObjectPattern(decl.id)) return (0, _tanstack_router_utils.collectIdentifiersFromPattern)(decl.id).map((name) => _babel_types.importSpecifier(_babel_types.identifier(name), _babel_types.identifier(name)));
504
+ if (_babel_types.isArrayPattern(decl.id)) return (0, _tanstack_router_utils.collectIdentifiersFromPattern)(decl.id).map((name) => _babel_types.importSpecifier(_babel_types.identifier(name), _babel_types.identifier(name)));
666
505
  return [];
667
506
  });
668
507
  if (specifiers.length === 0) {
@@ -687,14 +526,7 @@ function compileCodeSplitVirtualRoute(opts) {
687
526
  }
688
527
  } } });
689
528
  (0, _tanstack_router_utils.deadCodeElimination)(ast, refIdents);
690
- {
691
- const locallyBound = /* @__PURE__ */ new Set();
692
- for (const stmt of ast.program.body) collectLocalBindingsFromStatement(stmt, locallyBound);
693
- ast.program.body = ast.program.body.filter((stmt) => {
694
- if (!_babel_types.isExpressionStatement(stmt)) return true;
695
- return [...collectIdentifiersFromNode(stmt)].some((name) => locallyBound.has(name));
696
- });
697
- }
529
+ (0, _tanstack_router_utils.stripUnreferencedTopLevelExpressionStatements)(ast);
698
530
  if (ast.program.body.length === 0) ast.program.directives = [];
699
531
  const result = (0, _tanstack_router_utils.generateFromAst)(ast, {
700
532
  sourceMaps: true,
@@ -713,30 +545,14 @@ function compileCodeSplitSharedRoute(opts) {
713
545
  const ast = (0, _tanstack_router_utils.parseAst)(opts);
714
546
  const refIdents = (0, _tanstack_router_utils.findReferencedIdentifiers)(ast);
715
547
  const localBindings = /* @__PURE__ */ new Set();
716
- for (const node of ast.program.body) collectLocalBindingsFromStatement(node, localBindings);
548
+ for (const node of ast.program.body) (0, _tanstack_router_utils.collectLocalBindingsFromStatement)(node, localBindings);
717
549
  localBindings.delete("Route");
718
- const depGraph = buildDependencyGraph(buildDeclarationMap(ast), localBindings);
550
+ const depGraph = (0, _tanstack_router_utils.buildDependencyGraph)((0, _tanstack_router_utils.buildDeclarationMap)(ast), localBindings);
719
551
  const keepBindings = new Set(opts.sharedBindings);
720
552
  keepBindings.delete("Route");
721
- expandTransitively(keepBindings, depGraph);
722
- ast.program.body = ast.program.body.filter((stmt) => {
723
- if (_babel_types.isImportDeclaration(stmt)) return true;
724
- const decl = _babel_types.isExportNamedDeclaration(stmt) && stmt.declaration ? stmt.declaration : stmt;
725
- if (_babel_types.isVariableDeclaration(decl)) {
726
- decl.declarations = decl.declarations.filter((declarator) => {
727
- return collectIdentifiersFromPattern(declarator.id).some((n) => keepBindings.has(n));
728
- });
729
- if (decl.declarations.length === 0) return false;
730
- if (_babel_types.isExportNamedDeclaration(stmt) && stmt.declaration) return true;
731
- return true;
732
- } else if (_babel_types.isFunctionDeclaration(decl) && decl.id) return keepBindings.has(decl.id.name);
733
- else if (_babel_types.isClassDeclaration(decl) && decl.id) return keepBindings.has(decl.id.name);
734
- return false;
735
- });
736
- ast.program.body = ast.program.body.map((stmt) => {
737
- if (_babel_types.isExportNamedDeclaration(stmt) && stmt.declaration) return stmt.declaration;
738
- return stmt;
739
- });
553
+ (0, _tanstack_router_utils.expandTransitively)(keepBindings, depGraph);
554
+ (0, _tanstack_router_utils.retainModuleLevelDeclarations)(ast, keepBindings);
555
+ (0, _tanstack_router_utils.unwrapExportedDeclarations)(ast);
740
556
  const exportSpecifiers = [...opts.sharedBindings].sort((a, b) => a.localeCompare(b)).map((name) => _babel_types.exportSpecifier(_babel_types.identifier(name), _babel_types.identifier(name)));
741
557
  if (exportSpecifiers.length > 0) {
742
558
  const exportDecl = _babel_types.exportNamedDeclaration(null, exportSpecifiers);
@@ -820,23 +636,6 @@ function getImportSpecifierAndPathFromLocalName(programPath, name) {
820
636
  path
821
637
  };
822
638
  }
823
- /**
824
- * Recursively collects all identifier names from a destructuring pattern
825
- * (ObjectPattern, ArrayPattern, AssignmentPattern, RestElement).
826
- */
827
- function collectIdentifiersFromPattern(node) {
828
- if (!node) return [];
829
- if (_babel_types.isIdentifier(node)) return [node.name];
830
- if (_babel_types.isAssignmentPattern(node)) return collectIdentifiersFromPattern(node.left);
831
- if (_babel_types.isRestElement(node)) return collectIdentifiersFromPattern(node.argument);
832
- if (_babel_types.isObjectPattern(node)) return node.properties.flatMap((prop) => {
833
- if (_babel_types.isObjectProperty(prop)) return collectIdentifiersFromPattern(prop.value);
834
- if (_babel_types.isRestElement(prop)) return collectIdentifiersFromPattern(prop.argument);
835
- return [];
836
- });
837
- if (_babel_types.isArrayPattern(node)) return node.elements.flatMap((element) => collectIdentifiersFromPattern(element));
838
- return [];
839
- }
840
639
  function resolveIdentifier(path, node) {
841
640
  if (_babel_types.isIdentifier(node)) {
842
641
  const binding = path.scope.getBinding(node.name);
@@ -876,7 +675,7 @@ function hasExport(ast, node) {
876
675
  if (_babel_types.isIdentifier(decl.id)) {
877
676
  if (decl.id.name === node.name) found = true;
878
677
  } else if (_babel_types.isObjectPattern(decl.id) || _babel_types.isArrayPattern(decl.id)) {
879
- if (collectIdentifiersFromPattern(decl.id).includes(node.name)) found = true;
678
+ if ((0, _tanstack_router_utils.collectIdentifiersFromPattern)(decl.id).includes(node.name)) found = true;
880
679
  }
881
680
  }
882
681
  });
@@ -913,7 +712,7 @@ function removeExports(ast, node) {
913
712
  removed = true;
914
713
  }
915
714
  } else if (_babel_types.isObjectPattern(decl.id) || _babel_types.isArrayPattern(decl.id)) {
916
- if (collectIdentifiersFromPattern(decl.id).includes(node.name)) {
715
+ if ((0, _tanstack_router_utils.collectIdentifiersFromPattern)(decl.id).includes(node.name)) {
917
716
  path.remove();
918
717
  removed = true;
919
718
  }