fix: make ownership validation work with HMR (#11171)

* fix: make ownership validation work with HMR

* bump vite-plugin-svelte in playground

* missed a spot
pull/11162/head
Rich Harris 8 months ago committed by GitHub
parent a092899843
commit 2cefd785a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: make ownership validation work correctly with HMR

@ -464,8 +464,8 @@ export function client_component(source, analysis, options) {
);
}
body.unshift(b.stmt(b.call(b.id('$.mark_module_start'), b.id(analysis.name))));
body.push(b.stmt(b.call(b.id('$.mark_module_end'))));
body.unshift(b.stmt(b.call(b.id('$.mark_module_start'))));
body.push(b.stmt(b.call(b.id('$.mark_module_end'), b.id(analysis.name))));
}
if (options.discloseVersion) {

@ -67,9 +67,8 @@ function get_component() {
* Together with `mark_module_end`, this function establishes the boundaries of a `.svelte` file,
* such that subsequent calls to `get_component` can tell us which component is responsible
* for a given state change
* @param {Function} component
*/
export function mark_module_start(component) {
export function mark_module_start() {
const start = get_stack()?.[2];
if (start) {
@ -77,17 +76,24 @@ export function mark_module_start(component) {
start,
// @ts-expect-error
end: null,
component
// @ts-expect-error we add the component at the end, since HMR will overwrite the function
component: null
});
}
}
export function mark_module_end() {
/**
* @param {Function} component
*/
export function mark_module_end(component) {
const end = get_stack()?.[2];
if (end) {
const boundaries_file = boundaries[end.file];
boundaries_file[boundaries_file.length - 1].end = end;
const boundary = boundaries_file[boundaries_file.length - 1];
boundary.end = end;
boundary.component = component;
}
}

@ -11,7 +11,7 @@
"preview": "vite preview"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"express": "^4.19.2",
"nodemon": "^3.0.3",
"svelte": "workspace:*",

@ -145,8 +145,8 @@ importers:
playgrounds/demo:
devDependencies:
'@sveltejs/vite-plugin-svelte':
specifier: ^3.0.1
version: 3.0.1(svelte@packages+svelte)(vite@5.0.13)
specifier: ^3.1.0
version: 3.1.0(svelte@packages+svelte)(vite@5.0.13)
express:
specifier: ^4.19.2
version: 4.19.2
@ -258,13 +258,13 @@ importers:
version: 5.1.0(@sveltejs/kit@2.5.2)
'@sveltejs/kit':
specifier: ^2.5.0
version: 2.5.2(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13)
version: 2.5.2(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/site-kit':
specifier: 6.0.0-next.59
version: 6.0.0-next.59(@sveltejs/kit@2.5.2)(svelte@packages+svelte)
'@sveltejs/vite-plugin-svelte':
specifier: ^3.0.0
version: 3.0.1(svelte@packages+svelte)(vite@5.0.13)
specifier: ^3.1.0
version: 3.1.0(svelte@packages+svelte)(vite@5.0.13)
'@types/marked':
specifier: ^6.0.0
version: 6.0.0
@ -331,13 +331,13 @@ importers:
version: 4.0.5(@sveltejs/kit@2.4.3)
'@sveltejs/kit':
specifier: ^2.4.3
version: 2.4.3(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13)
version: 2.4.3(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/site-kit':
specifier: 6.0.0-next.59
version: 6.0.0-next.59(@sveltejs/kit@2.4.3)(svelte@4.2.9)
'@sveltejs/vite-plugin-svelte':
specifier: ^3.0.1
version: 3.0.1(svelte@4.2.9)(vite@5.0.13)
specifier: ^3.1.0
version: 3.1.0(svelte@4.2.9)(vite@5.0.13)
'@types/cookie':
specifier: ^0.6.0
version: 0.6.0
@ -2594,7 +2594,7 @@ packages:
peerDependencies:
'@sveltejs/kit': ^2.0.0
dependencies:
'@sveltejs/kit': 2.5.2(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/kit': 2.5.2(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13)
dev: true
/@sveltejs/adapter-vercel@4.0.5(@sveltejs/kit@2.4.3):
@ -2602,7 +2602,7 @@ packages:
peerDependencies:
'@sveltejs/kit': ^2.0.0
dependencies:
'@sveltejs/kit': 2.4.3(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/kit': 2.4.3(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13)
'@vercel/nft': 0.26.2
esbuild: 0.19.11
transitivePeerDependencies:
@ -2615,7 +2615,7 @@ packages:
peerDependencies:
'@sveltejs/kit': ^2.4.0
dependencies:
'@sveltejs/kit': 2.5.2(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/kit': 2.5.2(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13)
'@vercel/nft': 0.26.2
esbuild: 0.19.11
transitivePeerDependencies:
@ -2644,7 +2644,7 @@ packages:
typescript-eslint: 7.6.0(eslint@9.0.0)(typescript@5.3.3)
dev: true
/@sveltejs/kit@2.4.3(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13):
/@sveltejs/kit@2.4.3(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13):
resolution: {integrity: sha512-nKNhUdt61vtD961kQpUk6vLDhpnV0yku5F1uYNWvrJYFV0+cGfmW7ol0JVMSjHMXlMtmmv2FTc+nPRrTFwb2UA==}
engines: {node: '>=18.13'}
hasBin: true
@ -2654,7 +2654,7 @@ packages:
svelte: ^4.0.0 || ^5.0.0-next.0
vite: ^5.0.3
dependencies:
'@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/vite-plugin-svelte': 3.1.0(svelte@4.2.9)(vite@5.0.13)
'@types/cookie': 0.6.0
cookie: 0.6.0
devalue: 4.3.2
@ -2670,7 +2670,7 @@ packages:
tiny-glob: 0.2.9
vite: 5.0.13(@types/node@20.11.5)(lightningcss@1.23.0)(sass@1.70.0)
/@sveltejs/kit@2.5.2(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13):
/@sveltejs/kit@2.5.2(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13):
resolution: {integrity: sha512-1Pm2lsBYURQsjnLyZa+jw75eVD4gYHxGRwPyFe4DAmB3FjTVR8vRNWGeuDLGFcKMh/B1ij6FTUrc9GrerogCng==}
engines: {node: '>=18.13'}
hasBin: true
@ -2680,7 +2680,7 @@ packages:
svelte: ^4.0.0 || ^5.0.0-next.0
vite: ^5.0.3
dependencies:
'@sveltejs/vite-plugin-svelte': 3.0.1(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/vite-plugin-svelte': 3.1.0(svelte@packages+svelte)(vite@5.0.13)
'@types/cookie': 0.6.0
cookie: 0.6.0
devalue: 4.3.2
@ -2743,7 +2743,7 @@ packages:
'@sveltejs/kit': ^1.0.0
svelte: ^3.54.0
dependencies:
'@sveltejs/kit': 2.4.3(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/kit': 2.4.3(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13)
esm-env: 1.0.0
svelte: 4.2.9
svelte-local-storage-store: 0.4.0(svelte@4.2.9)
@ -2755,7 +2755,7 @@ packages:
'@sveltejs/kit': ^1.20.0
svelte: ^4.0.0
dependencies:
'@sveltejs/kit': 2.4.3(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/kit': 2.4.3(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13)
esm-env: 1.0.0
svelte: 4.2.9
svelte-local-storage-store: 0.6.4(svelte@4.2.9)
@ -2767,13 +2767,13 @@ packages:
'@sveltejs/kit': ^1.20.0
svelte: ^4.0.0
dependencies:
'@sveltejs/kit': 2.5.2(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/kit': 2.5.2(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13)
esm-env: 1.0.0
svelte: link:packages/svelte
svelte-local-storage-store: 0.6.4(svelte@packages+svelte)
dev: true
/@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13):
/@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13):
resolution: {integrity: sha512-gjr9ZFg1BSlIpfZ4PRewigrvYmHWbDrq2uvvPB1AmTWKuM+dI1JXQSUu2pIrYLb/QncyiIGkFDFKTwJ0XqQZZg==}
engines: {node: ^18.0.0 || >=20}
peerDependencies:
@ -2781,14 +2781,14 @@ packages:
svelte: ^4.0.0 || ^5.0.0-next.0
vite: ^5.0.0
dependencies:
'@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/vite-plugin-svelte': 3.1.0(svelte@4.2.9)(vite@5.0.13)
debug: 4.3.4(supports-color@5.5.0)
svelte: 4.2.9
vite: 5.0.13(@types/node@20.11.5)(lightningcss@1.23.0)(sass@1.70.0)
transitivePeerDependencies:
- supports-color
/@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13):
/@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13):
resolution: {integrity: sha512-gjr9ZFg1BSlIpfZ4PRewigrvYmHWbDrq2uvvPB1AmTWKuM+dI1JXQSUu2pIrYLb/QncyiIGkFDFKTwJ0XqQZZg==}
engines: {node: ^18.0.0 || >=20}
peerDependencies:
@ -2796,7 +2796,7 @@ packages:
svelte: ^4.0.0 || ^5.0.0-next.0
vite: ^5.0.0
dependencies:
'@sveltejs/vite-plugin-svelte': 3.0.1(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/vite-plugin-svelte': 3.1.0(svelte@packages+svelte)(vite@5.0.13)
debug: 4.3.4(supports-color@5.5.0)
svelte: link:packages/svelte
vite: 5.0.13(@types/node@20.11.5)(lightningcss@1.23.0)(sass@1.70.0)
@ -2804,39 +2804,39 @@ packages:
- supports-color
dev: true
/@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.2.9)(vite@5.0.13):
resolution: {integrity: sha512-CGURX6Ps+TkOovK6xV+Y2rn8JKa8ZPUHPZ/NKgCxAmgBrXReavzFl8aOSCj3kQ1xqT7yGJj53hjcV/gqwDAaWA==}
/@sveltejs/vite-plugin-svelte@3.1.0(svelte@4.2.9)(vite@5.0.13):
resolution: {integrity: sha512-sY6ncCvg+O3njnzbZexcVtUqOBE3iYmQPJ9y+yXSkOwG576QI/xJrBnQSRXFLGwJNBa0T78JEKg5cIR0WOAuUw==}
engines: {node: ^18.0.0 || >=20}
peerDependencies:
svelte: ^4.0.0 || ^5.0.0-next.0
vite: ^5.0.0
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 2.0.0(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@4.2.9)(vite@5.0.13)
'@sveltejs/vite-plugin-svelte-inspector': 2.0.0(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@4.2.9)(vite@5.0.13)
debug: 4.3.4(supports-color@5.5.0)
deepmerge: 4.3.1
kleur: 4.1.5
magic-string: 0.30.5
magic-string: 0.30.9
svelte: 4.2.9
svelte-hmr: 0.15.3(svelte@4.2.9)
svelte-hmr: 0.16.0(svelte@4.2.9)
vite: 5.0.13(@types/node@20.11.5)(lightningcss@1.23.0)(sass@1.70.0)
vitefu: 0.2.5(vite@5.0.13)
transitivePeerDependencies:
- supports-color
/@sveltejs/vite-plugin-svelte@3.0.1(svelte@packages+svelte)(vite@5.0.13):
resolution: {integrity: sha512-CGURX6Ps+TkOovK6xV+Y2rn8JKa8ZPUHPZ/NKgCxAmgBrXReavzFl8aOSCj3kQ1xqT7yGJj53hjcV/gqwDAaWA==}
/@sveltejs/vite-plugin-svelte@3.1.0(svelte@packages+svelte)(vite@5.0.13):
resolution: {integrity: sha512-sY6ncCvg+O3njnzbZexcVtUqOBE3iYmQPJ9y+yXSkOwG576QI/xJrBnQSRXFLGwJNBa0T78JEKg5cIR0WOAuUw==}
engines: {node: ^18.0.0 || >=20}
peerDependencies:
svelte: ^4.0.0 || ^5.0.0-next.0
vite: ^5.0.0
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 2.0.0(@sveltejs/vite-plugin-svelte@3.0.1)(svelte@packages+svelte)(vite@5.0.13)
'@sveltejs/vite-plugin-svelte-inspector': 2.0.0(@sveltejs/vite-plugin-svelte@3.1.0)(svelte@packages+svelte)(vite@5.0.13)
debug: 4.3.4(supports-color@5.5.0)
deepmerge: 4.3.1
kleur: 4.1.5
magic-string: 0.30.5
magic-string: 0.30.9
svelte: link:packages/svelte
svelte-hmr: 0.15.3(svelte@packages+svelte)
svelte-hmr: 0.16.0(svelte@packages+svelte)
vite: 5.0.13(@types/node@20.11.5)(lightningcss@1.23.0)(sass@1.70.0)
vitefu: 0.2.5(vite@5.0.13)
transitivePeerDependencies:
@ -3547,7 +3547,7 @@ packages:
hasBin: true
dependencies:
caniuse-lite: 1.0.30001609
electron-to-chromium: 1.4.735
electron-to-chromium: 1.4.736
node-releases: 2.0.14
update-browserslist-db: 1.0.13(browserslist@4.23.0)
dev: true
@ -4208,8 +4208,8 @@ packages:
resolution: {integrity: sha512-q4lkcbQrUdlzWCUOxk6fwEza6bNCfV12oi4AJph5UibguD1aTfL4uD0nuzFv9hbPANXQMuUS0MxPSHQ1gqq5dg==}
dev: true
/electron-to-chromium@1.4.735:
resolution: {integrity: sha512-pkYpvwg8VyOTQAeBqZ7jsmpCjko1Qc6We1ZtZCjRyYbT5v4AIUKDy5cQTRotQlSSZmMr8jqpEt6JtOj5k7lR7A==}
/electron-to-chromium@1.4.736:
resolution: {integrity: sha512-Rer6wc3ynLelKNM4lOCg7/zPQj8tPOCB2hzD32PX9wd3hgRRi9MxEbmkFCokzcEhRVMiOVLjnL9ig9cefJ+6+Q==}
dev: true
/emoji-regex@10.3.0:
@ -6011,6 +6011,12 @@ packages:
dependencies:
'@jridgewell/sourcemap-codec': 1.4.15
/magic-string@0.30.9:
resolution: {integrity: sha512-S1+hd+dIrC8EZqKyT9DstTH/0Z+f76kmmvZnkfQVmOpDEF9iVgdYif3Q/pIWHmCoo59bQVGW0kVL3e2nl+9+Sw==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/sourcemap-codec': 1.4.15
/magicast@0.3.3:
resolution: {integrity: sha512-ZbrP1Qxnpoes8sz47AM0z08U+jW6TyRgZzcWy3Ma3vDhJttwMwAFDMMQFobwdBxByBD46JYmxRzeF7w2+wJEuw==}
dependencies:
@ -7976,16 +7982,16 @@ packages:
svelte: link:packages/svelte
dev: true
/svelte-hmr@0.15.3(svelte@4.2.9):
resolution: {integrity: sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==}
/svelte-hmr@0.16.0(svelte@4.2.9):
resolution: {integrity: sha512-Gyc7cOS3VJzLlfj7wKS0ZnzDVdv3Pn2IuVeJPk9m2skfhcu5bq3wtIZyQGggr7/Iim5rH5cncyQft/kRLupcnA==}
engines: {node: ^12.20 || ^14.13.1 || >= 16}
peerDependencies:
svelte: ^3.19.0 || ^4.0.0
dependencies:
svelte: 4.2.9
/svelte-hmr@0.15.3(svelte@packages+svelte):
resolution: {integrity: sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==}
/svelte-hmr@0.16.0(svelte@packages+svelte):
resolution: {integrity: sha512-Gyc7cOS3VJzLlfj7wKS0ZnzDVdv3Pn2IuVeJPk9m2skfhcu5bq3wtIZyQGggr7/Iim5rH5cncyQft/kRLupcnA==}
engines: {node: ^12.20 || ^14.13.1 || >= 16}
peerDependencies:
svelte: ^3.19.0 || ^4.0.0

@ -17,7 +17,7 @@
"@sveltejs/adapter-vercel": "^5.0.0",
"@sveltejs/kit": "^2.5.0",
"@sveltejs/site-kit": "6.0.0-next.59",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@types/marked": "^6.0.0",
"esrap": "^1.2.1",
"marked": "^9.0.0",

@ -31,7 +31,7 @@
"@sveltejs/adapter-vercel": "^4.0.0",
"@sveltejs/kit": "^2.4.3",
"@sveltejs/site-kit": "6.0.0-next.59",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@types/cookie": "^0.6.0",
"@types/node": "^20.11.5",
"browserslist": "^4.22.2",

Loading…
Cancel
Save