Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(vite): improve vite-node module invalidation (#6736)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Aug 18, 2022
1 parent c688e18 commit 43e6c02
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"ufo": "^0.8.5",
"unplugin": "^0.9.2",
"vite": "~3.0.8",
"vite-node": "^0.22.0",
"vite-node": "^0.22.1",
"vite-plugin-checker": "^0.4.9",
"vue-bundle-renderer": "^0.4.2"
},
Expand Down
7 changes: 1 addition & 6 deletions packages/vite/src/runtime/vite-node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ export default async (ssrContext) => {
const invalidates = await $fetch('/invalidates', {
baseURL: viteNodeOptions.baseURL
})
const updates = new Set()
for (const key of invalidates) {
if (runner.moduleCache.delete(key)) {
updates.add(key)
}
}
const updates = runner.moduleCache.invalidateDepTree(invalidates)

// Execute SSR bundle on demand
const start = performance.now()
Expand Down
8 changes: 0 additions & 8 deletions packages/vite/src/vite-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ function createViteNodeMiddleware (ctx: ViteBuildContext, invalidates: Set<strin
}))

app.use('/invalidates', defineEventHandler(() => {
// When a file has been invalidated, we also invalidate the entry module
if (invalidates.size) {
for (const key of ctx.ssrServer!.moduleGraph.fileToModulesMap.keys()) {
if (key.startsWith(ctx.nuxt.options.appDir + '/entry')) {
invalidates.add(key)
}
}
}
const ids = Array.from(invalidates)
invalidates.clear()
return ids
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ __metadata:
unbuild: latest
unplugin: ^0.9.2
vite: ~3.0.8
vite-node: ^0.22.0
vite-node: ^0.22.1
vite-plugin-checker: ^0.4.9
vue: 3.2.37
vue-bundle-renderer: ^0.4.2
Expand Down Expand Up @@ -13488,17 +13488,17 @@ __metadata:
languageName: node
linkType: hard

"vite-node@npm:^0.22.0":
version: 0.22.0
resolution: "vite-node@npm:0.22.0"
"vite-node@npm:^0.22.1":
version: 0.22.1
resolution: "vite-node@npm:0.22.1"
dependencies:
debug: ^4.3.4
mlly: ^0.5.12
pathe: ^0.2.0
vite: ^2.9.12 || ^3.0.0-0
bin:
vite-node: vite-node.mjs
checksum: 2b5552b2ae1e20bf139e6b88e2b59910f4cedd01a9355b6bfbf3d10d36cb5979660a83e47e9db4c1523b874441c7a1498074bef6dc47c14cc3ace857eceaec13
checksum: 29a4edb4e3f1344a4334dd46ce8e023862831c74a8aca0266c625fbfbdc5a31e83bb64992b08a82249c8a298d5bbbf84bc27ff6af5fe60514e307008443a2d2a
languageName: node
linkType: hard

Expand Down

0 comments on commit 43e6c02

Please sign in to comment.