1.1.0 • Published 9 years ago

es6please v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

es6please

Quickly bootstrap Node's module system to automatically compile es6 to es5 source on require, based on file extensions.

Usage

// Require this module
var es6 = require('es6please');

// Setup which files will be compiled to ES5 JavaScript
es6.ext('.js');
es6.excludeExt('.txt');
es6.pattern(/\.es6(\.js)?$/);
es6.excludePattern(/\/node_modules\//);
es6.include('/foo/bar.js');
es6.exclude('./baz.js');
es6.filter(function(filename, source)
{
	if (/^\s*"use es6";/.test(source)) {
		return true;
	} else {
		return false;
	}
});

// Require some modules
var some_module = require('./some/module.es6');

API

All functions accept one or more arguments. More than one argument is equivalent to calling the method once for each argument.

  • .ext(...string)
    • include files with a specific extension. Leading dot (.) is optional and will be added automatically if missing.
  • .excludeExt(...string)
    • exclude files with a specific extension. Leading dot(.) is optional.
  • .pattern(...RegExp)
    • include files with filenames that match the regular expression.
  • .excludePattern(...RegExp)
    • exclude files with filenames that match the regular expression.
  • .include(...string)
    • include a specific file.
  • .exclude(...string)
    • exclude a specific file.
  • .filter(...function(string filename, string source))
    • include if the function returns true, exclude if it returns false. If the function returns null or undefined, then the file is not excluded, but is only included if there is another rule that includes it.

Dependencies

ES6 support is provided by the Google's Traceur Compiler, and Error stack trace offsets are corrected by the source-map-support module.