create-svelte TypeScript project should use vite.config.ts instead of vite.config.js
Description
Hello !
I opened this PR regarding the issue https://github.com/sveltejs/kit/issues/8257, for TypeScript projects, it makes sense to generate vite.config.ts files. This PR is a very tiny quality of life improvement for TypeScript users but doesn't change anything in a functional way.
By default, the vite command will look for vite.config.js or vite.config.ts file.
I took this issue even though it's probaby not "required" in the project right now, but it allows me to get started with a simple task first on the SvelteKit Repository.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] 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.
- [ ] Ideally, include a test that fails without this PR but passes with it.
Tests
- [x] Run the tests with
pnpm testand lint the project withpnpm lintandpnpm 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 changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0
🦋 Changeset detected
Latest commit: c636d89e50b90593856cbf099d7f0860a42c0545
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| create-svelte | 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
Test failures on macos and webkit seems unrelated to this PR
I think @dominikg had commented previously that this may be something we'd want to avoid. I'm not sure if there's a previous discussion of it on a ticket or PR somewhere
I think it makes sense to use vite.config.ts if they chose TypeScript. There isn't a big difference with how Vite handles it if it's using .js instead.
for vite config it's a matter of taste, as vite bundles it on the fly either way (not great imho, but it is what it is). svelte config otoh always is .js, so having one config in js and others in ts isn't great either....
at the end of the day users can easily switch to the style they prefer and while I would opt for vite.config.js, defaulting to ts is ok, if that's what the majority prefers.
I honestly don't mind either, changing the extension from .js to .ts takes 2 seconds, and less maintenance (see my PR I had to move the same file to different places to fit the logic of the svelte-create package, which means if we wish to update it in the future, we'll have to update it in multiple places + test and assert it works in these different templates).
If we do this — and I personally think that bundling config files is a costly mistake and I'd love to see a future version of Vite skip the bundling step for vite.config.js and discourage the use of vite.config.ts — then we should generate both .js and .ts files from the same .ts source, like we do for other modules. I've updated the PR