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

__esModule interop is applied to .cjs files #627

Open
5 of 6 tasks
nichtsam opened this issue Aug 7, 2024 · 1 comment
Open
5 of 6 tasks

__esModule interop is applied to .cjs files #627

nichtsam opened this issue Aug 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nichtsam
Copy link

nichtsam commented Aug 7, 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/nichtsam/tsx-import-differently

Problem & expected behavior (under 200 words)

Skip this section and let your reproduction do the talking...

But if you really need to explain, keep it under 200 words:

  • What happened
  • What I expected
  • Error stack trace
  • Documentation links
  • Screenshots

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
@nichtsam nichtsam added bug Something isn't working pending triage labels Aug 7, 2024
@privatenumber
Copy link
Owner

Oh good catch. The __esModule property should be ignored if the file is .cjs.

This will be pretty complex to handle since it should handle:

  • Relative path:import('./file.cjs')
  • Import subpath: import('#file') where #file maps to file.cjs
  • TS paths alias: import('file') where file maps to file.cjs

Feel free to open a PR with a test first, but I think this will be very challenging and may have to be resolved with #614

@privatenumber privatenumber changed the title Dynamic import behaves differently in tsx and node __esModule interop is applied to .cjs files Aug 9, 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
Projects
None yet
Development

No branches or pull requests

2 participants