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