From 5c086bb20ce1e206e2ca85526732513184886c14 Mon Sep 17 00:00:00 2001 From: William Viktorsson Date: Thu, 15 Sep 2022 23:43:50 +0200 Subject: [PATCH 1/5] fix route's not being found by id under group layouts Fixes #6842: Types are not properly updated for routes under group layouts routes were not found by id under group layouts. replacing '\' with '/' fixes this for route id's. --- packages/kit/src/core/sync/write_types/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index b925be7735b3..e9410122fe06 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -69,8 +69,8 @@ export async function write_types(config, manifest_data, file) { } const id = path.relative(config.kit.files.routes, path.dirname(file)); - - const route = manifest_data.routes.find((route) => route.id === id); + //replace '\' with '/' to fix #6842, routes not being found under layout groups + const route = manifest_data.routes.find((route) => route.id === id || route.id === id.replace(/\\/g, '/')); if (!route) return; // this shouldn't ever happen update_types(config, create_routes_map(manifest_data), route); From 3c6da8e51bf1345d56810777ec0d023f7e3c24e4 Mon Sep 17 00:00:00 2001 From: William Viktorsson Date: Thu, 15 Sep 2022 23:49:40 +0200 Subject: [PATCH 2/5] update to conform to linting --- packages/kit/src/core/sync/write_types/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index e9410122fe06..70d3aac6115e 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -69,7 +69,6 @@ export async function write_types(config, manifest_data, file) { } const id = path.relative(config.kit.files.routes, path.dirname(file)); - //replace '\' with '/' to fix #6842, routes not being found under layout groups const route = manifest_data.routes.find((route) => route.id === id || route.id === id.replace(/\\/g, '/')); if (!route) return; // this shouldn't ever happen From 13038446c4bbf472aea321ca5ba77a841acbb212 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 16 Sep 2022 12:00:23 -0400 Subject: [PATCH 3/5] Update packages/kit/src/core/sync/write_types/index.js --- packages/kit/src/core/sync/write_types/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index 70d3aac6115e..41d2d1544609 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -68,7 +68,7 @@ export async function write_types(config, manifest_data, file) { return; } - const id = path.relative(config.kit.files.routes, path.dirname(file)); + const id = path.posix.relative(config.kit.files.routes, path.dirname(file)); const route = manifest_data.routes.find((route) => route.id === id || route.id === id.replace(/\\/g, '/')); if (!route) return; // this shouldn't ever happen From 18e20ad80a16596ef690e557d5e02c330f703d7b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 16 Sep 2022 12:00:27 -0400 Subject: [PATCH 4/5] Update packages/kit/src/core/sync/write_types/index.js --- packages/kit/src/core/sync/write_types/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index 41d2d1544609..b9f1245e4f07 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -69,7 +69,8 @@ export async function write_types(config, manifest_data, file) { } const id = path.posix.relative(config.kit.files.routes, path.dirname(file)); - const route = manifest_data.routes.find((route) => route.id === id || route.id === id.replace(/\\/g, '/')); + + const route = manifest_data.routes.find((route) => route.id === id); if (!route) return; // this shouldn't ever happen update_types(config, create_routes_map(manifest_data), route); From cda5cb15b6e6df0d1bd5969d77aef946a0a32574 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 16 Sep 2022 12:01:46 -0400 Subject: [PATCH 5/5] Create six-pants-melt.md --- .changeset/six-pants-melt.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/six-pants-melt.md diff --git a/.changeset/six-pants-melt.md b/.changeset/six-pants-melt.md new file mode 100644 index 000000000000..9491b8e50c1d --- /dev/null +++ b/.changeset/six-pants-melt.md @@ -0,0 +1,5 @@ +--- +"@sveltejs/kit": patch +--- + +fix `write_types` on windows