Skip to content
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

TypeScript paths #10

Open
carlocorradini opened this issue Mar 27, 2023 · 8 comments
Open

TypeScript paths #10

carlocorradini opened this issue Mar 27, 2023 · 8 comments

Comments

@carlocorradini
Copy link

When using custom TypeScript paths the import is completely ignored (and therefore ESM invalid):

import { hello } from "@/world"; // IGNORED!
import { test } from "@/world/wow" // IGNORED!

Correct behaviour:

import { hello } from "@/world/index.js";
import { test } from "@/world/wow.js"

There is the need to understand if the import path points to a folder or a file and then apply the corresponding logic.

@carlocorradini carlocorradini changed the title TypesScript paths TypeScript paths May 20, 2023
@0x80
Copy link

0x80 commented Nov 13, 2023

I was so happy when I found this, for converting a large existing repo, but then I realized that most of my paths use aliases 😞

@jordaaash
Copy link
Collaborator

jordaaash commented Nov 13, 2023

Happy to accept a PR to fix this!

@0x80
Copy link

0x80 commented Nov 13, 2023

I don't think it's an easy fix. I tried hacking my way around it, but it didn't work, and I ran out of time. I'm going to park this for now.

@Val-istar-Guo
Copy link

same issue, hope someone have a good idea.

@mbonaci
Copy link

mbonaci commented May 7, 2024

@jordaaash Would you accept a PR which adds an ability to specify alias mapping for your two rules?
Similar to these two: eslint-import-resolver-custom-alias and eslint-import-resolver-alias.

Ideally, it would take the list of aliases from any of these:

  • package.json browser field
  • webpack conf resolve.alias field
  • tsconfig.json paths
    but that would be much more complicated to implement.

@mbonaci
Copy link

mbonaci commented May 9, 2024

FYI just to report that I managed to do a rewrite in which the existing import resolution aliases (webpack, jsconfig, tsconfig...) are taken into account.
I decided to publish a new package, given the unresponsiveness here, although I have to thank the original authors for the inspiration.

Introducing eslint-plugin-esm-import plugin: https://github.com/sematext/eslint-plugin-esm-import

@jordaaash
Copy link
Collaborator

@mbonaci Sorry about that! I had some of my Github emails going to an old work email address for quite a while, so I didn't see the notifications here until yours this week. I'd be happy to accept a PR to fix this behavior, and I'll check out your new package as well. If there's an opportunity for us to consolidate I'm very open to it, as we haven't been updating this in some time.

@mbonaci
Copy link

mbonaci commented May 10, 2024

@jordaaash No worries.

If there's an opportunity for us to consolidate...

I'd be open to that.
You can ping me here when you check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants