cjs2es6import

0.2.1 • Public • Published

cjs2es6import

Convert a subset of CommonJS/NodeJS module require() expressions to ECMAScript 6 module import statements.

Usage:

var cjs2es6import = require('cjs2es6import');

var src = "var foo = require('bar');";
var newSrc = cjs2es6import(src); // "import foo from 'bar';"

More examples in demo/demo.js (run npm start)

The require() calls are statically analyzed, similar to node-browserify (in node-detective), in order to translate to import statements. ES6 imports are designed to enforce a static module structure so not all requires are translated.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i cjs2es6import

Weekly Downloads

2

Version

0.2.1

License

MIT

Last publish

Collaborators

  • deathcap