diff --git a/e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx b/e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx index 338bf63d9ad..ad8f8789678 100644 --- a/e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx +++ b/e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx @@ -2,10 +2,6 @@ import { useQuery } from '@tanstack/solid-query' import { ErrorComponent, Link, createFileRoute } from '@tanstack/solid-router' import { postQueryOptions } from '~/utils/posts' -export function PostErrorComponent({ error }: { error: any }) { - return -} - export const Route = createFileRoute('/posts/$postId')({ loader: async ({ context, params }) => { await context.queryClient.ensureQueryData(postQueryOptions(params.postId)) @@ -14,6 +10,10 @@ export const Route = createFileRoute('/posts/$postId')({ component: PostComponent, }) +export function PostErrorComponent({ error }: { error: any }) { + return +} + function PostComponent() { const params = Route.useParams() const postQuery = useQuery(() => postQueryOptions(params().postId)) diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts index 5c2da5d3907..9f2ae7ab68f 100644 --- a/packages/router-plugin/src/core/code-splitter/compilers.ts +++ b/packages/router-plugin/src/core/code-splitter/compilers.ts @@ -264,6 +264,18 @@ export function compileCodeSplitReferenceRoute( if (shouldSplit) { removeIdentifierLiteral(path, value) + } else if ( + opts.targetFramework === 'solid' && + isExported + ) { + // For Solid, wrap exported component references in getter functions + // to avoid temporal dead zone issues with export function declarations + const componentName = value.name + prop.value = template.expression( + `() => ${componentName}`, + )() + modified = true + return } } @@ -440,7 +452,11 @@ export function compileCodeSplitReferenceRoute( console.warn(warningMessage) // append this warning to the file using a template - if (process.env.NODE_ENV !== 'production') { + // Skip inline warning for Solid as it interferes with module evaluation order + if ( + process.env.NODE_ENV !== 'production' && + opts.targetFramework !== 'solid' + ) { const warningTemplate = template.statement( `console.warn(${JSON.stringify(warningMessage)})`, )()