Consider two scenarios:
- compile browser version of a Javascript library, pulling out all
requiredependencies and putting them in one file. - compile a node.js version of the same library, but ignoring those
requiredependencies allowing node to handle them.
I thought of using requirejs / r.js, however I'm seem to be unable to work out the special sauce to do something like this.
Are there other build systems that can do this? Could I mod r.js in some way? Answers on postcard.
It sounds like you may want to optionally use node's require or requirejs' require depending on the environment. You can do this by using a variation of a "universal module boilerplate". Some examples are in the umdjs project. I mean to add more examples/variations to that project, will get on that soon.