Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
String(Symbol()) is removed upon treeshaking #2790
not to my knowledge in an environment which is compliant with the current ES2018 spec. Which is not to dismiss this issue but to put it into perspective. Rollup currently assumes that all builtins behave according to the latest spec.
And this is usually what the user wants EXCEPT inside polyfills. If every invocation of Symbol would be considered a side-effect, this would make Symbol something that people should definitely avoid ever using unless forced to.
So this is more about the issue of providing a useful fallback behaviour for polyfills (BTW all of these issues stem from IE11...). I have several ideas but nothing has been investigated further yet.
Wow, thank you for sharing the context of the issue!
This specific incompatibility between Rollup and core-js will be fixed upon the next core-js release.
Looking for a workaround myself (without patching core-js or Rollup) I was expecting a blacklist option for the tree-shaking algorithm, where I can flag functions (names) with known side-effects (in this case Symbol()). I know this wouldn't be an optimal solution either, but maybe it even helps with propertyReadSideEffects (which could default to false).
To resolve my issue I didn't bundle core-js, but added it separately to the HTML. It's a separate vendor package with separate release cycle, already bundled and it's huge alone (30+kB).