Skip to content

feat: type resolve with the correct trailing slash option#15027

Merged
teemingc merged 29 commits intosveltejs:mainfrom
jycouet:feat/trail
Feb 14, 2026
Merged

feat: type resolve with the correct trailing slash option#15027
teemingc merged 29 commits intosveltejs:mainfrom
jycouet:feat/trail

Conversation

@jycouet
Copy link
Contributor

@jycouet jycouet commented Dec 4, 2025

If we have routes/path-a/+page.svelte

The function resolve() propose us two options today

resolve('/path-a')
resolve('/path-a/')

As trailing slash default is never, I would expect that resolve('/path-a/') is not available.
If you set always, I would expect only resolve('/path-a/') to be available.

This PR is addressing this.
But... not that happy that:

I added a few unit tests to help playing around.
Any help on the stuff I'm not happy about ?


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

🦋 Changeset detected

Latest commit: 0c10c56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link

@teemingc teemingc changed the title resolve & trailing_slash feat: type resolve with the correct trailing slash option Dec 5, 2025
@teemingc
Copy link
Member

teemingc commented Feb 5, 2026

I've left two TODOs in packages/kit/src/core/sync/write_types/index.js and packages/kit/src/core/sync/sync.js. Aside from that, this PR is looking promising! Might even split out some of the static analysis changes so that it's easier to review.

@jycouet
Copy link
Contributor Author

jycouet commented Feb 6, 2026

I should get back at it! Thx 👍

@jycouet
Copy link
Contributor Author

jycouet commented Feb 7, 2026

I pulled main & looked at the TODOs, let me know what do you think @teemingc

Note: the Pathname update is now handled at the sync.js level after write_types() returns

@teemingc teemingc marked this pull request as ready for review February 12, 2026 18:25
Copy link
Member

@teemingc teemingc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Thank you.

@teemingc teemingc merged commit 0e3e4f6 into sveltejs:main Feb 14, 2026
25 checks passed
@github-actions github-actions bot mentioned this pull request Feb 14, 2026
@jycouet jycouet deleted the feat/trail branch February 23, 2026 08:31
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
…5027)

If we have `routes/path-a/+page.svelte`

The function `resolve()` propose us two options today
```ts
resolve('/path-a')
resolve('/path-a/')
```

As trailing slash default is `never`, I would expect that
`resolve('/path-a/')` is not available.
If you set `always`, I would expect only `resolve('/path-a/')` to be
available.

This PR is addressing this.
But... not that happy that:
- [x] I have to `read` in
`packages/kit/src/core/sync/create_manifest_data/index.js`
- [x] didn't manage to use
https://github.com/jycouet/kit/blob/7acee7aef9ac80614f9a78635cdf4a2a23785961/packages/kit/src/exports/vite/static_analysis/index.js#L213
as it's async

I added a few unit tests to help playing around.
Any help on the stuff I'm not happy about ?

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- [ ] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it
solves.
- [x] Ideally, include a test that fails without this PR but passes with
it.

### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets
- [x] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.

---------

Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants