Annotate with /*#__PURE__*/ magic comment
adi518 opened this issue · comments
This is a cool plugin that can potentially solve a big problem. How can we annotate the IIFE with /*#__PURE__*/
?
I don't know what does magic comment do but I guess you have to use the banner option.
It marks a piece of code as pure, making it tree-shakable.
This plugin wraps output bundle to iife. Why do you want to tree-shake the output?
It doesn't do it per export? I imagined it takes every export and wraps it into an IIFE, which I can then mark as pure, that's because without it, some parts of the module aren't detected as pure, such as styleInject
calls, which appear in the global scope of the module, thus breaking the tree-shake.
It doesn't do it per export?
No. This plugin modifies output result. Here is an example taken from the test file:
rollup-plugin-iife/test/test.js
Lines 49 to 67 in 9296d9e
Also take a look at es-iife.
it takes every export and wraps it into an IIFE, which I can then mark as pure,
I think the best solution is to use rollup-plugin-shim. There is an example in README that shim debug
module with an empty function so all debug
function calls will be tree-shaken.
Whoa, I'll go check that out ASAP. Thanks. :)