Skip to content
Source
Sign inSign up
TanStack/router

fix(router-utils): cache a descriptor instead of the initializer AST node #8296

Opensverrejoh(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8296/headopened

Showing 5 changed files with 66 additions and 4 deletions (loading 2).

x
0 of 5 viewed, 5 left
6 additions and 0 deletions.changeset/start-compiler-module-info-ast-retention.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/router-utils': patch
+'@tanstack/start-plugin-core': patch
+---
+​
+Stop the Start compiler's module cache from retaining parsed ASTs. `extractModuleInfoFromAst` now stores a small summary of each binding's initializer instead of the `t.Expression` node itself, so a cached module no longer keeps the `@babel/traverse` `NodePath` and `Scope` graph of the file it came from reachable.
54 additions and 3 deletionspackages/router-utils/src/compiler-helpers.tsModified
View file
@@ -16,6 +16,15 @@
type IdentifierScopeStack = Array<IdentifierScopeFrame>
​
+/**
+ * A detached description of an expression: identifier, member access or call,
+ * and the names involved. Holding one does not keep the parsed file alive.
+ */
+export type ExpressionSummary =
+ | { type: 'identifier'; name: string }
+ | { type: 'member'; object: ExpressionSummary; property: string }
+ | { type: 'call'; callee: ExpressionSummary }
+​
export type ModuleInfoBinding =
| {
type: 'import'