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

Fix missing paths when using typescript's module nodenext feature #216

Merged
merged 3 commits into from
Jun 2, 2023
Merged

Conversation

IgnusG
Copy link
Contributor

@IgnusG IgnusG commented Jul 20, 2022

This resolution requires relative/mapped import paths to end with .js
This PR detects if a path ends with .js and if so adds more extension type paths to try, that omit this extension when attaching additional extensions to match the actual existing files.

Reference https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#esm-nodejs

Should resolve #213 (edit 1: wrong issue sorry, edit 2: actually I believe this might resolve that issue as well) & aleclarson/vite-tsconfig-paths#59

@WoodyWoodsta
Copy link

Is this going anywhere?

@aleclarson
Copy link
Contributor

Can you copy over the test from #213 ?

@WoodyWoodsta
Copy link

I would also like to know if this handles .mjs files, which is what is emitted by the TS compiler when files are .mts files.

@aleclarson
Copy link
Contributor

I would also like to know if this handles .mjs files, which is what is emitted by the TS compiler when files are .mts files.

Good catch. There should definitely be a test for that.

@IgnusG
Copy link
Contributor Author

IgnusG commented Oct 11, 2022

I'll add both tests and check the mjs support 👍

@IgnusG
Copy link
Contributor Author

IgnusG commented Oct 11, 2022

I would also like to know if this handles .mjs files, which is what is emitted by the TS compiler when files are .mts files.

@WoodyWoodsta can you please check if 39354fb works for you? I barely remember this PR so I just quickly wrote down a test for it

Copy link

@WoodyWoodsta WoodyWoodsta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm coming here from aleclarson/vite-tsconfig-paths#54, so I would need to fiddle around to test it - but will do if I manage to find a gap.

src/__tests__/try-path.test.ts Outdated Show resolved Hide resolved
@IgnusG
Copy link
Contributor Author

IgnusG commented Nov 18, 2022

@jonaskello could you please take a look through this when you have the time?

@IgnusG
Copy link
Contributor Author

IgnusG commented Nov 19, 2022

For anyone wanting to use this in the meantime with yarn add this resolution to your package.json

{
  "resolutions": {
    "tsconfig-paths": "github:ignusg/tsconfig-paths@dev"
  }
}

@datner
Copy link

datner commented Jun 1, 2023

Hey, this pr was thoroughly tests, reviewed, and even approved!
This is great work and an important step in moving to full esm.

Is there a reason why this isn't merged?

@jonaskello
Copy link
Member

Yes, seems like this change has enough tests so let's merge it.

@jonaskello jonaskello merged commit b4eb77b into dividab:master Jun 2, 2023
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

Successfully merging this pull request may close these issues.

None yet

5 participants