-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Rollup Version
v4.6.1
Operating System (or Browser)
Ubuntu
Node Version (if applicable)
No response
Link To Reproduction
Expected Behaviour
When using treeshaking, the dead branches of OR logical expressions are totally absent from the bundle, and the source map.
Actual Behaviour
When using treeshaking, the dead branches of OR logical expressions are generated as an empty space that the source map maps back to them.
The fact that an empty space is generated in the bundle is not a big thing. But the fact that rollup declares this space as generated by the removed operands render impossible to detect treeshaked operands when parsing the source file. Typically, a code coverage tool would be incapable of knowing that the branches || 5 || 10 || 20 of the provided sample are uncovered because querying the source map about them would lead to a valid generated position.
Additionaly, this behavior is inconsistent with how rollup behaves with functions, that are not present neither in the bundle nor in the source map.
For covenience, a link to the source map visualization of the provided sample: