Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ErrorComponent error={error} />
}

export const Route = createFileRoute('/posts/$postId')({
loader: async ({ context, params }) => {
await context.queryClient.ensureQueryData(postQueryOptions(params.postId))
Expand All @@ -14,6 +10,10 @@ export const Route = createFileRoute('/posts/$postId')({
component: PostComponent,
})

export function PostErrorComponent({ error }: { error: any }) {
return <ErrorComponent error={error} />
}

function PostComponent() {
const params = Route.useParams()
const postQuery = useQuery(() => postQueryOptions(params().postId))
Expand Down
19 changes: 17 additions & 2 deletions packages/router-plugin/src/core/code-splitter/compilers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,21 @@ 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
}
}

if (!shouldSplit) {
if (!shouldSplit && opts.targetFramework !== 'solid') {
return
}

Expand Down Expand Up @@ -440,7 +451,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)})`,
)()
Expand Down
Loading