vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
32 lines (31 loc) • 1.22 kB
JavaScript
// Needed by Vike
export { setGlobalContext_buildEntry } from '../node/runtime/globalContext.js';
// Needed by vite-plugin-vercel
export { route, getPagesAndRoutes };
import { route as routeInternal } from '../shared/route/index.js';
import { getGlobalContextServerInternal, initGlobalContext_getPagesAndRoutes } from '../node/runtime/globalContext.js';
import { setNodeEnvProduction } from '../utils/assertSetup.js';
/**
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel} to compute some rewrite rules and extract { isr } configs.
*
* TODO/eventually: remove
*/
async function getPagesAndRoutes() {
setNodeEnvProduction();
await initGlobalContext_getPagesAndRoutes();
const { globalContext } = await getGlobalContextServerInternal();
const {
//
_pageRoutes: pageRoutes, _pageFilesAll: pageFilesAll, _pageConfigs: pageConfigs, _allPageIds: allPageIds } = globalContext;
return {
pageRoutes,
pageFilesAll,
pageConfigs,
allPageIds
};
}
async function route(pageContext) {
const pageContextFromRoute = await routeInternal(pageContext);
// Old interface
return { pageContextAddendum: pageContextFromRoute };
}