News for hackers. Stuff that matters.
Re:Browserify: browser-side require() for your node.js by ryanfitz on Tuesday March 29, 2011 @09:26AM (#2382475)
Is it possible to use this with haml-js or jade to render client side templates? As in I want folder of .haml files and then be able to do var newView = require("templates/new");
Re:Browserify: browser-side require() for your node.js by beginnerly on Tuesday March 29, 2011 @06:57AM (#2382130)
From a novices perspective, could someone please explain: what is it? what does it do? why is it better than the alternatives? Thanks!
Re:Browserify: browser-side require() for your node.js by sonnym on Tuesday March 29, 2011 @07:26AM (#2382179)
The CommonJS module specification uses the require() function to include modules. Because this function can take paths, it becomes difficult to share code between the server and the client without some workarounds.

What this module does (after a cursory glance) is:

1) intercept the request for browserify.js,

2) package all the necessary modules into a single file along with a require function that will link the modules to their identifiers, and

3) send the file to the client in a way that allows the calling document (in the case of the example, index.html) to use require() and module identifiers client side just as you would on the server side.

In short, this is a project which aims to lower the barrier between sharing code client and server side with node, as this ability to share code is one of node's greatest upsides in spite of the difficulties of doing so. I believe there are several other projects that perform similar tasks, but I have no direct experience with any of them.

Re:Browserify: browser-side require() for your node.js by beginnerly on Tuesday March 29, 2011 @12:09PM (#2383171)
Thank you,
Re:Browserify: browser-side require() for your node.js by jesusabdullah on Tuesday March 29, 2011 @03:12AM (#2381721)
Valmart's your FATHER, SubStack!

Edit: On a serious note, this looks really exciting, and I can't wait to give it a shot.

Re:Browserify: browser-side require() for your node.js by hazelnut on Tuesday March 29, 2011 @03:36AM (#2381771)
looks great. would be even better when it comes with automatic compression for bigger scripts.
Re:Browserify: browser-side require() for your node.js by focusaurus on Tuesday March 29, 2011 @09:03AM (#2382414)
Everyone always asks this, but compression is most cleanly handled by your web server with Content-encoding: gzip, no? Why do we need to compress and minify markup and script files one at a time by hand?
Re:Browserify: browser-side require() for your node.js by substack on Tuesday March 29, 2011 @09:18AM (#2382453)
Javascript compressors can intelligently remove blocks that general purpose stream compressors can't, like dead code or comments. Also because they understand the AST they can move code around to a limited extent to make the final output shorter.
Re:Browserify: browser-side require() for your node.js by substack on Tuesday March 29, 2011 @03:40AM (#2381778)
Automatic compression isn't in there yet but you can compress the bundles using the "filter" option, which just takes a function that transforms the bundled source.