vite/playground/hmr/hmrDep.js
2022-05-09 09:36:14 +02:00

15 lines
343 B
JavaScript

export const foo = 1
export { foo as nestedFoo } from './hmrNestedDep'
if (import.meta.hot) {
const data = import.meta.hot.data
if ('fromDispose' in data) {
console.log(`(dep) foo from dispose: ${data.fromDispose}`)
}
import.meta.hot.dispose((data) => {
console.log(`(dep) foo was: ${foo}`)
data.fromDispose = foo
})
}