flux icon indicating copy to clipboard operation
flux copied to clipboard

"npm start" watchify command continuously writing to js/bundle.js on both examples.

Open laurencefass opened this issue 11 years ago • 6 comments

hi im trying to run the flux examples and im not updating any files but it looks like watchify is constantly adding to bundle.js. is this correct or is there something wrong with this installation? im a bit of a newbie so maybe its meant to work this way by the bundle.js files looks pretty MASSIVE.

/var/www/flux/examples/flux-chat$ npm start

[email protected] start /var/www/flux/examples/flux-chat watchify -o js/bundle.js -v -d . 1615032 bytes written to js/bundle.js (3.82 seconds) 1615032 bytes written to js/bundle.js (0.53 seconds) 1615032 bytes written to js/bundle.js (0.44 seconds) 1615032 bytes written to js/bundle.js (0.62 seconds) 1615032 bytes written to js/bundle.js (0.51 seconds) 1615032 bytes written to js/bundle.js (0.50 seconds) 1615032 bytes written to js/bundle.js (0.44 seconds) 1615032 bytes written to js/bundle.js (0.47 seconds) 1615032 bytes written to js/bundle.js (0.39 seconds) 1615032 bytes written to js/bundle.js (0.47 seconds) 1615032 bytes written to js/bundle.js (0.48 seconds) 1615032 bytes written to js/bundle.js (0.47 seconds) 1615032 bytes written to js/bundle.js (0.45 seconds) 1615032 bytes written to js/bundle.js (0.52 seconds) 1615032 bytes written to js/bundle.js (0.43 seconds) 1615032 bytes written to js/bundle.js (0.49 seconds) 1615032 bytes written to js/bundle.js (0.42 seconds) 1615032 bytes written to js/bundle.js (0.53 seconds) 1615032 bytes written to js/bundle.js (0.40 seconds) (and so on ad infinitum)

laurencefass avatar Mar 24 '15 15:03 laurencefass

Watchify writes to bundle.js whenever any part of the code changes. This is the transpiling process, allowing JSX and ECMAScript6 and all that good stuff to work.

As far as the build size goes, you're seeing the development build. This is unminified.

The production build seems to be buggy at the moment (not sure if the API for browserify/envify has changed since I first wrote this), but I was able to get it to work after globally installing envify and uglify, and then running the following:

$ browserify . -t [envify --NODE_ENV production] | uglifyjs -cm > js/bundle.min.js

This produced the following:

189793 Mar 24 20:07 bundle.min.js

To find out how much of that is React, I built my own copy of React, and that produced this:

121391 Mar 24 20:36 react.min.js

fisherwebdev avatar Mar 25 '15 03:03 fisherwebdev

React gzipped is compressed uncompressed ratio uncompressed_name 36347 121391 70.0% react.min.js

and flux-chat gzipped is compressed uncompressed ratio uncompressed_name 51823 189793 72.6% bundle.min.js

fisherwebdev avatar Mar 25 '15 06:03 fisherwebdev

watchify is constantly updating the console even though i am not making any changes to code. is that normal/expected operation?

laurencefass avatar Mar 25 '15 10:03 laurencefass

You have be explicit about the entry file(s). This works without the constant rebuilding: watchify -o js/bundle.js -v -d js/app.js

zertosh avatar Mar 25 '15 12:03 zertosh

Fixed. Thanks @zertosh for the solution!

zpao avatar Mar 25 '15 18:03 zpao

Thanks @zertosh! I had copied a bit of boilerplate code for my project from the flux tutorial and encountered this problem only when I switched a new HD and re-downloaded all my NPM packages.

mikemorton avatar May 17 '15 18:05 mikemorton