From 457897e8b183d753c5fa6343be157a2981766ffe Mon Sep 17 00:00:00 2001 From: daiwei Date: Thu, 19 Sep 2024 18:22:12 +0800 Subject: [PATCH 1/3] fix(hmr): re-resolve script after type dep changed --- packages/plugin-vue/src/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 2ac6d5b8..d040f818 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -19,7 +19,12 @@ import { getSrcDescriptor, getTempSrcDescriptor, } from './utils/descriptorCache' -import { clearScriptCache, getResolvedScript, typeDepToSFCMap } from './script' +import { + clearScriptCache, + getResolvedScript, + resolveScript, + typeDepToSFCMap, +} from './script' import { transformMain } from './main' import { handleHotUpdate, handleTypeDepChange } from './handleHotUpdate' import { transformTemplateAsModule } from './template' @@ -301,6 +306,13 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { if (query.type === 'script') { // handle + + diff --git a/playground/vue/__tests__/vue.spec.ts b/playground/vue/__tests__/vue.spec.ts index aa88ec19..eb0af361 100644 --- a/playground/vue/__tests__/vue.spec.ts +++ b/playground/vue/__tests__/vue.spec.ts @@ -349,6 +349,20 @@ describe('macro imported types', () => { ), ) }) + + test('should hmr with lang=tsx', async () => { + editFile('types.ts', (code) => code.replace('msg: string', '')) + await untilUpdated( + () => page.textContent('.type-props-tsx'), + JSON.stringify( + { + bar: 'bar', + }, + null, + 2, + ), + ) + }) }) test('TS with generics', async () => { From c3d1ca0eca589ab29dd6ff66086657dfdb1976af Mon Sep 17 00:00:00 2001 From: daiwei Date: Fri, 8 Nov 2024 13:43:51 +0800 Subject: [PATCH 3/3] chore: update --- packages/plugin-vue/src/index.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index d040f818..3d547040 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -19,12 +19,7 @@ import { getSrcDescriptor, getTempSrcDescriptor, } from './utils/descriptorCache' -import { - clearScriptCache, - getResolvedScript, - resolveScript, - typeDepToSFCMap, -} from './script' +import { clearScriptCache, resolveScript, typeDepToSFCMap } from './script' import { transformMain } from './main' import { handleHotUpdate, handleTypeDepChange } from './handleHotUpdate' import { transformTemplateAsModule } from './template' @@ -305,14 +300,12 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { let block: SFCBlock | null | undefined if (query.type === 'script') { // handle