Skip to content

feat: Support svelte.config.ts #13935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

dominikg
Copy link
Member

@dominikg dominikg commented Jun 26, 2025

This PR enables loading svelte.config.ts in runtimes that support importing TypeScript files.
In deno and bun this should work ootb, in nodejs >=22.6 you can use the --experimental-strip-types flag to allow it.


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.

Copy link

changeset-bot bot commented Jun 26, 2025

🦋 Changeset detected

Latest commit: 790ced2

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

This PR includes changesets to release 2 packages
Name Type
@sveltejs/package Minor
@sveltejs/kit Minor

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

@dummdidumm
Copy link
Member

The lint error is from eslint which likely trips up on multiple files just with different extensions, best to ignore that directory in the config.
The other error sounds like something from the runtime, but not sure. Maybe NodeJs because the CI runs with a version which doesn't support ts files yet?

@dominikg
Copy link
Member Author

ugh, conditionally passing --experimental-strip-types is weird.

changed test-others to a matrix to be able to test with 22 and 18.

In a separate PR we should look into adding node24 to the matrix tests.

@benmccann
Copy link
Member

I'm not sure it makes sense to support .mjs and .mts file extensions. SvelteKit projects can only be ESM projects in which case you'd never use those extensions

@dominikg
Copy link
Member Author

dominikg commented Jun 27, 2025

When it was only one exact filename svelte.config.js it made the code simpler not checking svelte.config.mjs too.

Now that this PR adds checking multiple extensions, its very easy to allow mjs and mts and those are valid even in projects where "type":"module" is in package.json. They also enable custom setups where type is commonjs (eg sveltekit app embedded in a node app package).

@benmccann
Copy link
Member

To me it's nothing about the simplicity of the code, but whether we want to encourage bad practices. There is no reason a SvelteKit project should ever lack "type": "module" or use .mjs/.mts that I can think of

@dominikg dominikg changed the title feat: Support .ts,.mjs and .mts extension for svelte.config feat: Support svelte.config.ts Jun 28, 2025
@dominikg
Copy link
Member Author

removed mjs and mts, lets see if someone asks for it. I know there's a few that use vite-plugin-svelte with svelte.config.mjs but SvelteKit can have different constraints.

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.

4 participants