mirror of https://github.com/sveltejs/svelte
feat: simplify HMR implementation (#11132)
* chore: simplify HMR implementation * changeset * unused * prettierpull/11134/head
parent
a740b7bb43
commit
d5776c3ec3
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: simplify HMR implementation
|
@ -0,0 +1,7 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
hmr: true
|
||||
}
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
// index.svelte (Svelte VERSION)
|
||||
// Note: compiler output will change before 5.0 is released!
|
||||
import "svelte/internal/disclose-version";
|
||||
import * as $ from "svelte/internal/client";
|
||||
|
||||
var root = $.template(`<h1>hello world</h1>`);
|
||||
|
||||
function Hmr($$anchor, $$props) {
|
||||
$.push($$props, false);
|
||||
$.init();
|
||||
|
||||
var h1 = root();
|
||||
|
||||
$.append($$anchor, h1);
|
||||
$.pop();
|
||||
}
|
||||
|
||||
if (import.meta.hot) {
|
||||
const s = $.source(Hmr);
|
||||
|
||||
Hmr = $.hmr(s);
|
||||
|
||||
import.meta.hot.accept((module) => {
|
||||
$.set(s, module.default);
|
||||
});
|
||||
}
|
||||
|
||||
export default Hmr;
|
@ -0,0 +1,9 @@
|
||||
// index.svelte (Svelte VERSION)
|
||||
// Note: compiler output will change before 5.0 is released!
|
||||
import * as $ from "svelte/internal/server";
|
||||
|
||||
export default function Hmr($$payload, $$props) {
|
||||
$.push(false);
|
||||
$$payload.out += `<h1>hello world</h1>`;
|
||||
$.pop();
|
||||
}
|
@ -0,0 +1 @@
|
||||
<h1>hello world</h1>
|
Loading…
Reference in new issue