Book Image

Learning Underscore.js

By : Alexandru Vasile Pop
Book Image

Learning Underscore.js

By: Alexandru Vasile Pop

Overview of this book

Table of Contents (14 chapters)
Learning Underscore.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding ECMAScript 2015 (ES6) support to Browserify


When we explored Babel's capabilities, we looked at a key feature where by default Babel will transpile ES6 modules as CommonJS modules that can be loaded natively by Node.js. Because Browserify also supports CommonJS files, we could write code using the ES6 module syntax, transpile it via Babel into CommonJS modules, and then use Browserify to create a bundle that can run in the browser.

Browserify has extensive supports for plugins and transformations that add extra functionality that is not provided by default. Browserify can apply a transformation to its source files before they are processed for bundling. One such transformer called babelify can convert ES6 modules to CommonJS modules via the Babel API.

Before we modify our Gulp tasks to use this new transformer, we will follow a similar workflow to the previous subsection. Before we build the browser bundles, we will create an ES6 baseline codebase that can be exercised and tested via...