cjs2es6import
convert CommonJS require expressions to ES6 module import statements
Last updated 5 years ago by deathcap .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cjs2es6import 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.2.1                                ...           latest (5 years ago)

3 Versions

  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 2
Dependencies (3)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |