Browserify
Video Course on Building Web Applications with Node.js
- use commonjs require modules in the browser
- don't have to use boilerplate code to prevent polluting the global namespace (if you have several files)
you can then use
require
in your client side codethis file will become a self-contained node module environment - the browserified javascript file can run on any javascript environment (like iOS, or JVM)
a portable nodejs module loading environment
you can use any core, local
adds shims for filesystem and other standard nodejs libraries
Why would I want to use browserify?
- helps you write modular code on the client
- no need to build your own js file
- no futzing with client-side script loading (no need for ajax to load files) - on mobile each request is even more "expensive"
- share client and server code
- have the same code stlye, package management and module system as server! use the same code style and toolset for both environments
code reuse (client/server) - validation, server APIs,
> in practice you don't get so much code reuse
Fun browserify feature
- browser shims for lots of node core
- can provide modules with alternate entry points when used by browserify in npm you can specify an entry point for server and an entry point for the client. for the end-user, you require the same module and you interface the same way
- Source Maps (for debugging in web inspector)