-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add typescript version of svelte.config.js #2576
Comments
If this was implemented, it would be as part of sveltejs/rfcs#59 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Again, all this has nothing to do with the original issue, so I'm going to mark this conversation as off topic. Please search for related issues, and if you don't find one, open a separate issue detailing your problem and ideally providing a minimum reproducible. |
Using unconfig would make it quite easy to implement. |
see #4105 |
Workaround: npm install -D esbuild And then run the following command before you run "build:svelteconfig": "esbuild svelte.config.ts --outfile=svelte.config.js" |
In my project I've also the use case of wanting to write a vite plugin in TypeScript. A few weeks back, #5332 introduced Therefore the original use case described in this issue can be considered served as Vite plugins in TS are now a thing. It might make sense to close this issue and instead reopen #5867 which is more focused and calls explicitly for a |
Working on a preprocessor written in TypeScript. Cannot import it in
|
@valterkraemer check out https://github.com/svitejs/svelte-preprocess-svg for an example of how to use tsup to build a svelte preprocessor package from ts source. |
Thanks @dominikg, was looking for a good reference implementation for a preprocessor! The hack works decently because I only call it if it exist (now updated in earlier comment). For sure not ideal, but works good enough for now. Will for sure change it to something better like you suggested if I need something better! |
I have extensive data preprocessing for my static webpage which I'm currently executing in |
Okay, as above suggested, changing the vite config to typescript ( |
It would also be nice to rewrite the kit itself on ts (svelte has already been rewritten). |
This comment was marked as duplicate.
This comment was marked as duplicate.
Not sure if this is on the radar but there might be some hen and egg problems here. At least if one expects features like svelte-kit provided env variables, access to other methods defined in the svelte code, or other functionality one might be used to within the svelte project might not be available on call of There is only very little code I actually need to run prior to My other use-case is data preprocessing on build. This I did run in Hope this helps for some use-cases you might have. |
Apparently it was clear that this is not planned as stated in #4031 (comment) |
It seems like the overall goal of being able to support a |
please don't hold your breath on that one. the rfc has been stale for quite a while and having to bundle the config from ts comes with strings attached. |
unconfig does not "just work". it uses something called jiti under the hood and has a lot of complexity. We are not going to subject everyone to that by default. You may be able to use it from svelte.config.js to load your svelte.config.ts (and whatever complex setup with custom packages you have) yourself. |
Unsure if this has been discussed or whether it's a new implementation, I have discovered success thanks to https://skeleton.dev and their migration guide on using Typescript for configuration files! import adapter from '@sveltejs/adapter-auto';
import { Config } from '@sveltejs/kit';
import { vitePreprocess } from '@sveltejs/kit/vite';
export default {
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
} satisfies Config; |
Using svelte.config.tsimport type { Config } from '@sveltejs/kit';
export default <Config>{
}; works for me out of the box. |
The esbuild workaround doesn't work with imports, as it'd also require me to |
|
@FlooferLand if I remember correctly, SvelteKit uses |
This comment was marked as off-topic.
This comment was marked as off-topic.
I made a PR to support |
This comment was marked as duplicate.
This comment was marked as duplicate.
A gentle reminder to please refrain from unhelpful comments. A solution is in the works but requires time for discussion and implementation. Some maintainers also have full-time jobs and are working on SvelteKit uncompensated in their spare time. |
Describe the problem
In the FAQ, it is said I can add a middleware in dev mode by creating a vite plugin.
But my middleware is a typescript file and I cannot import it into my svelte.config.js.
I tried to rename svelte.config.js to svelte.config.ts but got an error "Cannot find module 'C:\Users\JEROME\Documents\MesDeveloppements\SitesInternet\tarteen\svelte.config.cjs'".
Describe the proposed solution
Allow svelte config file to be written in typescript.
Alternatives considered
Don't see any
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: