Tools like browserify and webpack popularized the idea of bundling. The idea is to transform your web application into a format that can be distributed to browsers. Bundlers operate on module level and can combine the assets in various ways.
Fastpack by Oleksiy Golovko is a new bundler that emphasizes performance. Read on to learn how it achieves this goal.
I am a freelance Software Developer living in Prague, Czech Republic. I have been working with various web technologies as of 2004 (PHP at that time!). I love solving challenging problems and working on the development tools.
When not programming I read, play tennis/squash/badminton and spend time with my three kids and the beautiful wife. Also, I am passionate about tasting good beers – you cannot resist it here in the Czech Republic!
Fastpack is a Javascript bundler. It can bundle other assets as well using webpack's loaders.
Fastpack is written in OCaml and compiled into a binary executable. To start using it, you need to install it from npm: npm install fpack
. If everything went fine, you should be able to run node_modules/.bin/fpack --help
.
We are trying to maintain the minimum set of required configuration parameters. The only way to pass those is to submit them as command line arguments: entry points, output configuration, resolver settings and preprocessors.
Under the hood it works just like most bundlers do:
Fastpack uses the Flow parser for JavaScript, so JSX and flow typings supported out if the box.
Consider the examples below to see how Fastpack can be used:
$ fpack --dev -o dist ./lib/index.js
lib/
#$ fpack --preprocess='^lib/.+js$' --dev -o dist ./lib/index.js
babel-loader
for transformations#$ fpack ./lib/index.js \
--dev \
-o dist \
--preprocess='^lib/.+js$:babel-loader?filename=.babelrc'
You can find more examples and the documentation on the fastpack.io site.
Well, it is faster :) Speaking seriously, we are aiming for three primary goals:
Naturally, we keep in mind other success parameters, like bundle size, which is very important too. But that's the second tier goal for now.
There were several reasons: First, I wanted to understand OCaml & ReasonML better. What do people do with it? What is the workflow? What are the hiccups? TodoMVC or even "Real World Example" didn't seem to be exciting use cases, so I decided to try something out of the compiler's side of things.
The second reason was the amount of the JavaScript code we had in my company. Our bundles are quite big and took a lot of time to rebuild. Of course, I could have configured webpack better, but I was never too successful in it.
Fastpack is young, and there is a long road behind us until it matures enough. Right now, we are considering several directions, which are:
Overall, I am passionate about the development tools and would be happy to contribute to other related projects as well.
As far as I can say, we would still need bundler in short/medium term. Hence, Fastpack may have its niche and its users. On the other hand, the HTTP/2 and supporting ECMAScript modules in browsers will likely eliminate a lot of bundler use cases in a long run.
The other (unrelated to Fastpack, or partially related because of the language) trend going on right now is the ReasonML. I think this is the future of the web development alongside the Elm and PureScript.
Of course, I am biased, so take it critically, but writing, debugging & maintaining the OCaml/ReasonML code is so much more comfortable, safer & more pleasant than any other dynamically-typed language I have experienced before.
I am not feeling in a position to be giving advice, but I think something trivial like "learn, practice and communicate" should always work. And yes, learn OCaml/ReasonML :)
I would love to see an interview with Andrey Popp (@andreypopp), Patrick Stapfer (@ryyppy), Nik Graf (@nikgraf) and Vladimir Kurchatkin (@vkurchatkin) - really loved his talk on ReasonConf.
Thank you for the interview!
Thanks for the interview Oleksiy! Fastpack looks promising. I like the approach and now I'm tempted to try out the tool in a few projects of mine.
Learn more at Fastpack documentation or Fastpack GitHub.