Skip to content

Commit

Permalink
fix: import.meta.hot should be injected before first `if (import.meta…
Browse files Browse the repository at this point in the history
….hot)` (#285)

Fix: #282
  • Loading branch information
csr632 authored May 28, 2020
1 parent 8cf1f75 commit 9ac63b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node/server/serverPluginHmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ export function rewriteFileWithHMR(
// if (import.meta.hot) ...
if (node.type === 'IfStatement') {
const isDevBlock = isMetaHot(node.test)
if (isDevBlock) {
if (isDevBlock && !importMetaConditional) {
// remember the first occurence of `if (import.meta.hot)`
importMetaConditional = node
}
if (node.consequent.type === 'BlockStatement') {
Expand Down

0 comments on commit 9ac63b1

Please sign in to comment.