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:
However, I believe this is backwards, and the correct code should be:
packageInfo.hasModuleSideEffects = id => filter(id);
The pull request which added this feature (https://github.com/rollup/rollup-plugin-node-resolve/pull/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:
Which should mean that dep1.js and *-free.jsdo have side effects, and all other files do not have side effects. However, the test asserts exactly the opposite:
How Do We Reproduce?
I believe the
sideEffects
array inpackage.json
is being treated as an exclusion list instead of an inclusion list. The current code setshasModuleSideEffects
totrue
if the id does not match the filter specified by the array:https://github.com/rollup/rollup-plugin-node-resolve/blob/fe7ea0ede81f5caf08db61c6e6b6356ea7ac3ac2/src/index.js#L149
However, I believe this is backwards, and the correct code should be:
The pull request which added this feature (https://github.com/rollup/rollup-plugin-node-resolve/pull/219) includes tests for the
sideEffects
array, but I believe the expected test results are backwards as well. The testpackage.json
specifies the following filter:https://github.com/rollup/rollup-plugin-node-resolve/blob/fe7ea0ede81f5caf08db61c6e6b6356ea7ac3ac2/test/node_modules/side-effects-array/package.json#L3-L6
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:https://github.com/rollup/rollup-plugin-node-resolve/blob/fe7ea0ede81f5caf08db61c6e6b6356ea7ac3ac2/test/test.js#L875-L876
Expected Behavior
Files matching the
sideEffects
array should havehasModuleSideEffects
set to a function which returnstrue
.Actual Behavior
Files matching the
sideEffects
array havehasModuleSideEffects
set to a function which returnsfalse
.