0.1.2 • Published 5 years ago

modconv v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

modconv

Module conversion tool for node.

GitHub license Build Status npm Project Status

Usage

modconv -d dist src

modconv does one thing, convert from one js module syntax to another. It uses Babel behind the scenes and has a very small set of flags you can use.

Why use this?

The main thing this tool does that many other module conversion tools do not is handle default exports from ECMAScript 6 module (esm) format when producing CommonJS (cjs) output. Normally you end up doing something like this from your converted modules:

const myModule = require('my-module').default;

This still works, but leaving off the .default part also works. That means you can simply require converted modules like this, and they will work as expected:

const myModule = require('my-module');

It's very useful for published modules that are written in esm, since using the cjs version in node feels very natural. (Note that other target module formats do not work this way, only cjs).

This is all thanks to babel-plugin-add-module-exports.

Options

FlagDescription
--helpShow help information
-f, --formatDesired output format, see --help for available formats
-d, --out-dirTarget directory for all converted code to be written
-o, --out-fileTarget file for all converted code to be written
--silentPrevent status output, converted module will still be sent to stdout if -d or -o are not used

License

MIT © w33ble