vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
70 lines (69 loc) • 3.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.analyzePage = analyzePage;
const determineClientEntry_js_1 = require("../../../shared/getPageFiles/analyzePageClientSide/determineClientEntry.js");
const analyzePageClientSide_js_1 = require("../../../shared/getPageFiles/analyzePageClientSide.js");
const virtualFilePageConfigLazy_js_1 = require("../../shared/virtualFiles/virtualFilePageConfigLazy.js");
const analyzeClientSide_js_1 = require("../../../shared/getPageFiles/analyzeClientSide.js");
const getConfigValueRuntime_js_1 = require("../../../shared/page-configs/getConfigValueRuntime.js");
async function analyzePage(pageFilesAll, pageConfig, pageId, globalContext) {
if (pageConfig) {
const { isClientRuntimeLoaded, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
const clientEntries = [];
const clientFilePath = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'client', 'string')?.value ?? null;
if (clientFilePath)
clientEntries.push(clientFilePath);
if (isClientRuntimeLoaded)
clientEntries.push((0, determineClientEntry_js_1.getVikeClientEntry)(isClientRouting));
const clientDependencies = [];
clientDependencies.push({
id: (0, virtualFilePageConfigLazy_js_1.getVirtualFileIdPageConfigLazy)(pageConfig.pageId, true),
onlyAssets: isClientRuntimeLoaded ? false : true,
eagerlyImported: false,
});
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
if (!globalContext._isProduction) {
clientDependencies.push({
id: (0, virtualFilePageConfigLazy_js_1.getVirtualFileIdPageConfigLazy)(pageConfig.pageId, false),
onlyAssets: true,
eagerlyImported: false,
});
}
/* Remove?
Object.values(pageConfig.configElements).forEach((configElement) => {
if (configElement.importPath) {
const { env } = configElement
assert(env)
const onlyAssets = env === { server: true }
const eagerlyImported = env === { server: true, client: 'if-client-routing', eager: true }
if (onlyAssets || eagerlyImported) {
clientDependencies.push({
id: configElement.importPath,
onlyAssets,
eagerlyImported
})
}
}
})
*/
clientEntries.forEach((clientEntry) => {
clientDependencies.push({
id: clientEntry,
onlyAssets: false,
eagerlyImported: false,
});
});
return {
isHtmlOnly: !isClientRuntimeLoaded,
isClientRouting,
clientEntries,
clientDependencies,
// pageFilesClientSide and pageFilesServerSide are only used for debugging
pageFilesClientSide: [],
pageFilesServerSide: [],
};
}
else {
return (0, analyzePageClientSide_js_1.analyzePageClientSide)(pageFilesAll, pageId);
}
}