compile-esx

1.0.22 • Public • Published

What

compile-esx can compile es6(es7 .etc) code in src folder/file to es5 code in target folder/file.

How

/*
 *  @param {string} srcFileOrFolderPath - src file or folder path; relative or absolute
 *  @param {string} targetFileOrFolderPath - target file or folder path; relative or absolute
 *  @param {Object} config - config, including: watch/include/exclude
 *  @param {boolean} config.watch - false by default; watch file changes: add/change/unlink/unlinkDir
 *  @param {RegExp} config.include - /\.js/ by default; will only compile files whose path matched this
 *  @param {RegExp} config.exclude - null by default; will not compile files whose path matched this
 *  @param {Array} config.presets - ['es2015'] by default; for babel config
 *  @param {Function} doneCallback - callback when compilation is done
 */
compileEsx(srcFileOrFolderPath, targetFileOrFolderPath[, config][, doneCallback]);

Example

const compileEsx = require('compile-esx');

compileEsx('./src', './target', {
    watch: true,
    include: /\.js/,
    exclude: /node\_modules/
}, function(err) {
    if (err) {
        throw err;
    }
    
    console.log('compilation is done.');
});

When

When you don't want to write webpack.config.js when coding node modules, but the same time also want to write es6/7..., you can use compile-esx and open the watch config to compile es6/7... code to es5.

var compile = require('compile-esx');

compile('./src', './dist', {
    watch: true
}, function () {
    console.log('done');
});

Readme

Keywords

Package Sidebar

Install

npm i compile-esx

Weekly Downloads

2

Version

1.0.22

License

ISC

Last publish

Collaborators

  • antfoot