5 ms·
Bun put a lot of work into making both “import” and “require” always work regardless of whether it’s given a commonjs or an ESM target. I’d say that’s half of t
by fwlr 2y ago
Bun put a lot of work into making both “import” and “require” always work regardless of whether it’s given a commonjs or an ESM target. I’d say that’s half of the right idea: make only import work with anything.
Another angle that might be effective: take the most popular aspect of commonjs - `require(‘extensionless-string’)` - and tie it to the least popular aspect, .cjs extensions.
- postepowanieadm 2y agoBut why do you want to break half of a working solution?
- tracker1 2y agoIt's closer to how Babel worked out of the box for half a decade before Node added their implementation. It's Node that broke a half-working solution.
- fwlr 2y agoIn fairness - given a choice and some time to think, I would probably not choose to actively break commonjs. However, if I was tasked with increasing ESM adoption, I would go about it like this.