Skip to content

Commit f82c1ff

Browse files
vkrolbradzacher
authored andcommitted
[FIX] import-js#7 node_modules with .js in the name (import-js#5)
Fixes import-js#7
1 parent 5e52af3 commit f82c1ff

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

dummy.js/index.js

Whitespace-only changes.

dummy.js/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "dummy.js",
3+
"version": "1.0.0",
4+
"private": true
5+
}

index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ function resolveFile(source, file, config) {
4949
}
5050

5151
// note that even if we match via tsconfig-paths, we still need to do a final resolve
52-
const foundNodePath = resolve.sync(foundTsPath || source, {
53-
extensions,
54-
basedir: path.dirname(path.resolve(file)),
55-
})
52+
let foundNodePath;
53+
try {
54+
foundNodePath = resolve.sync(foundTsPath || source, {
55+
extensions,
56+
basedir: path.dirname(path.resolve(file)),
57+
})
58+
} catch (err) {
59+
foundNodePath = null;
60+
}
5661

5762
if (foundNodePath) {
5863
log('matched node path:', foundNodePath)

package-lock.json

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

tests/.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
],
1414
rules: {
1515
'import/no-unresolved': 'error',
16+
'import/extensions': 'error',
1617
},
1718
settings: {
1819
'import/resolver': {

tests/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ import 'folder/subfolder/tsxImportee'
1212

1313
// import from node_module
1414
import 'typescript'
15+
import 'dummy.js'

0 commit comments

Comments
 (0)