Skip to content

Commit

Permalink
[fix] account for relative route path during types generation (#7223)
Browse files Browse the repository at this point in the history
Currently when using relative route path in `config.kit.files.routes` e.g. `../../project/src/routes` sync fails because it generates types outside of `.svelte-kit/types` 
It should account for relative paths and generate them inside `.svelte-kit/types`
fixes #7166
  • Loading branch information
gbkwiatt committed Oct 12, 2022
1 parent b4c2680 commit 0fc2193
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-jeans-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Account for relative path to routes in `config.kit.files.routes`
4 changes: 2 additions & 2 deletions packages/kit/src/core/sync/write_types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function write_all_types(config, manifest_data) {
const types_dir = `${config.kit.outDir}/types`;

// empty out files that no longer need to exist
const routes_dir = path.relative('.', config.kit.files.routes);
const routes_dir = posixify(path.relative('.', config.kit.files.routes)).replace(/\.\.\//g, '');
const expected_directories = new Set(
manifest_data.routes.map((route) => path.join(routes_dir, route.id))
);
Expand Down Expand Up @@ -179,7 +179,7 @@ function create_routes_map(manifest_data) {
* @param {Set<string>} [to_delete]
*/
function update_types(config, routes, route, to_delete = new Set()) {
const routes_dir = posixify(path.relative('.', config.kit.files.routes));
const routes_dir = posixify(path.relative('.', config.kit.files.routes)).replace(/\.\.\//g, '');
const outdir = path.join(config.kit.outDir, 'types', routes_dir, route.id);

// now generate new types
Expand Down

0 comments on commit 0fc2193

Please sign in to comment.