Skip to content

Commit 08501cd

Browse files
committed
chore: directly export function in non-HMR mode
1 parent 8e17428 commit 08501cd

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,18 +430,17 @@ export function client_component(source, analysis, options) {
430430
component_block.body.unshift(b.const('$$slots', b.call('$.sanitize_slots', b.id('$$props'))));
431431
}
432432

433-
const body = [
434-
...state.hoisted,
435-
...module.body,
436-
b.function_declaration(
437-
b.id(analysis.name),
438-
[b.id('$$anchor'), b.id('$$props')],
439-
component_block
440-
)
441-
];
433+
const body = [...state.hoisted, ...module.body];
434+
435+
const component = b.function_declaration(
436+
b.id(analysis.name),
437+
[b.id('$$anchor'), b.id('$$props')],
438+
component_block
439+
);
442440

443441
if (options.hmr) {
444442
body.push(
443+
component,
445444
b.if(
446445
b.id('import.meta.hot'),
447446
b.block([
@@ -459,12 +458,14 @@ export function client_component(source, analysis, options) {
459458
)
460459
)
461460
])
462-
)
461+
),
462+
463+
b.export_default(b.id(analysis.name))
463464
);
465+
} else {
466+
body.push(b.export_default(component));
464467
}
465468

466-
body.push(b.export_default(b.id(analysis.name)));
467-
468469
if (options.dev) {
469470
if (options.filename) {
470471
let filename = options.filename;

0 commit comments

Comments
 (0)