From 3300ab14c6be758043fd07fb625955b15a7727ce Mon Sep 17 00:00:00 2001 From: Veniamin Krol Date: Wed, 17 Oct 2018 17:21:57 +0300 Subject: [PATCH 1/2] Fix modules resolving with .js in the name --- index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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) From 7c6c4843ff4bf15d57f8fcfa62bd39e9314ae2ff Mon Sep 17 00:00:00 2001 From: Veniamin Krol Date: Thu, 25 Oct 2018 18:28:00 +0300 Subject: [PATCH 2/2] Introduce dummy.js package for the testing purposes --- dummy.js/index.js | 0 dummy.js/package.json | 5 +++++ package-lock.json | 4 ++++ tests/.eslintrc.js | 1 + tests/index.ts | 1 + 5 files changed, 11 insertions(+) create mode 100644 dummy.js/index.js create mode 100644 dummy.js/package.json 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/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'