Migration to Webpack@2

I spent the past few days upgrading our app to the latest RC of Webpack ver. 2. Here’s the official migration guide, that covers most of the common cases, but there were still a number of “gotchas” that I wish I had been aware of before I started this PR.

#1 thing that kills your productivity

It's not a routine, not meetings. Not even social networks or messengers.

#1 thing that kills your productivity is permanent long-term focus on one single project.

Imagine what's going to happen if you'll be eating same food every day during a year? Or to put a song on repeat and listening it for a few months? I bet you won't want to have those things around for a very long time. Same thing happens when you are focused exclusively on single project—your mind's just getting tired. This is human nature.

To keep yourself up—periodically switch. Find some new stuff to keep your mind busy with and start doing this. Few hours a day, on the weekends or 1 week in the month—adjust intervals and do yourself a favour—switch.

Code diet

For the past 3 (+/–) years my relationships with the code can be described as relationships of fatty with the fridge, at 3 AM, after alcohol. Development was a funky magic runaway train I was late for and I had to push hard to catch up. But now, when I can state that I jumped in, I must get on the diet to keep going.

No, it's still same (and even bigger) fun playing with all these shiny new tech toys and do the stuff that I'm doing, but what actually bothers me:

  • Amount of time spent on solving / debating on issues, that has nothing to do with the real world problems: terrifying.
  • Number of books (not focused on specific tech) I read in the past 3 years: 0 (zero).
  • Text notes made outside git repos: close to zero.

Code is extremely powerful matter, but code for code is road to nowhere (of course there are exceptions, but I'm not one of them for sure).

npm pitfalls

Lately we've been facing a number of issues with our npm workflow. I made a few notes how to prevent them in the future.

First, we use npm shrinkwrap to lock down production dependencies. And sometimes we find it broken for some reason. How it's happening.

Mocha + Webpack

There is one annoying issue with Webpack: if you use Webpack-specific code in your JS modules, it's impossible to use it outside of Webpack environment (or it takes time to made up a number of workarounds). A few days ago I was playing around with one awesome loader (sass-variable-loader) and it struck me again: I can share style variables with JSX views, but it makes them intestable, b/c mocha can't handle imports with Webpack loaders. So long story short: now I officially can state, that everything in my stack — production & development client builds, production & development builds for Node server and, finally, test builds — all compiled with Webpack.