Skip to content

Commit

Permalink
[fix] rebuild manifest when client hooks or param matcher file is add…
Browse files Browse the repository at this point in the history
…ed/removed (#7915)

* [fix] rebuild manifest when client hook file is added/removed

In contrast to server hooks, client hooks are written to the client manifest and therefore need rebuilding when they are added/removed

* also applies to param matchers
  • Loading branch information
dummdidumm committed Dec 2, 2022
1 parent dd380b3 commit 78a2322
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-trainers-perform.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] rebuild manifest when client hooks or param matcher file is added/removed
2 changes: 1 addition & 1 deletion packages/kit/src/core/sync/write_types/index.js
Expand Up @@ -150,7 +150,7 @@ export async function write_types(config, manifest_data, file) {
const id = '/' + posixify(path.relative(config.kit.files.routes, path.dirname(file)));

const route = manifest_data.routes.find((route) => route.id === id);
if (!route) return; // this shouldn't ever happen
if (!route) return;
if (!route.leaf && !route.layout && !route.endpoint) return; // nothing to do

update_types(config, create_routes_map(manifest_data), route);
Expand Down
8 changes: 7 additions & 1 deletion packages/kit/src/exports/vite/dev/index.js
Expand Up @@ -202,7 +202,13 @@ export async function dev(vite, vite_config, svelte_config) {
*/
const watch = (event, cb) => {
vite.watcher.on(event, (file) => {
if (file.startsWith(svelte_config.kit.files.routes + path.sep)) {
if (
file.startsWith(svelte_config.kit.files.routes + path.sep) ||
file.startsWith(svelte_config.kit.files.params + path.sep) ||
// in contrast to server hooks, client hooks are written to the client manifest
// and therefore need rebuilding when they are added/removed
file.startsWith(svelte_config.kit.files.hooks.client)
) {
cb(file);
}
});
Expand Down

0 comments on commit 78a2322

Please sign in to comment.