I've ran into a strange issue and need your help to figure what's going on.
I've configured gulp to build my a test up written in React.js in ES6. I've used browserify
to setup the CommonJS env and babelify
for bigger ES6 support. And everything works, it just takes too long (in my opinion) to build if React is required as CommonJS module. Meaning this
import React from 'react';
line will raise the bundle/compile time from 1.2secs
to around 4secs
on the initial build, then when any changes are detected it takes around 2.5secs
to rebuild the js files. And this time rapidly goes up when more modules are included. My work around was to configure bower
to expose any external libraries as globals in the browser, don't like this solution as much.
Here is my main browserify
setup:
function buildApp () {
return browserify({
entries: config.paths.jsx,
extensions: ['.jsx'],
debug: true
})
.bundle()
.on('error', onError)
.pipe(source('app.js'))
.pipe(gulp.dest(config.paths.dest));
}
and the transform is added via packages.json
"browserify": {
"transform": [
"babelify"
]
}
I did try the ignore
option in my buildApp function
as follows:
transform(babelify.configure({
ignore: /node_modules/
})
but that did not help.
I'm using the latest packages, as far as I know, meaning:
"babelify": "^6.3.0",
"browserify": "^11.2.0",
"react": "^0.14.0"
on Node v4.1.0. Anyone has any ideas? By all means, please share.
P.S. Here is the link to the repo if someone has the time and wants to take a closer look. Or, maybe, test the build time.