Skip to content

Commit 2a08f91

Browse files
committed
update latest
1 parent 715fb53 commit 2a08f91

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

e2e/react-start/custom-manifest-base/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const customHandler = defineHandlerCallback((ctx) => {
1010
return defaultStreamHandler(ctx)
1111
})
1212

13-
const fetch = createStartHandler(customHandler, {basePath: 'http://localhost:3001'})
13+
const fetch = createStartHandler(customHandler, {assetsUrl: 'http://localhost:3001'})
1414

1515
export default {
1616
fetch

packages/start-plugin-core/src/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const pageSchema = pageBaseSchema.extend({
129129
const tanstackStartOptionsSchema = z
130130
.object({
131131
srcDirectory: z.string().optional().default('src'),
132+
assetsUrl: z.string().optional(),
132133
start: z
133134
.object({
134135
entry: z.string().optional(),

packages/start-server-core/src/createStartHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getStartResponseHeaders(opts: { router: AnyRouter }) {
5353

5454
export function createStartHandler<TRegister = Register>(
5555
cb: HandlerCallback<AnyRouter>,
56-
opts: {basePath?: string} = {}
56+
opts: {assetsUrl?: string} = {}
5757
): RequestHandler<TRegister> {
5858
const ROUTER_BASEPATH = process.env.TSS_ROUTER_BASEPATH || '/'
5959
let startRoutesManifest: Manifest | null = null

packages/start-server-core/src/router-manifest.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { rootRouteId } from '@tanstack/router-core'
22
import { VIRTUAL_MODULES } from './virtual-modules'
33
import { loadVirtualModule } from './loadVirtualModule'
4-
import path from 'node:path'
54

65
/**
76
* @description Returns the router manifest that should be sent to the client.
87
* This includes only the assets and preloads for the current route and any
98
* special assets that are needed for the client. It does not include relationships
109
* between routes or any other data that is not needed for the client.
1110
*/
12-
export async function getStartManifest({basePath = '', routerBasePath}: { basePath?: string, routerBasePath?: string } = {}) {
11+
export async function getStartManifest({assetsUrl: maybeAssetsUrl, routerBasePath}: { assetsUrl?: string, routerBasePath?: string } = {}) {
1312
const { tsrStartManifest } = await loadVirtualModule(
1413
VIRTUAL_MODULES.startManifest,
1514
)
@@ -19,7 +18,9 @@ export async function getStartManifest({basePath = '', routerBasePath}: { basePa
1918
startManifest.routes[rootRouteId] || {})
2019

2120
rootRoute.assets = rootRoute.assets || []
22-
let script = `import('${basePath + "/" + startManifest.clientEntry.replace(routerBasePath ?? '', '')}')`
21+
let script =
22+
maybeAssetsUrl ?
23+
`import('${maybeAssetsUrl + "/" + startManifest.clientEntry.replace(routerBasePath ?? '', '')}')` : `import('${startManifest.clientEntry}')`
2324
if (process.env.TSS_DEV_SERVER === 'true') {
2425
const { injectedHeadScripts } = await loadVirtualModule(
2526
VIRTUAL_MODULES.injectedHeadScripts,
@@ -43,20 +44,27 @@ export async function getStartManifest({basePath = '', routerBasePath}: { basePa
4344
routes: Object.fromEntries(
4445
Object.entries(startManifest.routes).map(([k, v]) => {
4546
const { preloads, assets } = v
46-
console.log({k, preloads, assets})
47+
if (!maybeAssetsUrl) {
48+
return [
49+
k,
50+
{
51+
preloads,
52+
assets,
53+
},
54+
]
55+
}
4756
return [
4857
k,
4958
{
50-
preloads: preloads?.map((url) => basePath + '/' + url.replace(routerBasePath ?? '', '')) || [],
59+
preloads: preloads?.map((url) => maybeAssetsUrl + '/' + url.replace(routerBasePath ?? '', '')) || [],
5160
assets:
5261
assets?.map((asset) => {
53-
console.log(asset)
5462
if (asset.tag === 'link' && asset.attrs?.href) {
5563
return {
5664
...asset,
5765
attrs: {
5866
...asset.attrs,
59-
href: basePath + '/' + asset.attrs.href,
67+
href: maybeAssetsUrl + '/' + asset.attrs.href,
6068
},
6169
}
6270
}

0 commit comments

Comments
 (0)