Skip to content

[FIX] #7 node_modules with .js in the name #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added dummy.js/index.js
Empty file.
5 changes: 5 additions & 0 deletions dummy.js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "dummy.js",
"version": "1.0.0",
"private": true
}
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ function resolveFile(source, file, config) {
}

// note that even if we match via tsconfig-paths, we still need to do a final resolve
const foundNodePath = resolve.sync(foundTsPath || source, {
extensions,
basedir: path.dirname(path.resolve(file)),
})
let foundNodePath;
try {
foundNodePath = resolve.sync(foundTsPath || source, {
extensions,
basedir: path.dirname(path.resolve(file)),
})
} catch (err) {
foundNodePath = null;
}

if (foundNodePath) {
log('matched node path:', foundNodePath)
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
],
rules: {
'import/no-unresolved': 'error',
'import/extensions': 'error',
},
settings: {
'import/resolver': {
Expand Down
1 change: 1 addition & 0 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ import 'folder/subfolder/tsxImportee'

// import from node_module
import 'typescript'
import 'dummy.js'