Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions e2e/start/basic/app/components/CustomMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react'

export function CustomMessage({ message }: { message: string }) {
return (
<div className="py-2">
<div className="italic">This is a custom message:</div>
<p>{message}</p>
</div>
)
}
2 changes: 2 additions & 0 deletions e2e/start/basic/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createFileRoute } from '@tanstack/react-router'
import { CustomMessage } from '~/components/CustomMessage'

export const Route = createFileRoute('/')({
component: Home,
Expand All @@ -8,6 +9,7 @@ function Home() {
return (
<div className="p-2">
<h3>Welcome Home!!!</h3>
<CustomMessage message="Hello from a custom component!" />
</div>
)
}
19 changes: 18 additions & 1 deletion packages/start-router-manifest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import tsrGetManifest from 'tsr:routes-manifest'
import { getManifest } from 'vinxi/manifest'
import type { Manifest } from '@tanstack/react-router'

function sanitizeBase(base: string) {
return base.replace(/^\/|\/$/g, '')
}

/**
* @description Returns the full, unfiltered router manifest. This includes relationships
* between routes, assets, and preloads and is NOT what you want to serialize and
Expand All @@ -18,9 +22,22 @@ export function getFullRouterManifest() {

// Always fake that HMR is ready
if (process.env.NODE_ENV === 'development') {
const CLIENT_BASE = sanitizeBase(process.env.TSS_CLIENT_BASE || '')

if (!CLIENT_BASE) {
throw new Error(
'tanstack/start-router-manifest: TSS_CLIENT_BASE must be defined in your environment for getFullRouterManifest()',
)
}

rootRoute.assets.push({
tag: 'script',
children: `window.__vite_plugin_react_preamble_installed__ = true`,
attrs: { type: 'module' },
children: `import RefreshRuntime from "/${CLIENT_BASE}/@react-refresh";
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true`,
})
}

Expand Down