Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1dcfff6

Browse files
committed
fix: ensure HMR updates styles when SFC is treated as a type dependency
1 parentb5b9786 commit1dcfff6

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

‎src/core/handleHotUpdate.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export async function handleHotUpdate(
2828
{ file, modules, read}:HmrContext,
2929
options:ResolvedOptions,
3030
customElement:boolean,
31+
typeDepModules?:ModuleNode[],
3132
):Promise<ModuleNode[]|undefined>{
3233
constprevDescriptor=getDescriptor(file,options,false,true)
3334
if(!prevDescriptor){
@@ -167,7 +168,9 @@ export async function handleHotUpdate(
167168
}
168169
debug(`[vue:update(${updateType.join('&')})]${file}`)
169170
}
170-
return[...affectedModules].filter(Boolean)asModuleNode[]
171+
return[...affectedModules, ...(typeDepModules||[])].filter(
172+
Boolean,
173+
)asModuleNode[]
171174
}
172175

173176
exportfunctionisEqualBlock(a:SFCBlock|null,b:SFCBlock|null):boolean{

‎src/core/index.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
typeUnpluginContextMeta,
88
typeUnpluginInstance,
99
}from'unplugin'
10-
import{createFilter,normalizePath,typeViteDevServer}from'vite'
10+
import{
11+
createFilter,
12+
normalizePath,
13+
typeModuleNode,
14+
typeViteDevServer,
15+
}from'vite'
1116
import{version}from'../../package.json'
1217
import{resolveCompiler}from'../core/compiler'
1318
import{EXPORT_HELPER_ID,helperCode}from'../core/helper'
@@ -248,14 +253,22 @@ export const plugin: UnpluginInstance<Options | undefined, false> =
248253
if(options.value.compiler.invalidateTypeCache){
249254
options.value.compiler.invalidateTypeCache(ctx.file)
250255
}
256+
257+
lettypeDepModules:ModuleNode[]|undefined
258+
constmatchesFilter=filter.value(ctx.file)
251259
if(typeDepToSFCMap.has(ctx.file)){
252-
returnhandleTypeDepChange(typeDepToSFCMap.get(ctx.file)!,ctx)
260+
typeDepModules=handleTypeDepChange(
261+
typeDepToSFCMap.get(ctx.file)!,
262+
ctx,
263+
)
264+
if(!matchesFilter)returntypeDepModules
253265
}
254-
if(filter.value(ctx.file)){
266+
if(matchesFilter){
255267
returnhandleHotUpdate(
256268
ctx,
257269
options.value,
258270
customElementFilter.value(ctx.file),
271+
typeDepModules,
259272
)
260273
}
261274
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp