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

Support customConditions in tsconfig.json #574

Open
4 of 6 tasks
colinhacks opened this issue Jun 6, 2024 · 2 comments
Open
4 of 6 tasks

Support customConditions in tsconfig.json #574

colinhacks opened this issue Jun 6, 2024 · 2 comments
Labels
enhancement New feature or request resolver

Comments

@colinhacks
Copy link

colinhacks commented Jun 6, 2024

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I am reporting a confirmed bug (not seek debugging help)
  • I understand this is a collaborative project and relies on my contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

This is actually a feature request sorry :(

It would be cool if tsx automatically read customConditions from tsconfig.json and passed it to node using --conditions.

Problem & expected behavior (under 200 words)

"Repro" is https://github.com/colinhacks/live-typescript-monorepo

gh repo clone https://github.com/colinhacks/live-typescript-monorepo
cd live-typescript-monorepo/custom-conditions
pnpm i
cd packages/pkg-b
tsx index.ts # module resolution error
tsx --conditions source index.ts # works!

I'm using custom export conditions in my TypeScript monorepo (described in more detail here). Since tsconfig.json already supports the customConditions compiler option for specifying custom export conditions, it would be cool if tsx could read that and incorporate it into module resolution automatically.

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work financially will speed up resolution

  • I'm willing to offer financial support
@colinhacks colinhacks added bug Something isn't working pending triage labels Jun 6, 2024
@privatenumber
Copy link
Owner

Feature requests are reserved for sponsors, but I'll accept this for you @colinhacks!

This should be trivial to support for ESM, but it may be challenging with the CJS resolver as it doesn't seem to offer a way to accept conditions:
https://github.com/nodejs/node/blob/main/lib/internal/modules/cjs/loader.js#L1126

@privatenumber privatenumber added enhancement New feature or request resolver and removed bug Something isn't working pending triage labels Jun 9, 2024
@DASPRiD

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resolver
Projects
None yet
Development

No branches or pull requests

3 participants