rollup/rollup-plugin-node-resolve

sideEffects array is treated as exclusion list

mikeharder opened this issue · 0 comments

  • Node-Resolve Plugin Version: 5.0.3
  • Rollup Version: 1.15.6
  • Operating System (or Browser): Windows 10
  • Node Version: 10.16.0

How Do We Reproduce?

I believe the sideEffects array in package.json is being treated as an exclusion list instead of an inclusion list. The current code sets hasModuleSideEffects to true if the id does not match the filter specified by the array:

packageInfo.hasModuleSideEffects = id => !filter(id);

However, I believe this is backwards, and the correct code should be:

packageInfo.hasModuleSideEffects = id => filter(id);

The pull request which added this feature (#219) includes tests for the sideEffects array, but I believe the expected test results are backwards as well. The test package.json specifies the following filter:

"sideEffects": [
"./dep1.js",
"**/*-free.js"
]

Which should mean that dep1.js and *-free.js do have side effects, and all other files do not have side effects. However, the test asserts exactly the opposite:

'array-dep2',
'array-dep4',

Expected Behavior

Files matching the sideEffects array should have hasModuleSideEffects set to a function which returns true.

Actual Behavior

Files matching the sideEffects array have hasModuleSideEffects set to a function which returns false.