diff --git a/src/index.js b/src/index.js index d2f75b5..dca731c 100644 --- a/src/index.js +++ b/src/index.js @@ -145,8 +145,7 @@ export default function nodeResolve ( options = {} ) { if (typeof packageSideEffects === 'boolean') { packageInfo.hasModuleSideEffects = () => packageSideEffects; } else if (Array.isArray(packageSideEffects)) { - const filter = createFilter(packageSideEffects, null, {resolve: pkgRoot}); - packageInfo.hasModuleSideEffects = id => !filter(id); + packageInfo.hasModuleSideEffects = createFilter(packageSideEffects, null, {resolve: pkgRoot}); } packageInfoCache.set(pkgPath, packageInfo); diff --git a/test/node_modules/side-effects-array/dep3-free.js b/test/node_modules/side-effects-array/dep3-effect.js similarity index 100% rename from test/node_modules/side-effects-array/dep3-free.js rename to test/node_modules/side-effects-array/dep3-effect.js diff --git a/test/node_modules/side-effects-array/index.js b/test/node_modules/side-effects-array/index.js index bd33706..0e04e8f 100644 --- a/test/node_modules/side-effects-array/index.js +++ b/test/node_modules/side-effects-array/index.js @@ -1,8 +1,8 @@ global.sideEffects = global.sideEffects || []; -global.sideEffects.push('true-index'); +global.sideEffects.push('array-index'); export {value as value1} from './dep1.js'; export {value as value2} from './dep2.js'; -export {value as value3} from './dep3-free.js'; +export {value as value3} from './dep3-effect.js'; export {value as value4} from './nested/dep4'; -export {value as value5} from './nested/dep5-free'; +export {value as value5} from './nested/dep5-effect'; diff --git a/test/node_modules/side-effects-array/nested/dep5-free.js b/test/node_modules/side-effects-array/nested/dep5-effect.js similarity index 100% rename from test/node_modules/side-effects-array/nested/dep5-free.js rename to test/node_modules/side-effects-array/nested/dep5-effect.js diff --git a/test/node_modules/side-effects-array/package.json b/test/node_modules/side-effects-array/package.json index 5afd642..2a39b98 100644 --- a/test/node_modules/side-effects-array/package.json +++ b/test/node_modules/side-effects-array/package.json @@ -1,7 +1,8 @@ { "main": "./index.js", "sideEffects": [ + "./index.js", "./dep1.js", - "**/*-free.js" + "**/*-effect.js" ] } diff --git a/test/test.js b/test/test.js index d0b52f6..c7b1b7b 100644 --- a/test/test.js +++ b/test/test.js @@ -890,9 +890,10 @@ describe( 'rollup-plugin-node-resolve', function () { 'true-dep1', 'true-dep2', 'true-index', - 'array-dep2', - 'array-dep4', - 'true-index' + 'array-dep1', + 'array-dep3', + 'array-dep5', + 'array-index' ]); delete global.sideEffects; }));