-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
property access inside /* @__PURE__ */
makes an object not removed when minifying
#2279
Comments
Yes, AFAIK property accessing is always treated as having side effects in esbuild since there might defined a custom getter. Tracking the pureness of an object prop is not in esbuild's goal. There's still some way to hack around this, for example: // as pure as "var a = 1"
var pure_value = /* @__PURE__ */ (() => obj.prop)() |
I found a weird behavior.
Is there any difference between these? |
There's a weird case to use In: /* @__PURE__ */ (() => a.b)();
var c = /* @__PURE__ */ (() => d.e)(); Out: a.b; // won't be here if removed --minify-syntax So this might be a hidden bug in esbuild. |
The first 2 cases should be tree-shaked. This is because var a = /* @__PURE__ */ foo(whatever) The annotation does nothing about the things in braces. So if they have side effects, they are kept. |
That makes sense. So here it should be |
Thanks for the report. This is just an oversight. Looks like I missed a I'll fix this in the next release. If you want to work around this in the meantime, you can use |
Thank you! |
For example,
BaseTransitionImpl
is not removed from the output.esbuild repl
terser
outputs the following code.Is this is not supported because it is difficult to support this without performance degration?
refs: https://github.com/vuejs/core/blob/dddbd96dfe69292cee401f72d2703e8fb3708a14/packages/runtime-dom/src/components/Transition.ts#L72-L77
The text was updated successfully, but these errors were encountered: