justmoon / node-extend

Simple function to extend objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide esm version

tobiasdiez opened this issue · comments

With more and more build tools (vite, nuxt, etc) going towards an esm-first build, it would be nice if a proper esm interface could be provided, i.e. transpile and distribute esm version, including correct export declaration in package.json.

Why? CJS packages can be imported by ESM, and an "exports" field, while a good idea, should never be necessary to bundle a package.

If you're using a bundler that can't handle decade-old time-tested bundling patterns, then I'd suggest finding a better bundler.

Bundlers like vite/esbuild/rollup understand commonjs and transpile it to esm. By distributing an esm version, you remove the need for such tools to transpile it. I don't want to start an argument about commonjs vs esm, but let's face it: esm is more and more used, and it doesn't hurt to properly support it.

It does hurt, actually, because it's unnecessary complexity for node users, it creates potential "dual package hazard" issues (around duplicated object identities), and it's more package weight.

Transpilation is never going away and is not a bad thing to be avoided.