Skip to content

Commit

Permalink
Merge pull request sveltejs#3 from halfnelson/hmr-native-fix
Browse files Browse the repository at this point in the history
update native support
  • Loading branch information
rixo committed Jul 30, 2019
2 parents 9dd5eec + 21e0276 commit 733852f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 6 additions & 1 deletion lib/svelte3/make-hot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ const posixify = require('../posixify');

const hotApi = require.resolve('./hot/hot-api.js');

const nativeApi = require.resolve('../svelte-native/hot/proxy-adapter-native.js')

const quote = JSON.stringify;

function makeHot(id, code, hotOptions = {}) {
const options = JSON.stringify(hotOptions);
const replacement = `

let replacement = `
if (module.hot) {
${ hotOptions.native ? `global.__SvelteLoader__ProxyAdapter = require('${posixify(nativeApi)}').default` : ''}
const { applyHMR } = require('${posixify(hotApi)}');
$2 = applyHMR(${options}, ${quote(id)}, module.hot, $2);
}
export default $2;
`;

return code.replace(/(export default ([^;]*));/, replacement);
}

Expand Down
11 changes: 0 additions & 11 deletions native.js

This file was deleted.

0 comments on commit 733852f

Please sign in to comment.