Skip to content

Commit

Permalink
[feat] allow .d.ts files to have + prefix (#7682)
Browse files Browse the repository at this point in the history
closes #7662
  • Loading branch information
Rich-Harris committed Nov 16, 2022
1 parent 9dee9c9 commit 172e792
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-dolls-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow .d.ts files to have a + prefix
14 changes: 14 additions & 0 deletions packages/kit/src/core/sync/create_manifest_data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,20 @@ function create_routes_and_nodes(cwd, config, fallback) {
if (!file.name.startsWith('+')) continue;
if (!valid_extensions.find((ext) => file.name.endsWith(ext))) continue;

if (file.name.endsWith('.d.ts')) {
let name = file.name.slice(0, -5);
const ext = valid_extensions.find((ext) => name.endsWith(ext));
if (ext) name = name.slice(0, -ext.length);

const valid =
/^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/.test(name) ||
/^\+(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\.server)?))$/.test(
name
);

if (valid) continue;
}

const project_relative = posixify(path.relative(cwd, path.join(dir, file.name)));

const item = analyze(
Expand Down
Empty file.

0 comments on commit 172e792

Please sign in to comment.