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

Commit 896c75e

Browse files
committed
allow scoped packages to be skipped – fixes #15
1 parent 6ddf8fc commit 896c75e

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

src/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ export default function npm ( options ) {
1616

1717
return {
1818
resolveId ( importee, importer ) {
19-
const parts = importee.split( /[\/\\]/ );
20-
const id = parts.shift();
19+
let parts = importee.split( /[\/\\]/ );
20+
let id = parts.shift();
21+
22+
// scoped packages
23+
if ( id[0] === '@' && parts.length ) {
24+
id += `/${parts.shift()}`;
25+
}
2126

2227
if ( ~skip.indexOf(id) ) return null;
2328

test/node_modules/@scoped/foo/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/samples/scoped/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import foo from '@scoped/foo';
2+
3+
foo();

test/test.js

+13
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,17 @@ describe( 'rollup-plugin-npm', function () {
197197
assert.equal( module.exports, path.sep );
198198
});
199199
});
200+
201+
it( 'allows scoped packages to be skipped', () => {
202+
return rollup.rollup({
203+
entry: 'samples/scoped/main.js',
204+
plugins: [
205+
npm({
206+
skip: [ '@scoped/foo' ]
207+
})
208+
]
209+
}).then( bundle => {
210+
assert.deepEqual( bundle.imports, [ '@scoped/foo' ]);
211+
});
212+
});
200213
});

0 commit comments

Comments
 (0)