Skip to content

fix: resolve every module entry point using kit.moduleExtensions - #17043

Open
fgallaire wants to merge 1 commit into
sveltejs:version-3from
fgallaire:hooks-module-extensions
Open

fgallaire wants to merge 1 commit into
sveltejs:version-3from
fgallaire:hooks-module-extensions

Conversation

@fgallaire

Copy link
Copy Markdown

resolve_entry matched /\.(js|ts)$/, so kit.moduleExtensions was honoured by the router but nowhere else. A project that compiles another language to JavaScript could have route modules in that language, yet had to keep src/hooks.server.js as a shim re-exporting from the real file — and the same went for the param matchers, the service worker, the instrumentation file and src/env.

resolve_entry now takes the list of extensions to accept, defaulting to ['.js', '.ts'] so nothing changes for anyone who does not set moduleExtensions, and every entry point that is a module passes config.moduleExtensions. check_spelling takes them too, so a misspelled hooks.sever.py is caught the same way hooks.sever.js is.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Sep 6, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 0a2668a:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/0a2668a7d08eb94ee7f0c1c75fca61b4b75dafdd

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17043

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0a2668a

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

test('ignores extensions that are not listed', () => {
write('hooks.server.py', '');

expect(resolve_entry(join(source_dir, 'hooks.server'))).null;

@vercel vercel Bot Sep 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test "ignores extensions that are not listed" uses .null which is a no-op property access rather than a real Vitest matcher, so the test passes unconditionally and never validates the moduleExtensions boundary behavior.

Fix on Vercel

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: QUIET

Plan: Advanced

Run ID: 4cd82e9b-2deb-420b-a981-3a232f251727

📥 Commits

Reviewing files that changed from the base of the PR and between c36e857 and 0a2668a.

⛔ Files ignored due to path filters (1)
  • packages/kit/types/index.d.ts is excluded by !packages/kit/types/**
📒 Files selected for processing (1)
  • packages/kit/src/exports/vite/public.d.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • sveltejs/vite-plugin-svelte (manual)
  • vitejs/vite (manual)
  • sveltejs/svelte (manual)

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

resolve_entry now accepts configured module extensions for sibling and index-file lookup. Kit core and Vite entry points pass moduleExtensions when resolving service workers, hooks, parameters, environment entries, and instrumentation files. Spelling checks use the same extensions. Tests cover supported files, unsupported extensions, and index files. A changeset records the patch release.

Merge Risk: ⚪ Minimal · up to 0a266

Module entry resolution now consistently honors configured extensions across Kit entry points, with matching documentation and resolver coverage. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required fix: prefix and clearly summarises the main change: resolving module entry points with kit.moduleExtensions.
Backward Compatibility Impact Disclosure ✅ Passed No breaking public-interface change is introduced. The PR adds an optional argument to the internal resolve_entry helper, keeps its default extensions as ['.js', '.ts'], and retains the optional `…

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/kit/src/exports/vite/public.d.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


Comment @coderabbitai help to get the list of available commands.

`resolve_entry` matched `/\.(js|ts)$/`, so `kit.moduleExtensions` was honoured
by the router but nowhere else. A project that compiles another language to
JavaScript could have route modules in that language, yet had to keep
`src/hooks.server.js` as a shim re-exporting from the real file — and the same
went for the param matchers, the service worker, the instrumentation file and
`src/env`.

`resolve_entry` now takes the list of extensions to accept, defaulting to
`['.js', '.ts']` so nothing changes for anyone who does not set
`moduleExtensions`, and every entry point that is a module passes
`config.moduleExtensions`. `check_spelling` takes them too, so a misspelled
`hooks.sever.py` is caught the same way `hooks.sever.js` is.
@fgallaire
fgallaire force-pushed the hooks-module-extensions branch from c36e857 to 0a2668a Compare September 7, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant