The default file pattern includes all JavaScript files, but you may override it in order to only transform files coming
from a certain directory, with a specific file name and/or extension, etc.
By configuring the regex to exclude ES5 files, you can optimize the performance of the transform. However transforming
ES5 JavaScript will work since it is a subset of ES6.
browserify({ debug: true }) .add(require('es6ify').runtime) // compile all .js files except the ones coming from node_modules .transform(require('es6ify').configure(/^(?!.*node_modules)+.+\.js$/)) .require(require.resolve('./src/main.js'), { entry: true }) .bundle() .pipe(fs.createWriteStream(bundlePath));
es6ify.traceurOverrides
Some features supported by traceur are still experimental: either nonstandard, proposed but not yet standardized, or
just too slow to use for most code. Therefore Traceur disables them by default. They can be enabled by overriding these
options.
For instance to support the async functions (async/await) feature you'd do the following.
When es6ify is run on a development server to help generate the browserify bundle on the fly, it makes sense to only
recompile ES6 files that changed. Therefore es6ify caches previously compiled files and just pulls them from there if no
changes were made to the file.
Source Maps
es6ify instructs the traceur transpiler to generate source maps. It then inlines all original sources and adds the
resulting source map base64 encoded to the bottom of the transformed content. This allows debugging the original ES6
source when using the debug flag with browserify.
If the debug flag is not set, these source maps will be removed by browserify and thus will not be contained inside
your production bundle.
var object = { prop: 42, // No need for function method() { return this.prop; }};
propertyNameShorthand
var foo = 'foo';var bar = 'bar';var obj = { foo, bar };
templateLiterals
var x = 5, y = 10;console.log(`${x} + ${y} = ${ x + y}`)// 5 + 10 = 15
restParameters
function printList(listname, ...items) { console.log('list %s has the following items', listname); items.forEach(function (item) { console.log(item); });};