Skip to content
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

create-svelte TypeScript project should use vite.config.ts instead of vite.config.js #8258

Merged
merged 5 commits into from
Jan 5, 2023

Conversation

AmFlint
Copy link
Contributor

@AmFlint AmFlint commented Dec 25, 2022

Description

Hello !

I opened this PR regarding the issue #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:

  • 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. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Dec 25, 2022

🦋 Changeset detected

Latest commit: c636d89

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

@AmFlint AmFlint changed the title enhance: svelte create typescript project use vite.config.ts create-svelte TypeScript project should use vite.config.ts instead of vite.config.js Dec 25, 2022
@AmFlint
Copy link
Contributor Author

AmFlint commented Dec 25, 2022

Test failures on macos and webkit seems unrelated to this PR

@benmccann
Copy link
Member

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

@bluwy
Copy link
Member

bluwy commented Dec 28, 2022

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.

@dominikg
Copy link
Member

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.

@AmFlint
Copy link
Contributor Author

AmFlint commented Dec 30, 2022

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).

@Rich-Harris
Copy link
Member

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

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.

5 participants