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

package.json import maps not resolved correctly when it points to a directory under outDir #329

Closed
2 tasks
SuperchupuDev opened this issue Sep 30, 2023 · 5 comments
Labels
enhancement New feature or request resolver

Comments

@SuperchupuDev
Copy link
Contributor

SuperchupuDev commented Sep 30, 2023

Problem

When resolvePackageJsonImports is enabled in tsconfig.json, and they point to somewhere inside the outDir directory, TypeScript will resolve the package import as the same file but inside the rootDir directory.

However tsx does not, it resolves to the original package import directory, making this behavior inconsistent with typescript

This makes something like "imports": { "#*": "./dist/*" } work as expected under TypeScript (point to ./src/*), but makes tsx point to ./dist/*

Expected behavior

tsx having behavior consistent with TypeScript and resolving to the corresponding file inside rootDir

Minimal reproduction URL

https://stackblitz.com/edit/node-9muqn2?file=REPRO-INSTRUCTIONS.md&view=editor

Version

v3.13.0

Node.js version

v20.7.0

Package manager

pnpm

Operating system

Windows

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@SuperchupuDev SuperchupuDev added bug Something isn't working pending triage labels Sep 30, 2023
@SuperchupuDev SuperchupuDev changed the title package.json import maps not resolved correctly when it points to the same directory as outDir package.json import maps not resolved correctly when it points to a directory under outDir Sep 30, 2023
@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Sep 30, 2023

looks like this is a duplicate of #296, however it got closed without resolving

@privatenumber
Copy link
Owner

privatenumber commented Oct 1, 2023

This would be a feature request since TS released this after tsx, and this was simply not implemented.

As it says in the closing comment, #296 was closed as a duplicate, not because it's resolved; the referenced issue is still open.

I think this is a separate issue though. This ticket is about TypeScript customizing Node's import/export map logic to consider tsconfig, whereas #296 is about simply implementing Node's import/export map logic.

@privatenumber privatenumber added enhancement New feature or request resolver and removed bug Something isn't working pending triage labels Oct 1, 2023
@privatenumber
Copy link
Owner

I looked into this and the expected behavior doesn't seem to be correct: TypeScript is not mapping imports to a missing outDir directory back to the source:
Screenshot 2024-06-12 at 6 41 14 AM

It just so happens to work post compilation because it creates the files, but TypeScript is not intentionally doing that.

Closing as expected behavior.

@privatenumber privatenumber closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
@gaastonsr

This comment was marked as spam.

@privatenumber
Copy link
Owner

Please don't comment on closed issues. Especially if you're going to reference one that's open.

And also, if you're going to make a claim, please back it. There's an explanation with a screenshot above demonstrating why this particular issue is expected.

Repository owner locked and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request resolver
Projects
None yet
Development

No branches or pull requests

3 participants