Skip to content

Commit

Permalink
fix: HMR API conditinal guard (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
kermanx authored Mar 8, 2024
1 parent f11a491 commit 1ec5cc7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/slidev/node/plugins/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,12 @@ defineProps<{ no: number | string }>()`)
return [
...imports,
`const data = [\n${slides.join(',\n')}\n]`,
`import.meta.hot.data.slides ??= shallowRef()`,
`import.meta.hot.data.slides.value = data`,
`export const slides = import.meta.hot.data.slides`,
`if (import.meta.hot) {`,
` import.meta.hot.data.slides ??= shallowRef()`,
` import.meta.hot.data.slides.value = data`,
` import.meta.hot.accept()`,
`}`,
`export const slides = import.meta.hot ? import.meta.hot.data.slides : shallowRef(data)`,
].join('\n')
}

Expand Down

0 comments on commit 1ec5cc7

Please sign in to comment.