README
esm2umd
Transforms ESM to UMD, i.e. to use ESM by default with UMD as a legacy fallback.
Usage
npx esm2umd ModuleName esmFile.js > umdFile.js
ModuleName
is used as the name of the vanilla JS global. If the module has a default
export, it becomes the value obtained when require
d.
API
Installation as a dependency is optional (pulls in megabytes of babel), but if so desired exposes the CLI as an API:
import esm2umd from 'esm2umd'
const esmCode = '...'
const umdCode = esm2umd('ModuleName', esmCode)