Skip to content

Commit

Permalink
fix(better-define): hmr
Browse files Browse the repository at this point in the history
closes #158
  • Loading branch information
sxzz committed Nov 23, 2022
1 parent 6f5f652 commit 2fa0808
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-books-share.md
@@ -0,0 +1,5 @@
---
'@vue-macros/better-define': patch
---

fix HMR
6 changes: 3 additions & 3 deletions packages/better-define/src/index.ts
Expand Up @@ -90,7 +90,7 @@ export default createUnplugin<Options | undefined>((userOptions = {}, meta) => {
options.isProduction = config.isProduction
},

handleHotUpdate({ file, server }) {
handleHotUpdate({ file, server, modules }) {
function getAffectedModules(file: string): Set<ModuleNode> {
if (!referencedFiles.has(file)) return new Set([])
const modules = new Set<ModuleNode>([])
Expand All @@ -105,8 +105,8 @@ export default createUnplugin<Options | undefined>((userOptions = {}, meta) => {

if (tsFileCache[file]) delete tsFileCache[file]

const modules = getAffectedModules(file)
return Array.from(modules)
const affected = getAffectedModules(file)
return [...modules, ...affected]
},
},
}
Expand Down
@@ -1,3 +1,3 @@
export type AnotherType = {
baz: string
baz?: string
}
4 changes: 1 addition & 3 deletions playground/vue3/src/examples/better-define/child.vue
Expand Up @@ -24,7 +24,5 @@ defineEmits<Emits>()
</script>

<template>
<div>
<slot />
</div>
<div>bar</div>
</template>

0 comments on commit 2fa0808

Please sign in to comment.