

Browser-require.js brings "require" to the browser (just like node) - marcuswestin
https://github.com/marcuswestin/browser-require
Browser-require lets you write javascript using "require", "exports" and "module" in the browser, just as you would in node. It helps you with your dependency management, and provides a compiler to condense all your required modules into a single file for production.
======
julius
It uses synchronous XHR to load the JS-File. Then evals the JS-String.

This is great, but I could not figure out debugging my loaded code with this
solution.

Any ideas ?

~~~
arthurschreiber
Firebug and the WebKit Inspector allow you to set breakpoints by just putting
"debugger;" where you want to jump into debugging.

~~~
julius
Thanks. I did not know that.

The problem of getting stacktraces for errors remains.

UPDATE: Just tested in Safari. I get nice stacktraces there. Its only a
problem in Chrome.

------
arthurschreiber
The main difference between this and other solutions like RequireJS is the
fact that you don't have to wrap your CommonJS modules in callbacks and thus
could in theory use them "unmodified".

~~~
marcuswestin
That's one of the big differences - I'd say the other big difference is that
it comes with a compiler that bundles all your required modules into a single
javascript file for production

~~~
arthurschreiber
RequireJS also has it's own compiler.

~~~
marcuswestin
Did not know that! :P

I guess browser-require will still be useful, since you can import the same
files in node and in the browser

------
geuis
I don't understand. Require.js _already_ works in the browser.
<http://requirejs.org/>

~~~
marcuswestin
require.js does asynchronous file loading and is supposed to be deployed as-is
in production. Browser-require makes it easy to develop your code using
synchronous require statements and straight-forward dependency management. For
production it has a compiler that combines all the required files into a
single file (which is the only way you should serve your javascript in
production)

~~~
rmurphey3
RequireJS also has a "compiler" that will combine your files into one or more
layers for production use, as well as straightforward dependency management.

------
sjs
> When a module is required, we fetch it's javascript as a string using a
> synchronous XHR.

~~~
arthurschreiber
Obviously, that's meant for development only and that's why it also ships with
it's own compiler for production (where I seriously hope they don't use a
synchronous XHR to fetch the compiled code).

~~~
marcuswestin
no, it does not :)

