esbuild-plugins icon indicating copy to clipboard operation
esbuild-plugins copied to clipboard

does not support ESM packages

Open revelt opened this issue 3 years ago • 1 comments

The node-resolve is dependent on resolve which in turn, does not support native ESM packages (type=module in package.json) see https://github.com/browserify/resolve/issues/222

As a result, a well-known consumer of node-resolve, the Mr. Dodds' mdx-bundler doesn't properly compile ESM packages. For example, it would compile matcher which is ESM only because it has minimalistic "exports": "./index.js", https://github.com/sindresorhus/matcher/blob/main/package.json#L14 — any other value, including differently-named JS file, will fail in MDX bundler.

If you want to recreate the issue, just tweak the unit test to resolve package.json key exports pointing to anything else than index.js, and of course, make it type: module and without main.

revelt avatar Apr 06 '22 19:04 revelt

I would prefer waiting for resolve to add esm support

That library is downloaded 58 million times every month, sooner or later they will need to add esm support

remorses avatar Apr 06 '22 19:04 remorses