node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

runtime-transpiler

Runtime Transpiler

Runtime ES6 and JSX transpiler for Node. Load into your app when it starts, and it will transpile the file extensions specified in the config from ES6 to ES5.1 and from JSX to vanilla JS.

Installation

npm i runtime-transpiler --save-dev

Usage

If no config is specified, the ES6 transpiler will run on all .js files:

require('runtime-transpiler').start();
 
// is equivalent to 
 
require('runtime-transpiler').start({
    js: {
        es6: true
    }
});

Specifying config allows you to control which transpilers are run on which file extensions:

require('runtime-transpiler').start({
    js: {
        es6: true
    },
    jsx: {
        es6: true,
        jsx: true
    }
});
 
...

Files

Specifying a files item in the options argument restricts the transpiler to running on a set of files. The file paths are calculated using the node glob module. Not specifying this will cause the transpiler to run on all modules.

require('runtime-transpiler').start({
    jsx: {
        jsx: true
    },
    files: [
        'src/**/**.js',
        'tests/**/*.js'
    ]
});
 
...

This will run the jsx transpiler on all .js files under the src and tests directories recursively.