Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalidate module cache for subsequent builds #3398

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/client/app/index.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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