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
If rollup incorrectly removes a chunk of code, the ability to force an expression to not be tree-shaken.
Provides a workaround for:
users of rollup in non-standard environment, where rollup assumes a method is pure.
uncommon scenarios, where rollup assumes no side-effects.
bug in rollup, pending a fix
Admittedly, this is not for the main-stream user of rollup, but would be valuable for users who run into an issue.
Feature Proposal
/* @rollup-keep */
if (1 > 2) {
doSomething();
}
In the specific case I am working with, the embedded js engine, in rare occasions, breaks the behaviour of >.
To work around this, we have to add the above if (1 > 2) check, which of course, is tree-shaken.
To work around rollup, we must add
if (Math.random()*99.99 > 2) {
doSomething();
}
Then, on the rollup/minified bundle, replace the conditional back to (1 > 2).
Admittedly, seeing doSomething() report metrics once every few weeks is baffling.
This would also be valuable for my use-case. I am bundling Typescript to an ES5 environment (the CouchDB Spidermonkey engine), where a script is evaluated to define a map or reduce function.
So for example the following script evaluates to the value of myMap and defines a map function...
functionmyMap(doc){emit(doc.id)}myMap;
Since myMap is never actually referenced, when this runs with treeshake: true all code is removed as it is not exported. It would be valuable to be able to explicitly flag a symbol as being in use. Currently I simply have to disable treeshaking and have every imported function in its own file to prevent unused items making it into the bundle.
Feature Use Case
If
rollup
incorrectly removes a chunk of code, the ability to force an expression to not be tree-shaken.Provides a workaround for:
Admittedly, this is not for the main-stream user of rollup, but would be valuable for users who run into an issue.
Feature Proposal
In the specific case I am working with, the embedded js engine, in rare occasions, breaks the behaviour of
>
.To work around this, we have to add the above
if (1 > 2)
check, which of course, is tree-shaken.To work around rollup, we must add
Then, on the rollup/minified bundle, replace the conditional back to
(1 > 2)
.Admittedly, seeing
doSomething()
report metrics once every few weeks is baffling.Re: #2963
Re: #1771
The text was updated successfully, but these errors were encountered: