Skip to content

Commit c8f7e81

Browse files
committed
perf(core): read client manifest only if and when needed
1 parent 95204ba commit c8f7e81

File tree

1 file changed

+23
-21
lines changed
  • packages/qwik/src/optimizer/src/plugins

1 file changed

+23
-21
lines changed

packages/qwik/src/optimizer/src/plugins/plugin.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -285,27 +285,6 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
285285
if (updatedOpts.manifestInput) {
286286
opts.manifestInput = getValidManifest(updatedOpts.manifestInput) || null;
287287
}
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-
}
309288

310289
if (typeof updatedOpts.transformedModuleOutput === 'function') {
311290
opts.transformedModuleOutput = updatedOpts.transformedModuleOutput;
@@ -944,6 +923,29 @@ export const isDev = ${JSON.stringify(isDev)};
944923
}
945924

946925
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+
`could not read Qwik client manifest ${clientManifestPath}, ignoring. Make sure you provide it to the SSR renderer. (${e})`
945+
);
946+
}
947+
}
948+
947949
const manifest = isServer ? opts.manifestInput : null;
948950
let serverManifest: ServerQwikManifest | null = null;
949951
if (manifest?.manifestHash) {

0 commit comments

Comments
 (0)