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.id('import.meta.hot'),
b.block([ b.block([
b.const(b.id('s'), b.call('$.source', b.id(analysis.name))), 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.id(analysis.name), b.call('$.hmr', b.id('s')))),
b.stmt( b.stmt(
b.assignment('=', b.member(b.id(analysis.name), b.id('filename')), b.id('filename')) b.assignment('=', b.member(b.id(analysis.name), b.id('filename')), b.id('filename'))
), ),
b.if( b.if(
b.id('import.meta.hot.acceptExports'), b.id('import.meta.hot.acceptExports'),
b.block([
b.stmt( b.stmt(
b.call('import.meta.hot.acceptExports', b.array([b.literal('default')]), accept_fn) 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) { if (import.meta.hot) {
const s = $.source(Hmr); const s = $.source(Hmr);
const filename = Hmr.name; const filename = Hmr.filename;
Hmr = $.hmr(s); Hmr = $.hmr(s);
Hmr.filename = filename; 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); $.set(s, module.default);
}); else import.meta.hot.accept((module) => { });
} else {
import.meta.hot.accept((module) => {
$.set(s, module.default); $.set(s, module.default);
}); });
}
} }
export default Hmr; export default Hmr;
Loading…
Cancel
Save