johvin / eslint-import-resolver-alias

a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
MIT License
180 stars 10 forks source link

Unexpected use of file extensions #22

Open aryzing opened 2 years ago

aryzing commented 2 years ago

I'm working with a project written entirely in TS. This project imports code from node_modules, which for the most part is in plain JS. Despite everything in node_modules being in JS, the plugin works as expected when defining the extensions array as [.ts, .tsx].

However -- There is one package I'm importing which contains another "sub-package": it has a folder with a package.json with a main field. To be clear, this "sub-package" is not in the package's node_modules, it is just in a regular directory in the package,

# contents of package inside root node_modules
node_modules/ # the package's own packages
package.json
index.js
some-folder/
  package.json # with "main": "lib"
  lib/
    index.js

Under these circumstances, if the extensions array does not contain .js, importing from package/some-folder with throw an error. Is this a bug? Was under the impression that the extensions array should not have an effect when the fully resolved path lives inside node_modules.