It's in the name
Last updated 3 years ago by hollowdoor .
MIT · Original npm · Tarball · package.json
$ cnpm install compile-es-for-node 
SYNC missed versions from official npm registry.



npm install --save compile-es-for-node


"use strict";
const compile = require('../');
const vm = require('vm');

//script.js is some script in the current working directory.
compile('script.js', {
    //Set should this create an iife to pass globals into?
    //(default false)
    //These are iife parameters.
    wrap: ['exports', 'require', 'module', '__filename', '__dirname'] /*This is the same as wrap:true*/,
    //Show rollup warnings? (default false)
    showWarning: false,
    //Should the compiler seek deep into modules?
    //If set true then any modules that can be will be compiled.
    //(default false)
    deepRequire: false
    result = {code, map} = sourceMaps
    vm.runInNewContext(result.code, {
        console: console
    })(exports, require, module, __filename, __dirname);


results have a code property, and a map property.

code is the compiled code.

The map property contains the source maps.

Like rollup use like so:

 map.toString() // – shorthand for JSON.stringify( map )
 map.toUrl() // – generates a data URI, suitable for appending to a file


This module supports the common usage of the rollup module.

Any es2015 modules are compiled, and es2015 syntax (and into the future) is as compiled using babel.

See the babel-preset-env to see what what babel is doing to your code.

Source maps don't do anything yet, but they are there for the future.

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (0)
Dependents (1)

Copyright 2014 - 2016 © |