Skip to content

Commit

Permalink
consider modules from bower_components' and 'jspm_modules as extern…
Browse files Browse the repository at this point in the history
…al modules
  • Loading branch information
zloirock committed Jul 20, 2016
1 parent 7990596 commit 74e1ee2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/importType.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ export function isBuiltIn(name, settings) {
return builtinModules.indexOf(name) !== -1 || extras.indexOf(name) > -1
}

const folders = ['node_modules', 'bower_components', 'jspm_modules']
function isExternalPath(path, name) {
return !path || folders.some(folder => -1 < path.indexOf(join(folder, name)))
}

const externalModuleRegExp = /^\w/
function isExternalModule(name, settings, path) {
if (!externalModuleRegExp.test(name)) return false
return (!path || -1 < path.indexOf(join('node_modules', name)))
return externalModuleRegExp.test(name) && isExternalPath(path, name)
}

const scopedRegExp = /^@\w+\/\w+/
Expand All @@ -25,8 +29,7 @@ function isScoped(name) {
}

function isInternalModule(name, settings, path) {
if (!externalModuleRegExp.test(name)) return false
return (path && -1 === path.indexOf(join('node_modules', name)))
return externalModuleRegExp.test(name) && !isExternalPath(path, name)
}

function isRelativeToParent(name) {
Expand Down

0 comments on commit 74e1ee2

Please sign in to comment.