pull/11526/head
Rich Harris 2 years ago
parent fc07479efa
commit 22e1e91dec

@ -449,17 +449,19 @@ export function client_component(source, analysis, options) {
b.id('import.meta.hot'),
b.block([
b.const(b.id('s'), b.call('$.source', b.id(analysis.name))),
b.const(b.id('filename'), b.member(b.id(analysis.name), b.id('name'))),
b.const(b.id('filename'), b.member(b.id(analysis.name), b.id('filename'))),
b.stmt(b.assignment('=', b.id(analysis.name), b.call('$.hmr', b.id('s')))),
b.stmt(
b.assignment('=', b.member(b.id(analysis.name), b.id('filename')), b.id('filename'))
),
b.if(
b.id('import.meta.hot.acceptExports'),
b.block([
b.stmt(
b.call('import.meta.hot.acceptExports', b.array([b.literal('default')]), accept_fn)
),
b.stmt(b.call('import.meta.hot.accept', accept_fn))
)
]),
b.block([b.stmt(b.call('import.meta.hot.accept', accept_fn))])
)
])
),

@ -11,16 +11,20 @@ function Hmr($$anchor) {
if (import.meta.hot) {
const s = $.source(Hmr);
const filename = Hmr.name;
const filename = Hmr.filename;
Hmr = $.hmr(s);
Hmr.filename = filename;
if (import.meta.hot.acceptExports) import.meta.hot.acceptExports(["default"], (module) => {
if (import.meta.hot.acceptExports) {
import.meta.hot.acceptExports(["default"], (module) => {
$.set(s, module.default);
}); else import.meta.hot.accept((module) => {
});
} else {
import.meta.hot.accept((module) => {
$.set(s, module.default);
});
}
}
export default Hmr;
Loading…
Cancel
Save