@@ -285,27 +285,6 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
285
285
if ( updatedOpts . manifestInput ) {
286
286
opts . manifestInput = getValidManifest ( updatedOpts . manifestInput ) || null ;
287
287
}
288
- if (
289
- ! opts . manifestInput &&
290
- opts . target === 'ssr' &&
291
- opts . buildMode === 'production' &&
292
- maybeFs
293
- ) {
294
- let clientManifestPath = resolvePath ( opts . clientOutDir , Q_MANIFEST_FILENAME ) ;
295
- if ( ! ( await maybeFs . promises . stat ( clientManifestPath ) . catch ( ( ) => false ) ) ) {
296
- clientManifestPath = resolvePath ( opts . rootDir , CLIENT_OUT_DIR , Q_MANIFEST_FILENAME ) ;
297
- }
298
- try {
299
- const clientManifestStr = await maybeFs . promises . readFile ( clientManifestPath , 'utf-8' ) ;
300
- opts . manifestInput = getValidManifest ( JSON . parse ( clientManifestStr ) ) || null ;
301
- // eslint-disable-next-line no-console
302
- console . info ( 'Read client manifest from' , clientManifestPath ) ;
303
- } catch ( e ) {
304
- console . warn (
305
- `could not read Qwik client manifest ${ clientManifestPath } , ignoring. Make sure you provide it to the SSR renderer. (${ e } )`
306
- ) ;
307
- }
308
- }
309
288
310
289
if ( typeof updatedOpts . transformedModuleOutput === 'function' ) {
311
290
opts . transformedModuleOutput = updatedOpts . transformedModuleOutput ;
@@ -944,6 +923,34 @@ export const isDev = ${JSON.stringify(isDev)};
944
923
}
945
924
946
925
async function getQwikServerManifestModule ( isServer : boolean ) {
926
+ if (
927
+ ! opts . manifestInput &&
928
+ opts . target === 'ssr' &&
929
+ opts . buildMode === 'production' &&
930
+ maybeFs
931
+ ) {
932
+ const path = getPath ( ) ;
933
+ let clientManifestPath = path . resolve ( opts . clientOutDir , Q_MANIFEST_FILENAME ) ;
934
+ if ( ! ( await maybeFs . promises . stat ( clientManifestPath ) . catch ( ( ) => false ) ) ) {
935
+ clientManifestPath = path . resolve ( opts . rootDir , CLIENT_OUT_DIR , Q_MANIFEST_FILENAME ) ;
936
+ }
937
+ try {
938
+ const clientManifestStr = await maybeFs . promises . readFile ( clientManifestPath , 'utf-8' ) ;
939
+ opts . manifestInput = getValidManifest ( JSON . parse ( clientManifestStr ) ) || null ;
940
+ // eslint-disable-next-line no-console
941
+ console . info ( 'Read client manifest from' , clientManifestPath ) ;
942
+ } catch ( e ) {
943
+ console . warn (
944
+ `\n==========\n` +
945
+ `Could not read Qwik client manifest ${ clientManifestPath } .\n` +
946
+ `Make sure you provide it to the SSR renderer via the \`manifest\` argument, or define it in \`globalThis.__QWIK_MANIFEST__\` before the server bundle is loaded, or embed it in the server bundle by replacing \`globalThis.__QWIK_MANIFEST__\`.\n` +
947
+ `Without the manifest, the SSR renderer will not be able to generate event handlers.\n` +
948
+ `(${ e } )\n` +
949
+ `==========\n`
950
+ ) ;
951
+ }
952
+ }
953
+
947
954
const manifest = isServer ? opts . manifestInput : null ;
948
955
let serverManifest : ServerQwikManifest | null = null ;
949
956
if ( manifest ?. manifestHash ) {
@@ -959,7 +966,7 @@ export const isDev = ${JSON.stringify(isDev)};
959
966
} ;
960
967
}
961
968
return `// @qwik-client-manifest
962
- export const manifest = ${ JSON . stringify ( serverManifest ) } ;\n` ;
969
+ export const manifest = ${ serverManifest ? JSON . stringify ( serverManifest ) : 'globalThis.__QWIK_MANIFEST__' } ;\n` ;
963
970
}
964
971
965
972
function setSourceMapSupport ( sourcemap : boolean ) {
0 commit comments