vite-plugin-solid
vite-plugin-solid copied to clipboard
Remove `@babel/preset-typescript`
- Option
typescript
is unused by the majority I believe -
typescript
parsing can be bypassed byparserOpts.plugin = ['typescript']
, you can see an example here: https://github.com/lxsmnsyc/solid-styled/blob/main/packages/vite/src/index.ts#L66-L69 -
typescript
preset performs the TS-to-JS compilation, I don't think we want this
I didn't write this plugin so I can't speak to it. But assuming we don't do the TS conversion the expectation is the downstream tool does? Can we make that assumption. I'm open to this if we know Vite will just handle this for the files we process. I wonder if there are any other implications. I trust you if you've tested this.
The transform step in the link I gave is actually based on what Prefresh does in their Vite plugin: https://github.com/preactjs/prefresh/blob/main/packages/vite/src/index.js#L27-L34
so if anything, they have tested this more realistically. It works as I've tested. My only concern really here is if anyone actually uses the typescript
option in the plugin, in which case we can just recommend users to install @babel/preset-typescript
on their own.
Hi. I actually use typescript option for this:
solid({
typescript: {
allowDeclareFields: true,
},
})
Otherwise, my build fails because declare
is not allowed without that setting
4:42:58 PM [vite] Internal server error: /home/eptadot/source/md-web-widgets-elec-2024/assets/stimulus/controllers/Form/CandidateCollectionController/index.tsx: The 'declare' modifier is only allowed when the 'allowDeclareFields' option of @babel/plugin-transform-typescript or @babel/preset-typescript is enabled.
23 |
> 24 | declare readonly nameValue: string;
Can I use declare
without that setting after removing @babel/preset-typescript
? I suppose yes but I want to be sure.
yes you can. The new setup just enables Babel to understand TypeScript syntax.