babel-middleware
Express/Connect middleware to pre-process requested JS files through Babel
Last updated 4 years ago by mralex .
Apache 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-middleware 
SYNC missed versions from official npm registry.

babel-middleware

Simple Express/Connect middleware to automatically transpile JavaScript files from ES2015+ to ES5 via Babel, and cache the results to memory or the file-system as desired.

Usage

var express = require('express');
var babel = require('babel-middleware');
var app = express();

app.use('/js/', babel({
    srcPath: 'app/js',
    cachePath: __dirname + '/_cache'
    babelOptions: {
        presets: ['es2015']
    }
}));

app.listen(3001);

Options

srcPath: '/path/to/js/'

An absolute or relative path to the input source. This option is required.

cachePath: '/path/to/cache/'|'memory'

Use either memory for an in-memory cache; or a path to the desired cache directory (it does not need to exist when the app starts).

Default: memory

exclude: ['production/example/*.js']

An array of path globs to exclude from transpiling and caching. Returns the originally requested file. See Micromatch documentation for globbing examples. Exclusions do not match against srcPath.

Default: []

babelOptions: {}

An options object passed into babel.transformFile. See Babel documentation for usage.

debug: true|false

Print debug output.

Default: false

LICENSE

Apache 2.0.

Current Tags

  • 0.3.4                                ...           latest (4 years ago)

9 Versions

  • 0.3.4                                ...           4 years ago
  • 0.3.3                                ...           4 years ago
  • 0.3.2                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (6)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |