Thought I'd share something with those interested in Blue Ocean wrt how we're building things there and some of the challenges we're trying to deal with.
The Blue Ocean (BO) UI is a single page app (SPA), with lots of client-side JavaScript, using new frameworks/tools/libs such as React, Redux and more. So there's lots of "new" stuff in there when compared with how Jenkins UI's have been built in the past ... a big learning process for everyone involved.
All of this client-side code is not in a single .js file, but instead split across multiple self-contained javascript "bundles", and using some
js-builder and
js-modules magic to "link" things together at runtime.
The main/startup "bundle" is currently defined in the "blueocean-web" and it is responsible for loading some/all of the "core" modules used by BO, including react, react-dom and some others. This means that these modules are all inside the blueocean-web "bundle" (it has to be this way because of how react works).
One of the ongoing challenges we are looking at is - how do we make sure these bundles don't get too bloated and cause suckie UX because the user is kept waiting on JS to load. This is always going to be a challenge and something we need to monitor, just like personal fitness and weight is a constant challenge for people.
Anyway ... what I wanted to share here was a simple tool we found for analysing browserify generated bundles (we're currently using Browserify to generate the actual .js bundles). It tells you the composition of the bundle and which npm packages and CommonJS modules are contributing most to the bundle size. It's called
discify and after installing and running it, you can get some interesting info from it in the form of an interactive (hover the different slices to get details) chart that highlights the packages/modules going into the bundle, and the percentage of the bundle size each is contributing.

Yeah ... the above is just giving a flavour ... you really need to run it and interact with it to see. I'd encourage people to do that, especially if they are contributing to BO and adding dependencies ... we need to be very careful that the weight added by a new dependency is really justified in terms of the benefits that dependency brings. Adding every new "shinny" lib we see is just going to result in problems down the road !!
Installing
discify is dead easy ...
npm install -g disc
Then in one of the BO plugins (e.g. blueocean-web), just run gulp build as normal, but adding the --full-paths switch ...
gulp --full-paths
As this runs, the build will output the locations to where the bundles are being generated. You can use this to work out the path that needs to be supplied to the
discify command (or you can just look in the gulpfile.js). e.g. for the blueocean.js bundle generated by the blueocean-web build ....
discify /Users/tfennelly/projects/blueocean/blueocean-web/target/classes/io/jenkins/blueocean/blueocean.js -O
Of course, we can use minification and gzipping to reduce the full size, but we need to keep a close track on this and be careful when adding dependencies.