Feature request: Make routeTree.gen.ts NodeNext-compatible (and document current Bundler assumption)
#6553
jimmycallin
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
|
so how does the routetree then have to look like? please provide a complete minimal example project and the diff of the route tree file |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
routeTree.gen.tsshould be generated in a format that works with TypeScriptmoduleResolution: "NodeNext"/module: "NodeNext"(Node ESM rules). Today it effectively requiresmoduleResolution: "bundler"to avoid resolution errors, but that requirement isn’t documented anywhere. Figuring out why route loaders weren't automatically inferring types took me quite a while, due to the type errors being very vague about the issue.I understand why
"bundler"is the current default, as TanStack Start is Vite-based. However, generating NodeNext-compatible import specifiers should still work fine for bundler users, because TypeScript’s"bundler"resolution is explicitly less strict than Node’s ESM modes (e.g. it “never requires file extensions on relative paths in imports”).In NodeNext, TypeScript follows Node’s ESM rules more closely and is stricter about import specifiers (commonly: relative imports needing explicit extensions in ESM contexts). Generated output that relies on bundler-style resolution forces consumers to switch their project to
"moduleResolution": "bundler"even if they’re targeting Node ESM.This is surprising because the generator’s output has an implicit config requirement that isn’t mentioned in docs.
Proposed change
Generate
routeTree.gen.tsusing NodeNext-friendly ESM import specifiers (or provide a generator option likeresolutionMode: "nodenext" | "bundler"). I think it mainly involves avoiding relying on extensionless relative import resolution that breaks under NodeNext.Beta Was this translation helpful? Give feedback.
All reactions