Skip to content

Commit d9085f7

Browse files
committed
wip: call this.addWatchFile in vite:load-fallback plugin
1 parent 0c488c7 commit d9085f7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/vite/src/node/plugins/loadFallback.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ export function loadFallbackPlugin(): Plugin {
1010
name: 'vite:load-fallback',
1111
async load(id) {
1212
try {
13-
// if we don't add `await` here, we couldn't catch the error in readFile
14-
return await fsp.readFile(cleanUrl(id), 'utf-8')
13+
const cleanedId = cleanUrl(id)
14+
const content = await fsp.readFile(cleanedId, 'utf-8')
15+
this.addWatchFile(cleanedId)
16+
return content
1517
} catch (e) {
16-
return fsp.readFile(id, 'utf-8')
18+
const content = await fsp.readFile(id, 'utf-8')
19+
this.addWatchFile(id)
20+
return content
1721
}
1822
},
1923
}

0 commit comments

Comments
 (0)