Skip to content

Commit d05255a

Browse files
committed
fix #2258 fix isExternalModule calculation
1 parent ccb69d9 commit d05255a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/core/importType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function isExternalModule(name, settings, path, context) {
2929
if (arguments.length < 4) {
3030
throw new TypeError('isExternalModule: name, settings, path, and context are all required');
3131
}
32-
return isModule(name) && isExternalPath(name, settings, path, getContextPackagePath(context));
32+
return (isModule(name) || isScopedModule(name)) && isExternalPath(name, settings, path, getContextPackagePath(context));
3333
}
3434

3535
export function isExternalModuleMain(name, settings, path, context) {

tests/src/core/importType.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,21 @@ describe('importType(name)', function () {
234234
it('`isExternalModule` works with windows directory separator', function () {
235235
const context = testContext();
236236
expect(isExternalModule('foo', {}, 'E:\\path\\to\\node_modules\\foo', context)).to.equal(true);
237+
expect(isExternalModule('@foo/bar', {}, 'E:\\path\\to\\node_modules\\@foo\\bar', context)).to.equal(true);
237238
expect(isExternalModule('foo', {
238239
'import/external-module-folders': ['E:\\path\\to\\node_modules'],
239240
}, 'E:\\path\\to\\node_modules\\foo', context)).to.equal(true);
240241
});
241242

243+
it('`isExternalModule` works with unix directory separator', function () {
244+
const context = testContext();
245+
expect(isExternalModule('foo', {}, '/path/to/node_modules/foo', context)).to.equal(true);
246+
expect(isExternalModule('@foo/bar', {}, '/path/to/node_modules/@foo/bar', context)).to.equal(true);
247+
expect(isExternalModule('foo', {
248+
'import/external-module-folders': ['/path/to/node_modules'],
249+
}, '/path/to/node_modules/foo', context)).to.equal(true);
250+
});
251+
242252
it('correctly identifies scoped modules with `isScopedModule`', () => {
243253
expect(isScopedModule('@/abc')).to.equal(false);
244254
expect(isScopedModule('@/abc/def')).to.equal(false);

0 commit comments

Comments
 (0)