Browserify vs. Webpack
mattdesl.svbtle.com
mattdesl.svbtle.com
The given scenario of loading a regular ".js" looks like it is in favour of Browserify, but that advantage quickly goes to Webpack as soon you change the extension to be jsx/sass/yml/myown. How those files will be loaded and processed is not up to the bundling tool - that should be delegated to single-purpose loader that convert whatever the content is into an app-compatible format. This is exactly what Webpack does by keeping the core minimal and outsourcing all content loading to mini-loader, including the loading of simple JS files. The Webpack approach is much closer to the linux goal of do-one-thing-really-well-and-play-well-with-others.
Edit: The suggested "fragmentation" seems unlikely as Webpack does not enforce the change in the require() syntax. In practice, very few people would use that in the source files because using the overall config file is so much easier and more powerful - it is akin to having a makefile for the JS app.
Browserify also decouples its transforms from its core. The difference is that browserify can correctly identify which transforms your various dependencies are using, since they are listed in the package.json of each module, and it can resolve them automatically during the bundle step. This is not yet in Webpack, which makes code re-use more tedious.
module: {
loaders: [
{ test: /\.json$/, loader: 'json' },
]
}
Elsewhere: var version = require('./package.json').version;
Loaders are common.js packages that export a single function and expect `this` to have the loader API. You can put them as dependencies in your `package.json`. You can wire them up in your config. It's not any less flexible than browserify.- It shows Node compatibility is not a primary concern of Webpack.
- It is not a default feature of Webpack. Pretty much every Webpack project will need to include this loader config if you want to (safely) start consuming Node/browserify modules
I added the config to the article to detail the additional steps.
glslify is another useful one if you're authoring WebGL modules. Not only does it statically analyze the uniforms/attributes for use at runtime, but it also allows for modularization, minification, optimization, etc.
On the other hand, transforms like cssify and hbsfy might be better suited only for the application level.
In an ideal world; these transforms would be completely decoupled from the bundler so that Webpack, Browserify, or anything else can use them in the same way.