modulestrap

A basic JS module bootstrap

Usage no npm install needed!

<script type="module">
  import modulestrap from 'https://cdn.skypack.dev/modulestrap';
</script>

README

modulestrap

Social Media Photo by Danielle MacInnes on Unsplash

A basic JS module bootstrap: npx modulestrap project-name


The goal of this binary module is to bootstrap any JS module that would like to land on browsers, as well as NodeJS.

modulestrap project-name
  --babel      # to transpile for older browsers
  --cover      # to include coverage tools
  --node       # to create a NodeJS only module
  --ungap      # to include polyfills
  --force      # to overwrite existent projects
  --ucjs       # use ucjs instead of ascjs
  --no-default # to avoid exporting module.default
  --no-interop # alias for --no-default

Accordingly with the passed flags, the binary will create project-name and initialize it with most common tools to create dual modules.

Example / How to

npx modulestrap my-project --babel
cd my-project
code .
# write your module in ./esm/ folder
# the `index.js` is already there
# once you've done
npm run build

Above procedure will create all files for both CommonJS and ESM module + it will transpile to index.js and minify to min.js for browsers.

It is suggested to write a test too, either via --cover flag, or manually.

At that point, you can publish to npm your module.