Categories
Build Tools JavaScript webpack

webpack 3: Scope Hoisting and the Bundle Size Wars

webpack 3 just shipped with a feature called "scope hoisting" that makes bundles smaller and faster. The technical improvement is modest—5-15% bundle size reduction in practice—but the symbolism is significant. webpack is acknowledging that bundle size matters, and the ecosystem is finally taking performance seriously.

What Is Scope Hoisting?

Scope hoisting (via the ModuleConcatenationPlugin) changes how webpack wraps modules. Previously, webpack wrapped each module in a function:

// webpack 2 output (simplified)
[
  function(module, exports) {
    // your module code
    var foo = require('./other');
  },
  function(module, exports) {
    // other module
    module.exports = 'bar';
  }
]

Each module gets its own scope. This is safe but bloated—lots of function wrappers and runtime overhead.

Categories
Build Tools JavaScript Web Development

webpack Won the Bundler Wars (Somehow)

A year ago, browserify was the dominant module bundler and webpack was the confusing alternative. Today, webpack is becoming the default choice. This shift happened quickly and reveals what developers actually value versus what they claim to value.

Why webpack Won (Despite Itself)

Categories
Build Tools JavaScript Web Development

webpack: The Module Bundler That’s Different (and Confusing)

webpack has been around for two years, but it's starting to get attention as an alternative to browserify and RequireJS. After spending time configuring it, my reaction is: this is simultaneously brilliant and needlessly complex. The concepts are right, but the API fights you.

Everything Is A Module

Categories
Automation Build Tools JavaScript

Automating Front-End Tasks with Grunt

Introduction

Modern front-end development involves numerous repetitive tasks: minifying JavaScript, compiling CoffeeScript or LESS, running JSHint to catch errors, concatenating files, running tests, and more. Performing these tasks manually is tedious and error-prone. Forget to minify before deployment? Your users download bloated files. Skip linting? Bugs slip through that could have been caught automatically.

Build automation has long been standard practice in back-end development, with tools like Make, Rake, and Ant handling compilation and deployment tasks. But front-end development has lacked a cohesive, JavaScript-native solution—until now.