Skip to content

Commit c63aaa7

Browse files
committed
feat: move dev-time component properties to private symbols
1 parent a7442f6 commit c63aaa7

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.changeset/fluffy-colts-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
feat: move dev-time component properties to private symbols'

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export function client_component(source, analysis, options) {
418418

419419
if (options.hmr) {
420420
const accept_fn_body = [
421-
b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module.default'), b.id('original'))))
421+
b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module.default'), b.id('$.ORIGINAL'), true)))
422422
];
423423

424424
if (analysis.css.hash) {
@@ -446,7 +446,11 @@ export function client_component(source, analysis, options) {
446446
// Assign the original component to the wrapper so we can use it on hot reload patching,
447447
// else we would call the HMR function two times
448448
b.stmt(
449-
b.assignment('=', b.member(b.id(analysis.name), b.id('original')), b.id('$$original'))
449+
b.assignment(
450+
'=',
451+
b.member(b.id(analysis.name), b.id('$.ORIGINAL'), true),
452+
b.id('$$original')
453+
)
450454
),
451455
b.stmt(b.call('import.meta.hot.accept', b.arrow([b.id('module')], b.block(accept_fn_body))))
452456
]);

packages/svelte/tests/snapshot/samples/hmr/_expected/client/index.svelte.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ if (import.meta.hot) {
1616

1717
Hmr = $.hmr(s);
1818
Hmr.filename = filename;
19-
Hmr.original = $$original;
19+
Hmr[$.ORIGINAL] = $$original;
2020

2121
import.meta.hot.accept((module) => {
22-
$.set(s, module.default.original);
22+
$.set(s, module.default[$.ORIGINAL]);
2323
});
2424
}
2525

0 commit comments

Comments
 (0)