|
|
|
|
@ -422,10 +422,26 @@ export function client_component(source, analysis, options) {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (options.hmr) {
|
|
|
|
|
const accept_fn = b.arrow(
|
|
|
|
|
[b.id('module')],
|
|
|
|
|
b.block([b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module'), b.id('default'))))])
|
|
|
|
|
);
|
|
|
|
|
const accept_fn_body = [
|
|
|
|
|
b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module'), b.id('default'))))
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (analysis.css.hash) {
|
|
|
|
|
// remove existing `<style>` element, in case CSS changed
|
|
|
|
|
accept_fn_body.unshift(
|
|
|
|
|
b.stmt(
|
|
|
|
|
b.call(
|
|
|
|
|
b.member(
|
|
|
|
|
b.call('document.querySelector', b.literal('#' + analysis.css.hash)),
|
|
|
|
|
b.id('remove'),
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body.push(
|
|
|
|
|
component,
|
|
|
|
|
b.if(
|
|
|
|
|
@ -433,6 +449,7 @@ export function client_component(source, analysis, options) {
|
|
|
|
|
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('filename'))),
|
|
|
|
|
b.const(b.id('accept'), b.arrow([b.id('module')], b.block(accept_fn_body))),
|
|
|
|
|
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'))
|
|
|
|
|
@ -441,10 +458,14 @@ export function client_component(source, analysis, options) {
|
|
|
|
|
b.id('import.meta.hot.acceptExports'),
|
|
|
|
|
b.block([
|
|
|
|
|
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')]),
|
|
|
|
|
b.id('accept')
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
]),
|
|
|
|
|
b.block([b.stmt(b.call('import.meta.hot.accept', accept_fn))])
|
|
|
|
|
b.block([b.stmt(b.call('import.meta.hot.accept', b.id('accept')))])
|
|
|
|
|
)
|
|
|
|
|
])
|
|
|
|
|
),
|
|
|
|
|
|