Refactor SSR strategy. Redirect before bundling any page component. Additional bugfixes for dev environment
This commit is contained in:
+13
-8
@@ -5,14 +5,6 @@ import grabRootFilePath from "./grab-root-file-path";
|
||||
import grabPageCombinedServerRes from "./grab-page-combined-server-res";
|
||||
export default async function grabPageModules({ file_path, debug, url, query, routeParams, skip_server_res, }) {
|
||||
const now = Date.now();
|
||||
const { root_file_path } = grabRootFilePath();
|
||||
const root_module = root_file_path
|
||||
? await import(`${root_file_path}?t=${now}`)
|
||||
: undefined;
|
||||
const module = await import(`${file_path}?t=${now}`);
|
||||
if (debug) {
|
||||
log.info(`module:`, module);
|
||||
}
|
||||
const { serverRes } = skip_server_res
|
||||
? {}
|
||||
: await grabPageCombinedServerRes({
|
||||
@@ -22,6 +14,19 @@ export default async function grabPageModules({ file_path, debug, url, query, ro
|
||||
routeParams,
|
||||
url,
|
||||
});
|
||||
if (serverRes?.redirect?.destination) {
|
||||
return Response.redirect(serverRes.redirect.destination, serverRes.redirect.permanent
|
||||
? 301
|
||||
: serverRes.redirect.status_code || 302);
|
||||
}
|
||||
const { root_file_path } = grabRootFilePath();
|
||||
const root_module = root_file_path
|
||||
? await import(`${root_file_path}?t=${now}`)
|
||||
: undefined;
|
||||
const module = await import(`${file_path}?t=${now}`);
|
||||
if (debug) {
|
||||
log.info(`module:`, module);
|
||||
}
|
||||
const { component } = (await grabPageBundledReactComponent({
|
||||
file_path,
|
||||
})) || {};
|
||||
|
||||
Reference in New Issue
Block a user