generator-es-cross

Yeoman generator to create a nodejs library to support both esm and commonjs

Usage no npm install needed!

<script type="module">
  import generatorEsCross from 'https://cdn.skypack.dev/generator-es-cross';
</script>

README

Build Status

generator-es-cross

Yeoman generator to create a nodejs library to support both esm and commonjs by using package.main and package.module

Install

$ npm i -g generator-es-cross

Usage

# 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 git@github.com: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 directory lib will be included in NPM tarball.

License

MIT