require-compiled
v1.5.0
Published
The easiest way to require babel-compiled modules.
Downloads
3
Readme
require-compiled
require-compiled
works just like regular require
, except it allows you to require code written in newer versions of JS.
Just add a .babelrc file to your project and you're good to go!
// Read babel options our of your .babelrc:
var requireCompiled = require('require-compiled');
var myModule = requireCompiled('./my-module');
var myModulePath = requireCompiled.resolve('./my-module');
// Instead of using a .babelrc, you can also pass in your babel options explicitly:
var requireCompiled = require('require-compiled').babelOptions({ ... });
Only the module directly required this way gets compiled.
To compile some of its dependencies as well, mark them with a compile!
flag:
var myChildModule = require('compile!./child')
Behind the scenes the the modules required this way are compiled into a cache directory.
Because of this, require-compiled
does not need to load require hooks into your node process.
require-compiled
does load node-source-map-support to give you nice stack traces in your errors.
Thanks
The code of the amazing ava testrunner was a great inspiration and guide for this module.