forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hmr): support multiple accept calls (vitejs#170)
fix vitejs#158
- Loading branch information
Showing
5 changed files
with
143 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
import { hot } from 'vite/hmr' | ||
import './testHmrManualDep' | ||
|
||
export const foo = 1 | ||
|
||
if (__DEV__) { | ||
hot.accept(({ foo }) => { | ||
console.log('foo is now: ', foo) | ||
console.log('(self-accepting)1.foo is now:', foo) | ||
}) | ||
|
||
hot.accept(({ foo }) => { | ||
console.log('(self-accepting)2.foo is now:', foo) | ||
}) | ||
|
||
hot.dispose(() => { | ||
console.log('foo was: ', foo) | ||
console.log(`foo was: ${foo}`) | ||
}) | ||
|
||
hot.accept('./testHmrManualDep.js', ({ foo }) => { | ||
console.log('(single dep) foo is now:', foo) | ||
}) | ||
|
||
hot.accept(['./testHmrManualDep.js'], (modules) => { | ||
console.log('(multiple deps) foo is now:', modules[0].foo) | ||
}) | ||
} |
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,9 @@ | ||
import { hot } from 'vite/hmr' | ||
|
||
export const foo = 1 | ||
|
||
if (__DEV__) { | ||
hot.dispose(() => { | ||
console.log(`(dep) foo was: ${foo}`) | ||
}) | ||
} |
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