Better ESM/CJS support #648
Labels
bug 🐛
Something doesn't work
core
Infrastructure work going on behind the scenes
status: waiting for maintainer
These issues haven't been looked at yet by a maintainer
Current issues
node
folder for CJS is misleading and not discoverableView source
action in VS Code goes to the (hard to read) CJS versionpackage.json
doesn’t specify the type fieldmoduleResolution: "Node" | "NodeNext"
Suggestions
My preferred implementation would be to do what we learned from doing the dual package in Radix Themes (see on unpkg):
type: "commonjs"
in the root package.jsontype: "module"
in the esm folder package.jsonexports
field withrequire
andimport
declarationscjs
andesm
folders in the built packagepublint can be a good way to check if all looks good:
https://publint.dev/@base_ui/[email protected]
https://publint.dev/@radix-ui/[email protected]
Some details on the possible implementations:
https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
The text was updated successfully, but these errors were encountered: