fix: prevent false-positive ownership validations due to hot reload ()

The component identity could change due to HMR, so we fall back to checking the filenames as well

fixes 
pull/15156/head
Simon H 3 months ago committed by GitHub
parent 83f00ebbd6
commit 970aa7cfaa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: prevent false-positive ownership validations due to hot reload

@ -220,6 +220,10 @@ function has_owner(metadata, component) {
return (
metadata.owners.has(component) ||
// This helps avoid false positives when using HMR, where the component function is replaced
[...metadata.owners].some(
(owner) => /** @type {any} */ (owner)[FILENAME] === /** @type {any} */ (component)?.[FILENAME]
) ||
(metadata.parent !== null && has_owner(metadata.parent, component))
);
}

Loading…
Cancel
Save