@@ -32,6 +32,8 @@ const defaultHotOptions = {
3232 absoluteImports : false ,
3333}
3434
35+ const defaultHotApi = 'svelte-hmr/runtime/hot-api-esm.js'
36+
3537const nativeAdapter = require . resolve (
3638 '../runtime/svelte-native/proxy-adapter-native.js'
3739)
@@ -148,10 +150,10 @@ const parseCssId = (code, parseHash) => {
148150}
149151
150152// meta can be 'import.meta' or 'module'
151- const createMakeHot = ( _hotApi , options ) => {
152- if ( typeof _hotApi !== 'string' ) {
153- options = _hotApi
154- _hotApi = null
153+ const createMakeHot = ( hotApi = defaultHotApi , options ) => {
154+ if ( typeof hotApi !== 'string' ) {
155+ options = hotApi
156+ hotApi = defaultHotApi
155157 }
156158 const { meta = 'import.meta' , walk } = options || { }
157159
@@ -171,7 +173,7 @@ const createMakeHot = (_hotApi, options) => {
171173 return accessors
172174 }
173175
174- return function makeHot (
176+ function makeHot (
175177 id ,
176178 compiledCode ,
177179 hotOptionsArg ,
@@ -181,9 +183,6 @@ const createMakeHot = (_hotApi, options) => {
181183 ) {
182184 const hotOptions = Object . assign ( { } , defaultHotOptions , hotOptionsArg )
183185
184- const hotApi =
185- _hotApi || ( hotOptions . compatVite && 'svelte-hmr/runtime/esm.js' )
186-
187186 const noPreserveState =
188187 hotOptions . noPreserveState ||
189188 ( hotOptions . noPreserveStateKey &&
@@ -221,6 +220,11 @@ const createMakeHot = (_hotApi, options) => {
221220
222221 return compiledCode . replace ( / ( \n ? e x p o r t d e f a u l t ( [ ^ ; ] * ) ; ) / , replacement )
223222 }
223+
224+ // rollup-plugin-svelte-hot needs hotApi path (for tests)
225+ makeHot . hotApi = hotApi
226+
227+ return makeHot
224228}
225229
226230module . exports = createMakeHot
0 commit comments