feat(optimizer): replace user defines#9548
Conversation
I think the situations are same, both would break esbuild's prebundle when dynamic importing optional dependencies.The difference is i use a defined global as condition, when the others use |
|
@bluwy #8606 fixed a real issue by removing the user defines, see #8606 (comment). Maybe what we could do is only eagerly define when pre-bundling the user defines that are not objects. The bug only appeared for an object value, and for the use cases like @Chen-jj ones it would be quite rare if it isn't a string or simple value. |
|
I forgot about prebundling in build aspect 🤦 I wonder if it's also worth trying the second commit of #8606. It should be better for perf too, the cons are negligible i think. |
|
I'll close this at the meantime. I think either ways #9321 should fix this implicitly, and we can look into the perf optimizations at a later time. |
Description
Fix #9527
Ref #8606 (comment)
Additional context
@Chen-jj I wonder if your issue is somewhat similar to #6007 too, which I have a fix for it, but nonetheless I think this change is good too so we can leverage lesser filesystem traversing (and other optimizations)
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).