How browserify makes Node.js modules to work in the browser?

Ii really can't understand some work behind browserify. When using pure JavaScript modules it seems "easy" to convert it to browser code, even if with many dependencies.

But browserify does more:

Many npm modules that don't do IO will just work after being browserified. Others take more work.

Many node built-in modules have been wrapped to work in the browser, but only when you explicitly require() or use their functionality.

When you require() any of these modules, you will get a browser-specific shim.

And again:

  • process.nextTick(), __dirname, and __filename node-isms work
  • get browser versions of the node core libraries events, stream, path, url, assert, buffer, util, querystring, http, vm, and crypto when you require() them

So... process.nextTick(), __dirname inside the browser... even http? This doesn't make sense to me... how __dirname is supposed to work inside a browser?

process.nextTick() simply runs a callback later.
In a browser, this is simulated using setTimeout(func, 0), setImmediate, or requestAnimationFrame().

__dirnamne and __filename are simply variables that browserify injects at compile-time based on the original path to the file.

This question is very similar to this one.

I provided an answer there which should be helpful here as well.