Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

ESM packages that don't specify "module" #9

Open
web-padawan opened this issue Dec 13, 2019 · 1 comment
Open

ESM packages that don't specify "module" #9

web-padawan opened this issue Dec 13, 2019 · 1 comment

Comments

@web-padawan
Copy link

web-padawan commented Dec 13, 2019

Now when Node has support for modules, some packages started to care about ESM version.

It turns out the "module" field isn't always the best solution, because of webpack.
See for example this PR where it was decided to remove it: markedjs/marked#1571 (comment)

Also I found this article relevant: https://2ality.com/2019/10/hybrid-npm-packages.html

@FredKSchott would you consider adding more ways to discover ESM packages?

This is important for me as a library maintainer: I was hoping to get @pika/web and CDN support when upgrading to ESM version of dependency, but so far I'm out of luck.

@Andarist
Copy link

Module field is OK - the only thing you have to do to make it work is to expose the same shape from each format. If that requires a major bump on your side because of CJS consumers then just do it. Yes - it will be a little bit worse for CJS consumers because they will have to either use .default or destructure named export which is less than ideal bit its really not that bad in the end. The difference is just visual so it’s better to get over it and start shipping stuff instead of hanging to a possibility to export a single thing from CJS in a flat~ manner (whereas in ESM you always export a bag of things).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants