Yeoman generator to create a nodejs library to support both esm and commonjs by using package.main
and package.module
$ npm i -g generator-es-cross
# It is recommanded to clone the empty repo first,
# because `generator-es-cross` reads the git remote url
# and set default prompts values.
git clone [email protected]:my-name/my-empty-repo.git
cd my-empty-repo
yo es-cross
After that
- ES module files will be located at
./src
- ES modules will be transformed into commonjs to directory
./lib
which is ignored by git. package.main
->./lib
package.module
->./src
- both directory
src
and directorylib
will be included in NPM tarball.