News for hackers. Stuff that matters.
Re:Reusing require.js modules in Node.js with AMDrequire by couchand on Wednesday May 21, 2014 @10:21AM (#7778367)
I disagree with the assertion that the browserify transformation implies it's "not the same code". If you're (following best practice and) concatenating and minifying your assets, is that not the same thing?

The compilation step that browserify uses is little more than concatenate + a little bit of sugar. Practically speaking why does this matter?

I'd much prefer to deliver less code to the client if possible, so I don't see the rationale for adding a dependency on a dependency manager.

Re:Reusing require.js modules in Node.js with AMDrequire by jgillich on Wednesday May 21, 2014 @11:10AM (#7778629)
Exactly. RequireJS promotes having lots of files, but for production, everyone runs their code through r.js anyway.

I used RequireJS for a while and it isn't bad, but Browserify has a lot of advantages like compatibility with Node.js and npm (while the only disadvantage I see is that the compile step is non-optional).

Re:Reusing require.js modules in Node.js with AMDrequire by chr1 on Wednesday May 21, 2014 @11:41AM (#7778828)
Browserify compile step on a large project is painfully slow. Using https://www.npmjs.org/package/amd-loader with commonjs style modules http://requirejs.org/docs/commonjs.html was much easier to use.

> I'd much prefer to deliver less code to the client if possible

requirejs shim isn't signifcantly larger than what browserify adds, it's only 200 lines.

Re:Reusing require.js modules in Node.js with AMDrequire by couchand on Wednesday May 21, 2014 @11:54AM (#7778893)
Browserify compile step on a large project is painfully slow.

I'd be very interested in seeing a set of benchmarks comparing browserify to r.js. I'd be very surprised if the difference was meaningful, since they do basically the same thing. In fact, doesn't r.js support CommonJS-style requires?

Re:Reusing require.js modules in Node.js with AMDrequire by chr1 on Wednesday May 21, 2014 @12:02PM (#7778941)
The speed of r.js and browserify compile is about the same, indeed. The difference is that with browserify i had to wait for it on every reload, and r.js runs only for release, on buildbot.
Re:Reusing require.js modules in Node.js with AMDrequire by greggman on Wednesday May 21, 2014 @11:01AM (#7778591)
I don't know browserify well but I'd assume having a compile step is the part that sucks. If you can use require.js style until shipping time you can debug the actual code directly instead of the compiled code. You see each module in the debugger as its original file.
Re:Reusing require.js modules in Node.js with AMDrequire by jgillich on Wednesday May 21, 2014 @11:12AM (#7778640)
Source maps solve that issue, even though browser support isn't perfect yet.
Re:Reusing require.js modules in Node.js with AMDrequire by alistairjcbrown on Wednesday May 21, 2014 @11:31AM (#7778769)
+1 - this is why I love requirejs - lazy load modules in development, compile for QA and deployment.

Update: My other love for requirejs is that you don't need to use relative paths when requiring a module. Once you have a relative path, you can't change the location of either dependant or dependency. The require config lets you separate what you call the module from the location of the file.

Re:Reusing require.js modules in Node.js with AMDrequire by danabramov on Wednesday May 21, 2014 @12:51PM (#7779257)
I tried porting a project from Require to Browserify and I gave up because of relative paths issue.