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

Import discrepancy in Node's ESM/CJS interop #657

Open
6 tasks done
steelbrain opened this issue Sep 26, 2024 · 2 comments
Open
6 tasks done

Import discrepancy in Node's ESM/CJS interop #657

steelbrain opened this issue Sep 26, 2024 · 2 comments
Labels
bug Something isn't working pending triage

Comments

@steelbrain
Copy link

steelbrain commented Sep 26, 2024

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://github.com/steelbrain/2024-09-tsx-bug-repro

Problem & expected behavior (under 200 words)

Hey Team! Really confused by the output of tsx changing based on package.json#type instead of tsconfig.json. Please have a look at the repro repository. It's possible that this isn't a bug in tsx and is a behavior coming in from esbuild.

Either way, would love to hear based on your experience why this is happening and any pointers on how we could mitigate the impact. I burned through some solid time trying to isolate the bug that led me here. Happy to do a PR (if someone can walk me through it) or financially sponsor a fix here.

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support
@steelbrain steelbrain added bug Something isn't working pending triage labels Sep 26, 2024
@privatenumber
Copy link
Owner

This is unexpected behavior but unrelated to tsx. You can run it in Node and get the same behavior.
I hope to fix it via tsx in the future though.

Modules can parse named exports from CommonJS via cjs-module-lexer, but that's unable to parse UMD format.

@steelbrain
Copy link
Author

Thank you for the pointers @privatenumber. Much appreciated!

I hope to fix it via tsx in the future though.

That would be really helpful. I ran into this while trying to run some code that worked fine in Next.js but broke in tsx. Handling it here would make it easier for people to run tsx on existing codebases.

@privatenumber privatenumber changed the title Trying to understand why import value is changing Import discrepancy in Node's ESM/CJS interop Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

2 participants