开发者社区> 镜像站> NPM> es6please
es6please
Quickly boot strap node's module system to automatically compile es6 to es5 source on require, based on file extension.
Last updated 6 years ago by bluejeansandrain .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install es6please 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 1.1.0                                ...           latest (6 years ago)

3 Versions

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