Skip to content

multiple resolvers don't always work #1350

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

Closed
benmosher opened this issue May 1, 2019 · 4 comments
Closed

multiple resolvers don't always work #1350

benmosher opened this issue May 1, 2019 · 4 comments

Comments

@benmosher
Copy link
Member

benmosher commented May 1, 2019

Need to isolate a repro but in my day job codebase the following works:

settings:
  import/resolver:
    webpack: {}
    typescript: {}

and this doesn't (always), but should (always):

settings:
  import/resolver: ['webpack', 'typescript']

technically blocked by import-js/eslint-import-resolver-typescript#18 for typescript resolver specifically but there is something else going on that makes

settings:
  import/resolver: webpack

work, but

settings:
  import/resolver: ['webpack', { 'typescript': {} }]

doesn't always. not sure what the difference is but in some files I get "Resolver error" with the above.

@teoxoy
Copy link

teoxoy commented Aug 3, 2019

I don't think those 2 resolvers are compatible with each other.
You don't need the typescript resolver if you already use the webpack one.
If you want aliases, set them up in the webpack config (alias option) instead of declaring them via compilerOptions.paths in your tsconfig

@smtchahal
Copy link

I realize this is an old thread, but I came across a similar issue where I would ideally want both of these resolvers.

I need the webpack resolver so that it can resolve the resolve.aliases from webpack.config.js properly, but I need the typescript resolver because I want to be able to import App from 'App' from a file named App.tsx.

There currently seems to be no way to have both of these functionalities using just one of these resolvers.

@ljharb
Copy link
Member

ljharb commented Apr 6, 2022

@smtchahal my personal opinion is that the proper way to solve this is to use babel for all transpiling (it does a much better job than tsc), and to handle aliases using a babel transform.

Short of that, I think you'd need a webpack config that did nothing but resolve the aliases, and then fell back to the TS resolver - or, you'd need to also define the aliases in tsconfig.

@JounQin
Copy link
Collaborator

JounQin commented Jul 19, 2022

I believe this can be closed for a long time because import-js/eslint-import-resolver-typescript#18 has already been merged.

@JounQin JounQin closed this as completed Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants