Skip to content

Commit

Permalink
perf: eagerly load user files
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 21, 2024
1 parent e1a09e0 commit b8d3619
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vike/node/runtime/globalContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { ConfigVikeResolved } from '../../shared/ConfigVike.js'
import { getConfigVike } from '../shared/getConfigVike.js'
import { assertRuntimeManifest, type RuntimeManifest } from '../shared/assertRuntimeManifest.js'
import pc from '@brillout/picocolors'
import { getPageFilesExports } from './page-files/getPageFilesExports.js'
let resolveGlobalContext: (globalContext: GlobalContext) => void
const globalObject = getGlobalObject<{
globalContext?: GlobalContext
Expand Down Expand Up @@ -133,6 +134,7 @@ function setGlobalContext_viteDevServer(viteDevServer: ViteDevServer) {
assert(!globalObject.globalContext)
globalObject.viteConfig = viteDevServer.config
globalObject.viteDevServer = viteDevServer
eagerlyLoadUserFiles()
}
function setGlobalContext_isDev(isDev: boolean) {
globalObject.isDev = isDev
Expand Down Expand Up @@ -253,3 +255,9 @@ function assertViteManifest(manifest: unknown): asserts manifest is ViteManifest
})
*/
}

function eagerlyLoadUserFiles() {
// Other than here, the getPageFilesExports() function is only called only upon calling the renderPage() function.
// We call it as early as possible here for better performance.
getPageFilesExports()
}

0 comments on commit b8d3619

Please sign in to comment.