perf(vite-node): only invalidate cache for user code (#6156)

This commit is contained in:
Anthony Fu 2022-07-26 21:46:06 +08:00 committed by GitHub
parent 54da45e7a1
commit f0485d83d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,11 @@ export default async (ssrContext) => {
process.server = true process.server = true
render = render || (await runner.executeFile(viteNodeOptions.entryPath)).default render = render || (await runner.executeFile(viteNodeOptions.entryPath)).default
const result = await render(ssrContext) const result = await render(ssrContext)
runner.moduleCache.clear() // reset cache for non-node-modules
for (const key of runner.moduleCache.keys()) {
if (!key.includes('/node_modules/')) {
runner.moduleCache.delete(key)
}
}
return result return result
} }