Skip to content

Commit d370467

Browse files
authoredFeb 7, 2025
fix: prevent undefined module imports from parent routes (#193)
1 parent 2f64c72 commit d370467

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎packages/tanstack-react-router/src/generate.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ const generateRoutes = async () => {
7070

7171
const components = [meta._component, meta._pendingComponent, meta._errorComponent].filter(Boolean)
7272
const options = [path ? `path: '${path}'` : `id: '${id}'`, meta._loader, meta._action].filter(Boolean)
73+
const module = `const ${id} = createRoute({ getParentRoute: () => ${pid}, ${options.join(', ')} })`
7374

7475
modules.push(
75-
`const ${id} = createRoute({ getParentRoute: () => ${pid}, ${options.join(', ')} }).lazy(() =>
76+
meta._module ? `${module}.lazy(() =>
7677
${meta._module}.then((m) => createLazyRoute('${meta._path}')({ ${components.join(', ')} }))
77-
)`,
78+
)` : module,
7879
)
7980
}
8081

0 commit comments

Comments
 (0)
Please sign in to comment.