From f0485d83d9ef834d8ecb0a1b32a708c50eb3e370 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 26 Jul 2022 21:46:06 +0800 Subject: [PATCH] perf(vite-node): only invalidate cache for user code (#6156) --- packages/vite/src/runtime/vite-node.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/runtime/vite-node.mjs b/packages/vite/src/runtime/vite-node.mjs index 88b63e3fb2..94f45f25b3 100644 --- a/packages/vite/src/runtime/vite-node.mjs +++ b/packages/vite/src/runtime/vite-node.mjs @@ -22,6 +22,11 @@ export default async (ssrContext) => { process.server = true render = render || (await runner.executeFile(viteNodeOptions.entryPath)).default 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 }