-
Notifications
You must be signed in to change notification settings - Fork 51
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
Extensions option added #24
Conversation
- added extensions option, which should contain list of additional extensions that should be also processed by vite-plugin-solid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick pass, ping me if you have any questions :)
src/index.ts
Outdated
if (id.includes('tsx')) { | ||
opts.presets.push([ts, options.typescript || {}]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@high1 Can we keep this format? I prefer things to be explicit rather than one liners. It eases the readability in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've did this because
if (!/.[jt]sx/.test(id)) return null;
line 296
src/index.ts
Outdated
if (!(/\.[jt]sx/.test(id) || options.extensions?.includes(getExtension(id).split('?')[0]))) | ||
return null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@high1 I'd prefer to break that into two different steps to improve readability.
Something like that:
if (!(/\.[jt]sx/.test(id) || options.extensions?.includes(getExtension(id).split('?')[0]))) | |
return null; | |
if (options.extensions) { | |
const extension = getExtension(id); | |
const [extensionWithoutMdFlag] = extension.split('?'); | |
if (options.extensions.includes(extensionWithoutMdFlag)) return null | |
} | |
if (!(/\.[jt]sx/.test(id)) return null; | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I have some kind of passion for one liners, but those can be hard to read...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally get it, I too have this thing, it's really a JS thing haha
The issue here is that I want anyone to be able to come in and be able to contribute without having to worry about code structure.
If we had another check to do within that if, that person would have to add { }
As per discussions, I also think its a good idea to have the options passed with the extensions be an object with config for the compiler..
This will allow us to add more options if we need them (and considering the compiler approach, its probably going to require configuration for like custom renderers, etc). |
- made everything more explicit, as requested - added optional typescript opt-in behavior per extension, like ['.solid', { typescript: true }]
- check if options.extensions is defined before calling find
extensions that should be also processed by vite-plugin-solid