@tanstack/start-server-core 1.169.4 → 1.169.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/createStartHandler.js +75 -35
- package/dist/esm/createStartHandler.js.map +1 -1
- package/dist/esm/finalManifest.d.ts +5 -5
- package/dist/esm/finalManifest.js +2 -2
- package/dist/esm/finalManifest.js.map +1 -1
- package/dist/esm/router-manifest.d.ts +2 -6
- package/dist/esm/router-manifest.js +3 -9
- package/dist/esm/router-manifest.js.map +1 -1
- package/dist/esm/transformAssetUrls.d.ts +5 -14
- package/dist/esm/transformAssetUrls.js +10 -45
- package/dist/esm/transformAssetUrls.js.map +1 -1
- package/package.json +4 -4
- package/src/createStartHandler.ts +150 -57
- package/src/finalManifest.ts +10 -15
- package/src/router-manifest.ts +7 -10
- package/src/tanstack-start.d.ts +1 -1
- package/src/transformAssetUrls.ts +10 -88
package/src/router-manifest.ts
CHANGED
|
@@ -3,8 +3,11 @@ import {
|
|
|
3
3
|
buildDevStylesUrl,
|
|
4
4
|
rootRouteId,
|
|
5
5
|
} from '@tanstack/router-core'
|
|
6
|
-
import type {
|
|
7
|
-
|
|
6
|
+
import type {
|
|
7
|
+
AnyRoute,
|
|
8
|
+
ServerManifest,
|
|
9
|
+
ServerManifestRoute,
|
|
10
|
+
} from '@tanstack/router-core'
|
|
8
11
|
|
|
9
12
|
// Pre-computed constant for dev styles URL basepath.
|
|
10
13
|
// Defaults to vite `base` (set via TSS_DEV_SSR_STYLES_BASEPATH in the plugin),
|
|
@@ -16,15 +19,12 @@ const DEV_SSR_STYLES_BASEPATH = process.env.TSS_DEV_SSR_STYLES_BASEPATH || '/'
|
|
|
16
19
|
* special assets that are needed for the client. It does not include relationships
|
|
17
20
|
* between routes or any other data that is not needed for the client.
|
|
18
21
|
*
|
|
19
|
-
* The client entry URL is returned separately so that it can be transformed
|
|
20
|
-
* (e.g. for CDN rewriting) before being embedded into the `<script>` tag.
|
|
21
|
-
*
|
|
22
22
|
* @param matchedRoutes - In dev mode, the matched routes are used to build
|
|
23
23
|
* the dev styles URL for route-scoped CSS collection.
|
|
24
24
|
*/
|
|
25
25
|
export async function getStartManifest(
|
|
26
26
|
matchedRoutes?: ReadonlyArray<AnyRoute>,
|
|
27
|
-
): Promise<
|
|
27
|
+
): Promise<ServerManifest> {
|
|
28
28
|
const { tsrStartManifest } = await import('tanstack-start-manifest:v')
|
|
29
29
|
const startManifest = tsrStartManifest()
|
|
30
30
|
let routes = startManifest.routes
|
|
@@ -85,8 +85,5 @@ export async function getStartManifest(
|
|
|
85
85
|
routes: manifestRoutes,
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
return
|
|
89
|
-
manifest: manifest as StartManifestWithClientEntry['manifest'],
|
|
90
|
-
clientEntry: startManifest.clientEntry,
|
|
91
|
-
}
|
|
88
|
+
return manifest
|
|
92
89
|
}
|
package/src/tanstack-start.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module 'tanstack-start-manifest:v' {
|
|
2
2
|
import type { ServerManifest } from '@tanstack/router-core'
|
|
3
3
|
|
|
4
|
-
export const tsrStartManifest: () => ServerManifest
|
|
4
|
+
export const tsrStartManifest: () => ServerManifest
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
declare module 'tanstack-start-route-tree:v' {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getManifestScriptFormat,
|
|
3
2
|
resolveManifestAssetLink,
|
|
4
3
|
resolveManifestCssLink,
|
|
5
4
|
} from '@tanstack/router-core'
|
|
@@ -9,8 +8,6 @@ import type {
|
|
|
9
8
|
Awaitable,
|
|
10
9
|
ManifestAssetLink,
|
|
11
10
|
ManifestCssLink,
|
|
12
|
-
ManifestScript,
|
|
13
|
-
ScriptFormat,
|
|
14
11
|
ServerManifest,
|
|
15
12
|
} from '@tanstack/router-core'
|
|
16
13
|
|
|
@@ -322,30 +319,6 @@ export function resolveTransformAssetsConfig(
|
|
|
322
319
|
}
|
|
323
320
|
}
|
|
324
321
|
|
|
325
|
-
export interface StartManifestWithClientEntry {
|
|
326
|
-
manifest: ServerManifest
|
|
327
|
-
clientEntry: string
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Builds the client entry `<script>` tag from a (possibly transformed) client
|
|
332
|
-
* entry URL.
|
|
333
|
-
*/
|
|
334
|
-
export function buildClientEntryScriptTag(
|
|
335
|
-
clientEntry: string,
|
|
336
|
-
scriptFormat: ScriptFormat = 'module',
|
|
337
|
-
crossOrigin?: AssetCrossOrigin,
|
|
338
|
-
): ManifestScript {
|
|
339
|
-
return {
|
|
340
|
-
attrs: {
|
|
341
|
-
...(scriptFormat === 'module' ? { type: 'module' } : {}),
|
|
342
|
-
async: true,
|
|
343
|
-
src: clientEntry,
|
|
344
|
-
...(crossOrigin ? { crossOrigin } : {}),
|
|
345
|
-
},
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
322
|
type AssignableManifestLink = ManifestAssetLink | ManifestCssLink
|
|
350
323
|
|
|
351
324
|
function assignManifestLink(
|
|
@@ -378,60 +351,15 @@ function assignManifestLink(
|
|
|
378
351
|
return nextLink
|
|
379
352
|
}
|
|
380
353
|
|
|
381
|
-
function appendUniqueManifestAssetLink(
|
|
382
|
-
target: Array<ManifestAssetLink> | undefined,
|
|
383
|
-
link: ManifestAssetLink,
|
|
384
|
-
) {
|
|
385
|
-
const href = typeof link === 'string' ? link : link.href
|
|
386
|
-
|
|
387
|
-
if (target) {
|
|
388
|
-
for (const item of target) {
|
|
389
|
-
if ((typeof item === 'string' ? item : item.href) === href) {
|
|
390
|
-
return target
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return [...(target ?? []), link]
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
function addClientEntryToManifest(
|
|
399
|
-
manifest: ServerManifest,
|
|
400
|
-
clientEntry: string,
|
|
401
|
-
) {
|
|
402
|
-
const rootRoute = manifest.routes.__root__ ?? {}
|
|
403
|
-
const rootScripts = rootRoute.scripts ?? []
|
|
404
|
-
const scripts = rootScripts.some(
|
|
405
|
-
(script) => script.attrs?.src === clientEntry,
|
|
406
|
-
)
|
|
407
|
-
? rootScripts
|
|
408
|
-
: [
|
|
409
|
-
...rootScripts,
|
|
410
|
-
buildClientEntryScriptTag(
|
|
411
|
-
clientEntry,
|
|
412
|
-
getManifestScriptFormat(manifest),
|
|
413
|
-
),
|
|
414
|
-
]
|
|
415
|
-
|
|
416
|
-
manifest.routes = {
|
|
417
|
-
...manifest.routes,
|
|
418
|
-
__root__: {
|
|
419
|
-
...rootRoute,
|
|
420
|
-
preloads: appendUniqueManifestAssetLink(rootRoute.preloads, clientEntry),
|
|
421
|
-
scripts,
|
|
422
|
-
},
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
354
|
export async function transformManifestAssets(
|
|
427
|
-
source:
|
|
355
|
+
source: ServerManifest,
|
|
428
356
|
transformFn: TransformAssetsFn,
|
|
429
357
|
_opts?: {
|
|
430
358
|
clone?: boolean
|
|
431
359
|
inlineCss?: boolean
|
|
432
360
|
},
|
|
433
361
|
): Promise<ServerManifest> {
|
|
434
|
-
const manifest = structuredClone(source
|
|
362
|
+
const manifest = structuredClone(source)
|
|
435
363
|
const inlineCssEnabled = _opts?.inlineCss !== false
|
|
436
364
|
const scriptTransforms = new Map<
|
|
437
365
|
string,
|
|
@@ -462,8 +390,6 @@ export async function transformManifestAssets(
|
|
|
462
390
|
)
|
|
463
391
|
}
|
|
464
392
|
|
|
465
|
-
addClientEntryToManifest(manifest, source.clientEntry)
|
|
466
|
-
|
|
467
393
|
for (const route of Object.values(manifest.routes)) {
|
|
468
394
|
if (route.preloads?.length) {
|
|
469
395
|
route.preloads = await Promise.all(
|
|
@@ -524,28 +450,24 @@ export async function transformManifestAssets(
|
|
|
524
450
|
}
|
|
525
451
|
|
|
526
452
|
/**
|
|
527
|
-
* Builds a final ServerManifest
|
|
528
|
-
*
|
|
453
|
+
* Builds a final ServerManifest without URL transforms. Used when no
|
|
454
|
+
* transformAssets option is provided.
|
|
529
455
|
*
|
|
530
456
|
* Returns a new manifest object so the cached base manifest is never mutated.
|
|
531
457
|
*/
|
|
532
|
-
export function
|
|
533
|
-
source:
|
|
458
|
+
export function buildManifest(
|
|
459
|
+
source: ServerManifest,
|
|
534
460
|
opts?: { inlineCss?: boolean },
|
|
535
461
|
): ServerManifest {
|
|
536
462
|
const manifest: ServerManifest = {
|
|
537
|
-
...(source.
|
|
538
|
-
|
|
539
|
-
:
|
|
540
|
-
...(opts?.inlineCss !== false && source.manifest.inlineCss
|
|
541
|
-
? { inlineCss: structuredClone(source.manifest.inlineCss) }
|
|
463
|
+
...(source.scriptFormat ? { scriptFormat: source.scriptFormat } : {}),
|
|
464
|
+
...(opts?.inlineCss !== false && source.inlineCss
|
|
465
|
+
? { inlineCss: structuredClone(source.inlineCss) }
|
|
542
466
|
: {}),
|
|
543
467
|
routes: {
|
|
544
|
-
...source.
|
|
468
|
+
...source.routes,
|
|
545
469
|
},
|
|
546
470
|
}
|
|
547
471
|
|
|
548
|
-
addClientEntryToManifest(manifest, source.clientEntry)
|
|
549
|
-
|
|
550
472
|
return manifest
|
|
551
473
|
}
|