You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #7372 the plugin started marking the hoisted values as pure. However the way it does it has no effect if the original React tree is more than one level deep. Let me illustrate…
Hey @wereHamster! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
Bug Report
In #7372 the plugin started marking the hoisted values as pure. However the way it does it has no effect if the original React tree is more than one level deep. Let me illustrate…
Consider the following input:
Will get transformed to this (you can test it on the babel repl):
However such an annotation has no effect and the
_ref
is retained by all bundlers (rollup, webpack/terser). This is expected, that's how the/*#__PURE__*/
annotation works.Here is an example how rollup does (or rather does not) tree-shake such a module
One solution would be to wrap the value in an IIFE, as suggested by the above linked comment:
The text was updated successfully, but these errors were encountered: