Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
216ec30
test(router-plugin, start-plugin-core): cover compiler output regress…
Sheraff Oct 6, 2026
ed258f9
test: require hoisting and declared bindings in compiler regression t…
Sheraff Oct 6, 2026
a1a870e
test(router-plugin, start-plugin-core, router-generator, react-start-…
Sheraff Oct 6, 2026
4c4912f
test(start-plugin-core): port Next.js server actions fixtures to crea…
Sheraff Oct 6, 2026
faa5868
test(router-plugin): port Next.js SSG and React Router route-chunk sp…
Sheraff Oct 6, 2026
28bfbb8
test(start-plugin-core, router-plugin): port Qwik optimizer extractio…
Sheraff Oct 6, 2026
a364494
test(router-plugin, start-plugin-core): cover real-world compiler shapes
Sheraff Oct 6, 2026
f6058e0
test(router-plugin, start-plugin-core): port React Compiler fixture s…
Sheraff Oct 6, 2026
4a74486
test: cover exported route variables in split chunks and JSX pragma f…
Sheraff Oct 6, 2026
4c7917c
test(start-plugin-core): port SolidStart directive and Waku allowServ…
Sheraff Oct 6, 2026
62ce5e0
test(router-plugin): port React Refresh and solid-refresh scenarios t…
Sheraff Oct 6, 2026
a7318fb
test(router-plugin, start-plugin-core, react-start-rsc): port @vitejs…
Sheraff Oct 6, 2026
e1ca059
test: port babel-dead-code-elimination and Turbopack tree-shaker scen…
Sheraff Oct 6, 2026
0909bf5
test(router-plugin): share compiler regression test helpers
Sheraff Oct 6, 2026
a97add7
test(start-plugin-core): share compiler regression test helpers
Sheraff Oct 6, 2026
c3aa005
test(react-start-rsc): share the RSC CSS transform compile helper
Sheraff Oct 6, 2026
4e0c96a
test(router-plugin): merge duplicated compiler regression tests
Sheraff Oct 6, 2026
b42763e
test(start-plugin-core): merge duplicated compiler regression tests
Sheraff Oct 6, 2026
94a67d0
test(router-generator): merge the parenthesized route call transform …
Sheraff Oct 6, 2026
9ec82ff
test(router-plugin): keep covering configs without the router plugin
Sheraff Oct 6, 2026
4a8a60d
test(router-plugin): regroup compiler regression tests by behaviour
Sheraff Oct 7, 2026
b86e646
test(start-plugin-core): regroup compiler regression tests by behaviour
Sheraff Oct 7, 2026
004085d
test(router-generator): move transform edge cases into transform.test.ts
Sheraff Oct 7, 2026
a4bc82c
test(react-start-rsc): move RSC CSS transform edge cases into rscCssT…
Sheraff Oct 7, 2026
a23021d
test: keep regression tests valid once known compiler bugs are fixed
Sheraff Oct 7, 2026
b7a76ee
test: share the build and React Refresh helpers
Sheraff Oct 7, 2026
40af4c1
test(start-plugin-core): link Hydrate chunks to their parent however …
Sheraff Oct 7, 2026
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
51 changes: 51 additions & 0 deletions packages/react-start-rsc/tests/rscCssTransform.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,55 @@ describe('RSC CSS compiler transforms', () => {
detectKindsInCode(code, 'client', { compilerTransforms }),
).toMatchInlineSnapshot(`Set {}`)
})

test('rewrites render APIs imported from @tanstack/react-start-rsc', async () => {
const code = await compileWithRscCssTransform({
code: `
import { renderServerComponent } from '@tanstack/react-start-rsc'

export const renderable = renderServerComponent(<Card />)
`,
})

expect(code).toContain(
'__tanstackStartRscCss: import.meta.viteRsc.loadCss()',
)
})

test.each([
{ wrapped: '(<Card />)', bare: '<Card />' },
{ wrapped: '<Card /> as any', bare: '<Card />' },
{ wrapped: '<Card />!', bare: '<Card />' },
{ wrapped: '(<><Card /></>) satisfies unknown', bare: '<><Card /></>' },
])(
'streams $wrapped like the bare JSX it wraps',
async ({ wrapped, bare }) => {
const compileStream = (element: string) =>
compileWithRscCssTransform({
code: `
import { renderToReadableStream } from '@tanstack/react-start/rsc'

export const stream = renderToReadableStream(${element})
`,
})

const bareCode = await compileStream(bare)
expect(bareCode).toContain('import.meta.viteRsc.loadCss()')
expect(await compileStream(wrapped)).toBe(bareCode)
},
)

test('does not stream JSX that is not the whole argument', async () => {
const code = await compileWithRscCssTransform({
code: `
import { renderToReadableStream } from '@tanstack/react-start/rsc'

export const conditional = renderToReadableStream(flag ? <A /> : <B />)
export const spread = renderToReadableStream(...args)
`,
})

expect(code).toContain('renderToReadableStream(...args)')
expect(code).not.toContain('loadCss')
})
})
119 changes: 119 additions & 0 deletions packages/router-generator/tests/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,35 @@ function makeNode(
}
}

function transformToNewRoute(source: string, node = makeNode()) {
return transform({
source,
ctx: { target: 'react', routeId: '/new', lazy: false },
node,
})
}

describe('transform', () => {
it('reads and rewrites the route constructor, id and options through parentheses', () => {
const node = makeNode()
const result = transformToNewRoute(
[
"import { createLazyFileRoute } from '@tanstack/react-router'",
"export const Route = (createLazyFileRoute)(('/old'))(({ component: Page, server: {} }))",
].join('\n'),
node,
)

expect(result).toEqual({
result: 'modified',
output: [
"import { createFileRoute } from '@tanstack/react-router'",
"export const Route = (createFileRoute)(('/new'))(({ component: Page, server: {} }))",
].join('\n'),
})
expect(node.createFileRouteProps).toEqual(new Set(['component', 'server']))
})

it('updates parenthesized route calls without changing their surrounding source', () => {
const result = transform({
source:
Expand Down Expand Up @@ -535,4 +563,95 @@ describe('transform', () => {
)
expect(result.output).not.toContain('createLazyFileRoute')
})

// The recorded option keys drive prerendering and server-only route pruning.
it('records identifier and string-literal option keys, not computed or spread ones', () => {
const node = makeNode()
const result = transformToNewRoute(
[
"import { createFileRoute } from '@tanstack/react-router'",
"export const Route = createFileRoute('/new')({ 'component': Page, [key]: load, ...rest, server: {} })",
].join('\n'),
node,
)

expect(result).toEqual({ result: 'not-modified' })
expect(node.createFileRouteProps).toEqual(new Set(['component', 'server']))
})
})

// The generator writes its output back over the user's route file, so every
// byte outside the route id and the router import must survive unchanged.
describe('transform preserves the rest of the route file', () => {
it('edits the right spans after a BOM and astral characters', () => {
const result = transformToNewRoute(
[
'\uFEFF// πŸ˜€',
"import { createLazyFileRoute } from '@tanstack/react-router'",
"import { createFileRoute } from '@tanstack/react-router'",
"export const Route = createFileRoute(/* πŸš€ */ '/old')({})",
].join('\n'),
)

expect(result).toEqual({
result: 'modified',
output: [
'\uFEFF// πŸ˜€',
"import { createFileRoute } from '@tanstack/react-router'",
"export const Route = createFileRoute(/* πŸš€ */ '/new')({})",
].join('\n'),
})
})

it.each([
{
name: 'a default import',
imports: "import Router from '@tanstack/react-router'",
expected:
"import Router, { createFileRoute } from '@tanstack/react-router'",
},
{
name: 'an aliased import of the constructor',
imports:
"import { createFileRoute as cfr } from '@tanstack/react-router'",
expected:
"import { createFileRoute as cfr, createFileRoute } from '@tanstack/react-router'",
},
{
// The constructor goes into the named import, never the namespace one.
name: 'a namespace import',
imports: [
"import * as Router from '@tanstack/react-router'",
"import { Link } from '@tanstack/react-router'",
].join('\n'),
expected: [
"import * as Router from '@tanstack/react-router'",
"import { Link, createFileRoute } from '@tanstack/react-router'",
].join('\n'),
},
])('adds the missing constructor next to $name', ({ imports, expected }) => {
const route = "export const Route = createFileRoute('/old')({})"

expect(transformToNewRoute(`${imports}\n${route}`)).toEqual({
result: 'modified',
output: `${expected}\n${route.replace('/old', '/new')}`,
})
})

it('updates only the Route declarator of a multi-declarator export', () => {
const result = transformToNewRoute(
[
"import { createFileRoute } from '@tanstack/react-router'",
"export const Route = createFileRoute('/old')({}), path = '/old'",
].join('\n'),
)

expect(result).toEqual({
result: 'modified',
output: [
"import { createFileRoute } from '@tanstack/react-router'",
"export const Route = createFileRoute('/new')({}), path = '/old'",
].join('\n'),
})
})
})
Loading
Loading