-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
feat(node/plugins): esbuild options #11049
Conversation
- since https://github.com/evanw/esbuild/releases/tag/v0.14.51 esbuild supports JSX transformations, so it makes sense that jsx and jsxImportSource are forwarded along with other relevant options
Should this be closed, @bluwy ? Or should precedence be added to esbuild config, if it exists? Maybe something like
options?.[field] would make sure that the option from vite config takes precedence. |
Yeah having the esbuild options take precedence over the ones in tsconfig makes sense to me. We could update this PR to re-apply #10374, or open a new PR (whichever you prefer). But maybe @sapphi-red has some thoughts about this before we move forward. |
Yeah, I think the same as @bluwy (esbuild options should take precedence over tsconfig ones). I think we should skip adding some values to |
@high1 let us know if you plan to work on this feature. Our plan is to release the first beta of Vite 4 in a few days and cut the major around Dec 10th, and I agree with @bluwy and @sapphi-red that the major is a good opportunity to go ahead with this change. We could take this over if you are busy, there is no problem. |
@patak-dev I am planning to work, yes, and would be very excited to contribute. I was a bit overwhelmed with other stuff, but now I'm able to finish the PR. Considering what @sapphi-red said, would an acceptable course of action be to remove the features that are overriden in Vite configuration could from resolved TypeScript configuration? This would avoid the need of hand-mapping the properties, but I'm not sure if removing something here would have other unwanted effects?
options are TransformOptions in src/node/plugins/esbuild. If I'm completely missing what should be done here, I would appreciate some guidance, @bluwy , @sapphi-red . |
@high1 That looks good to me! a quick benchmarkconsole.time('delete')
for (let i = 0; i < 1000; i++) {
const foo = { bar: 'bar' }
delete foo.bar
}
console.timeEnd('delete')
console.time('assign undefined')
for (let i = 0; i < 1000; i++) {
const foo = { bar: 'bar' }
foo.bar = undefined
}
console.timeEnd('assign undefined') result on my machine |
- set TSConfigRaw options to undefined when a parallel option is defined inside Vite configuration
Updated the PR - added changes from #10374, increased esbuild version to ^0.15.11 to make sure that relevant options are defined and changed the implementation to set relevant TSConfigRaw options to undefined when defined in Vite configuration - this way, if both are defined, Vite configuration takes precedence. |
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.
Would you add a test here to make sure removing tsconfig.compilerOptions
works as we expect in future esbuild versions too?
vite/packages/vite/src/node/__tests__/plugins/esbuild.spec.ts
Lines 244 to 252 in c26679a
describe('transformWithEsbuild', () => { | |
test('not throw on inline sourcemap', async () => { | |
const result = await transformWithEsbuild(`const foo = 'bar'`, '', { | |
sourcemap: 'inline' | |
}) | |
expect(result?.code).toBeTruthy() | |
expect(result?.map).toBeTruthy() | |
}) | |
}) |
@high1 We merged this PR without tests to test it out. If you are not going to add a test, please let us know. I'll take it. If you are going to, no rush. 👍 |
@sapphi-red I just didn't have the time - hoping to finish the tests this week. |
Co-authored-by: sapphi-red <green@sapphi.red>
Description
Since https://github.com/evanw/esbuild/releases/tag/v0.14.51 esbuild supports JSX transformations, so it makes sense that jsx and jsxImportSource are forwarded along with other relevant options
Additional context
This PR just extends the list of relevant fields that are forwarded to esbuild. Now, using voby without any plugins, it's needed to duplicate these options in vite configuration also, like here https://github.com/high1/voby-clock/blob/main/vite.config.ts. Using feature for this change is maybe incorrect, but it's also not a bug fix, or is it?
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).