fix: further improvements to hmr component key generation (#11129)

pull/11130/head
Dominic Gannaway 9 months ago committed by GitHub
parent 3f9f28604e
commit 0896543e67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: further improvements to hmr component key generation

@ -422,7 +422,10 @@ export function client_component(source, analysis, options) {
)
];
if (options.hmr) {
// In order for hmr to work correctly, we need associate each component with a unique key.
// This is because bundlers might put many components into a the same module (usuaully as a chunk).
// `import.meta.hot` will then be the same object for all components in that modules.
if (options.hmr && options.filename) {
body.push(
b.export_default(
b.conditional(
@ -431,7 +434,7 @@ export function client_component(source, analysis, options) {
'$.hmr',
b.member(b.import_meta_hot(), b.id('data')),
b.id(analysis.name),
b.member(b.member(b.id('import'), b.id('meta')), b.id('url'))
b.literal(options.filename)
),
b.id(analysis.name)
)

Loading…
Cancel
Save