From 0ad9659e611d18c48f732bc5f29eb2003eed3975 Mon Sep 17 00:00:00 2001 From: Ross Warren Date: Mon, 13 Feb 2017 11:00:41 +0000 Subject: [PATCH] support scoped modules containing hyphens --- CHANGELOG.md | 1 + src/core/importType.js | 2 +- tests/src/core/importType.js | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fcb4faa3..4c9a54888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Yanked due to critical issue in eslint-module-utils with cache key resulting fro ### Fixed - attempt to fix crash in [`no-mutable-exports`]. ([#660]) - "default is a reserved keyword" in no-maned-default tests by locking down babylon to 6.15.0 (#756, thanks @gmathieu) +- support scoped modules containing non word characters ## [2.2.0] - 2016-11-07 diff --git a/src/core/importType.js b/src/core/importType.js index 869ca7496..79b8870b1 100644 --- a/src/core/importType.js +++ b/src/core/importType.js @@ -27,7 +27,7 @@ function isExternalModule(name, settings, path) { return externalModuleRegExp.test(name) && isExternalPath(path, name, settings) } -const scopedRegExp = /^@\w+\/\w+/ +const scopedRegExp = /^@[^\/]+\/[^\/]+/ function isScoped(name) { return scopedRegExp.test(name) } diff --git a/tests/src/core/importType.js b/tests/src/core/importType.js index 5b63910af..dedf43d0d 100644 --- a/tests/src/core/importType.js +++ b/tests/src/core/importType.js @@ -31,6 +31,9 @@ describe('importType(name)', function () { it("should return 'external' for scopes packages", function() { expect(importType('@cycle/core', context)).to.equal('external') expect(importType('@cycle/dom', context)).to.equal('external') + expect(importType('@some-thing/something', context)).to.equal('external') + expect(importType('@some-thing/something/some-module', context)).to.equal('external') + expect(importType('@some-thing/something/some-directory/someModule.js', context)).to.equal('external') }) it("should return 'internal' for non-builtins resolved outside of node_modules", function () {