flightcontrolhq / superjson

Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.
https://www.flightcontrol.dev?ref=superjson
MIT License
4.17k stars 90 forks source link

ESM entrypoint isn't functional #260

Closed acidoxee closed 1 year ago

acidoxee commented 1 year ago

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

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.