-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
#__PURE__
on member expressions should be handled
#4893
Comments
Reread the terser thread, seems like the only objection is maintenance cost. |
Honestly, I think the problem is that you have
I'm fine with the maintenance cost, but not sure about adding it to |
|
I think access to global |
I think we can add the pure comment support for member expressions, and I think we should. Currently, this can be done via export const MyExport = /*#__PURE__*/ (function () { return window.MyExport; })() but this does not look like a good idea. |
#__PURE__
on member expressions should be handled
I didn't know about |
For what I'm doing (Deno bundling), the comment here doesn't seem to have any effect: export const MyExport = /*#__PURE__*/ (function () { return window.MyExport; })() I was grepping the SWC code for |
Yeah, it's only handled by the minifier |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the feature
If I have an export like
export const foo = ...
, this export will only be removed if the RHS can be determined to be side-effect-free, understandably. Member accesses in general are considered to potentially have side effects (with the exception of Math.PI; see implementation ofis_pure_callee
), which is very conservative. I have exports likeexport const HTMLElement = window.HTMLElement
in a module, and it's inconvenient that SWC is worried about the side effects of an expression likewindow.HTMLElement
.There is a quite ugly workaround, involving temporarily reassigning the global
Math
. It would be great if there were some other way to mark an expression (or export) as side-effect-free, such as with a comment, a wrapper function with a magic name, or even some identifier besides Math that you can access properties on and have it considered to be pure, like if you name your local variable__pure
you are ok.Babel plugin or link to the feature description
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: