|
|
|
@ -418,7 +418,13 @@ export function client_component(source, analysis, options) {
|
|
|
|
|
|
|
|
|
|
|
|
if (options.hmr) {
|
|
|
|
if (options.hmr) {
|
|
|
|
const accept_fn_body = [
|
|
|
|
const accept_fn_body = [
|
|
|
|
b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module.default'), b.id('$.ORIGINAL'), true)))
|
|
|
|
b.stmt(
|
|
|
|
|
|
|
|
b.call(
|
|
|
|
|
|
|
|
'$.set',
|
|
|
|
|
|
|
|
b.id('import.meta.hot.data.source'),
|
|
|
|
|
|
|
|
b.member(b.id('module.default'), b.id('$.ORIGINAL'), true)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
if (analysis.css.hash) {
|
|
|
|
if (analysis.css.hash) {
|
|
|
|
@ -438,13 +444,27 @@ export function client_component(source, analysis, options) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const hmr = b.block([
|
|
|
|
const hmr = b.block([
|
|
|
|
b.const(b.id('s'), b.call('$.source', b.id(analysis.name))),
|
|
|
|
b.stmt(
|
|
|
|
b.const(b.id('filename'), b.member(b.id(analysis.name), b.id('filename'))),
|
|
|
|
b.assignment(
|
|
|
|
|
|
|
|
'??=',
|
|
|
|
|
|
|
|
b.id('import.meta.hot.data.source'),
|
|
|
|
|
|
|
|
b.call('$.source', b.id(analysis.name))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
b.const(b.id('$$filename'), b.member(b.id(analysis.name), b.id('$.FILENAME'), true)),
|
|
|
|
b.const(b.id('$$original'), b.id(analysis.name)),
|
|
|
|
b.const(b.id('$$original'), b.id(analysis.name)),
|
|
|
|
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.id(analysis.name), b.call('$.hmr', b.id('import.meta.hot.data.source')))
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
b.stmt(
|
|
|
|
|
|
|
|
b.assignment(
|
|
|
|
|
|
|
|
'=',
|
|
|
|
|
|
|
|
b.member(b.id(analysis.name), b.id('$.FILENAME'), true),
|
|
|
|
|
|
|
|
b.id('$$filename')
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
// Assign the original component to the wrapper so we can use it on hot reload patching,
|
|
|
|
// Assign the original component to the wrapper so we can use it on hot reload patching,
|
|
|
|
// else we would call the HMR function two times
|
|
|
|
// else we would create a matryoshka doll of HMR wrappers
|
|
|
|
b.stmt(
|
|
|
|
b.stmt(
|
|
|
|
b.assignment(
|
|
|
|
b.assignment(
|
|
|
|
'=',
|
|
|
|
'=',
|
|
|
|
|