Skip to content

Commit

Permalink
fix: invalidate module cache for subsequent builds (#3398)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jan 1, 2024
1 parent 09e48db commit 27f60e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/client/app/index.ts
Expand Up @@ -135,7 +135,11 @@ function newRouter(): Router {
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js')
}

pageModule = import(/*@vite-ignore*/ pageFilePath)
if (import.meta.env.SSR) {
pageModule = import(/*@vite-ignore*/ pageFilePath + '?t=' + Date.now())
} else {
pageModule = import(/*@vite-ignore*/ pageFilePath)
}
}

if (inBrowser) {
Expand Down
4 changes: 3 additions & 1 deletion src/node/build/build.ts
Expand Up @@ -52,7 +52,9 @@ export async function build(
}

const entryPath = path.join(siteConfig.tempDir, 'app.js')
const { render } = await import(pathToFileURL(entryPath).toString())
const { render } = await import(
pathToFileURL(entryPath).toString() + '?t=' + Date.now()
)

await task('rendering pages', async () => {
const appChunk =
Expand Down
6 changes: 5 additions & 1 deletion src/node/build/render.ts
Expand Up @@ -52,7 +52,11 @@ export async function renderPage(
try {
// resolve page data so we can render head tags
const { __pageData } = await import(
pathToFileURL(path.join(config.tempDir, pageServerJsFileName)).toString()
pathToFileURL(
path.join(config.tempDir, pageServerJsFileName)
).toString() +
'?t=' +
Date.now()
)
pageData = __pageData
} catch (e) {
Expand Down

0 comments on commit 27f60e0

Please sign in to comment.