-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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: add optimizeDeps.esbuildOptions #2991
Conversation
Thanks for your PR, related to mine. In my work I have also to include eslint plugins in this scan phase :
|
Yet, I'm not convinced about the choice to place Keeping your idea in mind, we should also deprecate
|
@nihalgonsalves we discussed with Evan, this PR is a good first step towards allowing users to patch the optimizer when needed. We can continue talking about other further improvements in #3124, but for the time being, I think that this is enough given the tradeoffs regarding increasing Vite's API surface. Thanks again for pushing for these changes. @qnp about #2991 (comment), I agree with you that this is a better API for Regarding #2991 (comment),
I see two options here. We could add a new vite/packages/vite/src/node/optimizer/scan.ts Lines 94 to 105 in 1e785d1
I am not sure at this point what is the best strategy. @nihalgonsalves @antfu could you help to review this?
At this point, Vite shouldn't tie itself too hard to the internal libraries it is using. For example, IMO it would have been better to name
I agree here about |
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.
@patak-js All done.
About the question about dep-scanning: this PR now also uses the same custom options for dep scanning. I think that if you're trying to patch something or change behaviour, you'd want your settings to apply to both the pre-scan and the bundling.
Some explanations of the choices I made below:
| 'bundle' | ||
| 'write' | ||
| 'watch' | ||
| 'outdir' | ||
| 'outfile' | ||
| 'outbase' | ||
| 'outExtension' | ||
| 'metafile' |
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.
Added this because I don't believe changing these would have a valid use case. Vite depends on bundling, the metafile, the output settings, and the build mode (i.e. watch = false).
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.
Should we add a comment within the code about why they are omitted?
Or maybe extract them into a well named type 🤔
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.
@nihalgonsalves I tested locally and found several spurious |
@patak-js Oops, forgot about those. They're due to the test for the keepNames deprecation handling. I silenced them now |
(API extractor warning)
Just a guess since I’m not developing on Windows, but perhaps it doesn’t match on the CI due to the back slash on Windows
in favour of setting exclude directly.
Co-authored-by: Shinigami <[email protected]>
Thanks for the work, LGTM |
Co-authored-by: Shinigami <[email protected]>
Description
This adds the ability to customise the esbuild options during the optimiser phase, including plugins.
There are some libraries that esbuild throws an error on, and I'd really like to have this functionality – we're stuck on a Vite conversion because of one or two packages – with plain esbuild, we're able to use plugins to work around small errors.
Additional context
See #3124
This is inspired by the conversation here: #2886 (comment)
The discussion is about where the build options should live. I feel like since
optimizeDeps
is an entirely different build phase than the esbuild transform options, the settings should go intoconfig.optimizeDeps
.Questions
define
andentryPoints
, should any other options be disallowed? For example, perhaps overridingbundle
,format
, oroutdir
shouldn't be allowed.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).Closes #2886