diff --git a/dummy.js/index.js b/dummy.js/index.js new file mode 100644 index 00000000..e69de29b diff --git a/dummy.js/package.json b/dummy.js/package.json new file mode 100644 index 00000000..2baf0fcc --- /dev/null +++ b/dummy.js/package.json @@ -0,0 +1,5 @@ +{ + "name": "dummy.js", + "version": "1.0.0", + "private": true +} diff --git a/index.js b/index.js index 92e412a1..9ce16245 100644 --- a/index.js +++ b/index.js @@ -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) diff --git a/package-lock.json b/package-lock.json index 3cda1c99..51a935f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -271,6 +271,10 @@ "esutils": "^2.0.2" } }, + "dummy.js": { + "version": "file:dummy.js", + "dev": true + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js index c8b722c4..e393da70 100644 --- a/tests/.eslintrc.js +++ b/tests/.eslintrc.js @@ -13,6 +13,7 @@ module.exports = { ], rules: { 'import/no-unresolved': 'error', + 'import/extensions': 'error', }, settings: { 'import/resolver': { diff --git a/tests/index.ts b/tests/index.ts index b7ae0801..8d011e92 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -12,3 +12,4 @@ import 'folder/subfolder/tsxImportee' // import from node_module import 'typescript' +import 'dummy.js'