Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Treat sideEffects array as inclusion list (#227)
Browse files Browse the repository at this point in the history
* Treat sideEffects array as inclusion list
- Fixes #226

* Rename 'true-index' to 'array-index' for clarity

* Inline unnecessary local variable

* Rename test files from "-free" to "-effect"
  • Loading branch information
mikeharder authored and lukastaegert committed Jun 22, 2019
1 parent cdb7448 commit d49e257
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/index.js
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions test/node_modules/side-effects-array/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/node_modules/side-effects-array/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions test/test.js
Expand Up @@ -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;
}));
Expand Down

0 comments on commit d49e257

Please sign in to comment.