0.0.0 • Published 6 years ago

babel-plugin-transform-esm-to-cjs v0.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

JavaScript Style Guide code style: prettier Conventional Commits

babel-plugin-transform-esm-to-cjs

a babel plugin for lightweight conversion from esm to cjs without much ceremony

Purpose

transform basic import and export syntax of esm to cjs

import a from './a'

to

var a = require('./a')

export default a

to

module.exports = a

export { default as a } from './a'
export { default as b } from './b'

to

module.exports = {}
module.exports.a = require('./a')
module.exports.b = require('./b')

Usage

add as plugin to your babel configuration

{
  //...
  "plugins": [
    // ...
    "babel-plugin-transform-esm-to-cjs"
  ]
}

Use case

This plugin was made for developing library to be used with node.js or with bundler that can consume cjs