cjyes
🔍 see jay, yes! 🎉 / 👨🏻💻 see, JS! 👾 / ⚓️ sea JS ⛴
If you're publishing ES Modules, you need to also publish CommonJS versions of those modules.
This isn't to support old browsers or Node versions: even in Node 14, using require()
to load a module won't work if it's only available as ESM.
cjyes
is the bare minimum fix for this problem. You write ES Modules and fill out a valid package.json
, and it'll generate the corresponding CommonJS files pretty much instantly. cjyes
takes up 500kb of disk space including its two dependencies.
Usage
The easiest way to use cjyes
is to define package exports the way Node 13+ requires:
cjyes
will create CommonJS versions of all modules listed in the "exports"
field and place them at the specified locations.
You can also use
.js
file extensions and the{"type":"module"}
field - cjyes will detect this and generate the required.cjs
output files.
Multiple Entries
Multiple entry points are supported automatically. Simply define them in your export map:
Custom Files
It is also possible to pass a list of input modules to cjyes
directly:
cjyes src/index.js src/other.mjs# generates the following: # dist/ # index.cjs # other.cjs