@@ -81,28 +81,42 @@ export interface RendererContext {
8181 _dependencySets : Record < string , ModuleDependencies >
8282 _entrypoints : Identifier [ ]
8383 _dynamicEntrypoints : Identifier [ ]
84+ updateManifest : ( manifest : ClientManifest ) => void
8485}
8586
8687export type RenderOptions = Partial < Exclude < RendererContext , 'entrypoints' > >
8788
8889export function createRendererContext ( { clientManifest, publicPath, basedir, shouldPrefetch, shouldPreload } : RenderOptions ) : RendererContext {
89- const manifest = normalizeClientManifest ( clientManifest ! )
90- const manifestEntries = Object . entries ( manifest ) as [ Identifier , ResourceMeta ] [ ]
91-
92- return {
90+ const ctx : RendererContext = {
9391 // User customisation of output
9492 shouldPrefetch : shouldPrefetch || ( ( ) => true ) ,
9593 shouldPreload : shouldPreload || ( ( _file : string , asType : ModuleDependencies [ 'preload' ] [ string ] [ 'type' ] ) => [ 'module' , 'script' , 'style' ] . includes ( asType as string ) ) ,
9694 // Manifest
97- publicPath : ensureTrailingSlash ( publicPath || ( clientManifest as any ) . publicPath || '/' ) ,
98- clientManifest : manifest ,
95+ publicPath : ensureTrailingSlash ( publicPath || '/' ) ,
9996 basedir,
97+ clientManifest : undefined ! ,
98+ updateManifest,
10099 // Internal cache
101- _dependencies : { } ,
102- _dependencySets : { } ,
103- _entrypoints : manifestEntries . filter ( e => e [ 1 ] . isEntry ) . map ( ( [ module ] ) => module ) ,
104- _dynamicEntrypoints : manifestEntries . filter ( e => e [ 1 ] . isDynamicEntry ) . map ( ( [ module ] ) => module )
100+ _dependencies : undefined ! ,
101+ _dependencySets : undefined ! ,
102+ _entrypoints : undefined ! ,
103+ _dynamicEntrypoints : undefined !
104+ }
105+
106+ function updateManifest ( clientManifest ?: ClientManifest ) {
107+ const manifest = normalizeClientManifest ( clientManifest ! )
108+ const manifestEntries = Object . entries ( manifest ) as [ Identifier , ResourceMeta ] [ ]
109+ ctx . clientManifest = manifest
110+ ctx . _dependencies = { }
111+ ctx . _dependencySets = { }
112+ ctx . _entrypoints = manifestEntries . filter ( e => e [ 1 ] . isEntry ) . map ( ( [ module ] ) => module )
113+ ctx . _dynamicEntrypoints = manifestEntries . filter ( e => e [ 1 ] . isDynamicEntry ) . map ( ( [ module ] ) => module )
114+ ctx . publicPath = ensureTrailingSlash ( publicPath || ( clientManifest as any ) . publicPath || '/' )
105115 }
116+
117+ updateManifest ( clientManifest )
118+
119+ return ctx
106120}
107121
108122export function isLegacyClientManifest ( clientManifest : ClientManifest | LegacyClientManifest ) : clientManifest is LegacyClientManifest {
@@ -358,6 +372,7 @@ export function createRenderer (createApp: any, renderOptions: RenderOptions & {
358372 const rendererContext = createRendererContext ( renderOptions )
359373
360374 return {
375+ rendererContext,
361376 async renderToString ( ssrContext : SSRContext ) {
362377 ssrContext . _registeredComponents = ssrContext . _registeredComponents || new Set ( )
363378
0 commit comments