diff --git a/lib/make-hot.js b/lib/make-hot.js index 9aa7557..d1efef9 100644 --- a/lib/make-hot.js +++ b/lib/make-hot.js @@ -38,6 +38,8 @@ const defaultHotOptions = { // Svelte Native mode native: false, // Vite mode + // NOTE probably not neede anymore with Vite2, kept for compatibility with + // existing Vite1 setups though compatVite: false, // name of the adapter import binding importAdapterName: globalAdapterName, @@ -97,8 +99,14 @@ const renderApplyHmr = ({ }) => // this silly formatting keeps all original characters in their position, // thus saving us from having to provide a sourcemap + // + // NOTE the `if (false) accept()` line is for tools that wants to see the + // accept call in the actual accepted module to enable HMR (Vite and, I + // believe, Snowpack 3) + // `${imports.join(';')};${` if (${compatVite ? '' : `${meta} && `}${meta}.hot) { + if (false) import.meta.hot.accept(); $2 = ${globalName}.applyHmr({ m: ${meta}, id: ${quote(id)}, @@ -109,7 +117,6 @@ const renderApplyHmr = ({ cssId: ${quote(cssId)}, nonCssHash: ${quote(nonCssHash)}, }); - ${compatVite ? 'import.meta.hot.accept();' : ''} } ` .split('\n')