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

ESM entrypoint isn't functional #260

Closed
acidoxee opened this issue Oct 6, 2023 · 3 comments · Fixed by #263
Closed

ESM entrypoint isn't functional #260

acidoxee opened this issue Oct 6, 2023 · 3 comments · Fixed by #263

Comments

@acidoxee
Copy link

acidoxee commented Oct 6, 2023

The files in dist/esm are not valid ESM because:

  • The folder is missing a package.json with { "type": "module" } in it, OR files use a .js extension instead of .mjs (since the closest package.json states the package is using CJS)
  • Relative imports in those files don't have an extension

This causes esbuild (for my case) and maybe other bundlers to discard this entrypoint and fallback to the CJS one instead (TypeScript resolution also points towards the CJS entrypoint, even when consumed from ESM code).

Do you think you might be able to fix the entrypoint to make ESM code able to consume ESM from your package as well? 🙏

@Skn0tt
Copy link
Collaborator

Skn0tt commented Oct 6, 2023

Thanks for reporting this! This sounds like a regression to me. I’m not in office until beginning of next week, but will take a look then.

@Skn0tt
Copy link
Collaborator

Skn0tt commented Oct 11, 2023

Released a pure ESM version in https://github.com/blitz-js/superjson/releases/tag/v2.0.0, let me know if that works for you!

@acidoxee
Copy link
Author

acidoxee commented Oct 11, 2023

I'm currently assessing whether this breaks something or not in my app, but what's sure is that esbuild now properly leverages ESM for superjson and its dependencies 🥳

image
image
image

I believe going ESM-only is the right move for most libs, otherwise people would rarely have any real incentive to move away from CJS. Anyway, thanks a lot for your quick reaction and fix! I'll open another issue if I stumble upon other problems.

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 a pull request may close this issue.

2 participants