-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vite-node): correctly resolve hmr filepath (#3834)
- Loading branch information
1 parent
4552185
commit 711a624
Showing
6 changed files
with
89 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
console.error('Hello!') | ||
|
||
if (import.meta.hot) { | ||
import.meta.hot.accept(() => { | ||
console.error('Accept') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test } from 'vitest' | ||
import { resolve } from 'pathe' | ||
import { editFile, runViteNodeCli } from '../../test-utils' | ||
|
||
test('hmr.accept works correctly', async () => { | ||
const scriptFile = resolve(__dirname, '../src/script.js') | ||
|
||
const viteNode = await runViteNodeCli('--watch', scriptFile) | ||
|
||
await viteNode.waitForStderr('Hello!') | ||
|
||
editFile(scriptFile, content => content.replace('Hello!', 'Hello world!')) | ||
|
||
await viteNode.waitForStderr('Hello world!') | ||
await viteNode.waitForStderr('Accept') | ||
await viteNode.waitForStdout(`[vite-node] hot updated: ${scriptFile}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters