From b493925022aaf10acc48efc7610303842615a24b Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Thu, 5 Dec 2024 14:44:40 +0900 Subject: [PATCH] fix: hack vue hmr --- packages/vite/src/node/server/environments/rolldown.ts | 6 ++++++ playground/rolldown-dev-vue/__tests__/basic.spec.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/environments/rolldown.ts b/packages/vite/src/node/server/environments/rolldown.ts index 9ab06e1163656e..6a63ecb87eae81 100644 --- a/packages/vite/src/node/server/environments/rolldown.ts +++ b/packages/vite/src/node/server/environments/rolldown.ts @@ -331,6 +331,12 @@ class RolldownEnvironment extends DevEnvironment { if (!this.fileModuleIds.has(ctx.file)) { return } + for (const plugin of this.plugins) { + // TODO: for now, simple hack for vue hmr + if (plugin.name === 'vite:vue') { + ;(plugin.handleHotUpdate as any)(ctx) + } + } if ( this.rolldownDevOptions.hmr || this.rolldownDevOptions.ssrModuleRunner diff --git a/playground/rolldown-dev-vue/__tests__/basic.spec.ts b/playground/rolldown-dev-vue/__tests__/basic.spec.ts index 7a47a7182ace0b..26c56f3178c7e2 100644 --- a/playground/rolldown-dev-vue/__tests__/basic.spec.ts +++ b/playground/rolldown-dev-vue/__tests__/basic.spec.ts @@ -13,6 +13,6 @@ test.runIf(!isBuild)('hmr js', async () => { editFile('./src/App.vue', (s) => s.replace('Count:', 'Count-x:')) await page.getByRole('button', { name: 'Count-x: 1' }).click() - editFile('./src/app.tsx', (s) => s.replace('Count-x:', 'Count:')) + editFile('./src/App.vue', (s) => s.replace('Count-x:', 'Count:')) await page.getByRole('button', { name: 'Count: 2' }).click() })