Skip to content

Commit a5e0973

Browse files
committed
remove need for compatVite option for Vite 2
1 parent 0b1be66 commit a5e0973

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/make-hot.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const defaultHotOptions = {
3838
// Svelte Native mode
3939
native: false,
4040
// Vite mode
41+
// NOTE probably not neede anymore with Vite2, kept for compatibility with
42+
// existing Vite1 setups though
4143
compatVite: false,
4244
// name of the adapter import binding
4345
importAdapterName: globalAdapterName,
@@ -97,8 +99,14 @@ const renderApplyHmr = ({
9799
}) =>
98100
// this silly formatting keeps all original characters in their position,
99101
// thus saving us from having to provide a sourcemap
102+
//
103+
// NOTE the `if (false) accept()` line is for tools that wants to see the
104+
// accept call in the actual accepted module to enable HMR (Vite and, I
105+
// believe, Snowpack 3)
106+
//
100107
`${imports.join(';')};${`
101108
if (${compatVite ? '' : `${meta} && `}${meta}.hot) {
109+
if (false) import.meta.hot.accept();
102110
$2 = ${globalName}.applyHmr({
103111
m: ${meta},
104112
id: ${quote(id)},
@@ -109,7 +117,6 @@ const renderApplyHmr = ({
109117
cssId: ${quote(cssId)},
110118
nonCssHash: ${quote(nonCssHash)},
111119
});
112-
${compatVite ? 'import.meta.hot.accept();' : ''}
113120
}
114121
`
115122
.split('\n')

0 commit comments

Comments
 (0)