configure = function (opts) { opts = assign({}, opts); var extensions = opts.extensions ? babel.util.arrayify(opts.extensions) : null; var sourceMapsAbsolute = opts.sourceMapsAbsolute; if (opts.sourceMaps !== false) opts.sourceMaps = "inline"; // babelify specific options delete opts.sourceMapsAbsolute; delete opts.extensions; delete opts.filename; // babelify backwards-compat delete opts.sourceMapRelative; // browserify specific options delete opts._flags; delete opts.basedir; delete opts.global; // browserify cli options delete opts._; // "--opt [ a b ]" and "--opt a --opt b" are allowed: if (opts.ignore && opts.ignore._) opts.ignore = opts.ignore._; if (opts.only && opts.only._) opts.only = opts.only._; if (opts.plugins && opts.plugins._) opts.plugins = opts.plugins._; if (opts.presets && opts.presets._) opts.presets = opts.presets._; return function (filename) { if (!babel.util.canCompile(filename, extensions)) { return stream.PassThrough(); } var _opts = sourceMapsAbsolute ? assign({sourceFileName: filename}, opts) : opts; return new Babelify(filename, _opts); }; }
...
var babelify = require("babelify");
browserify().transform(babelify, {presets: ["es2015", "react"]});
```
Or, with the `configure` method:
```js
browserify().transform(babelify.configure({
presets: ["es2015", "react"]
}));
```
#### Customizing extensions
By default, all files with the extensions `.js`, `.es`, `.es6` and `.jsx` are compiled. You can change this by passing an array
of extensions.
...
function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); Duplex.call(this, options); this._transformState = new TransformState(this); var stream = this; // start out asking for a readable event once data is transformed. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things // that Readable wants before the first _read call, so unset the // sync guard flag. this._readableState.sync = false; if (options) { if (typeof options.transform === 'function') this._transform = options.transform; if (typeof options.flush === 'function') this._flush = options.flush; } // When the writable side finishes, then flush out anything remaining. this.once('prefinish', function() { if (typeof this._flush === 'function') this._flush(function(er) { done(stream, er); }); else done(stream); }); }
n/a