Skip to content

Instantly share code, notes, and snippets.

@bytespider
Created November 15, 2011 12:25
Show Gist options
  • Select an option

  • Save bytespider/1366958 to your computer and use it in GitHub Desktop.

Select an option

Save bytespider/1366958 to your computer and use it in GitHub Desktop.
Tweet question

Consider two scenarios:

  • compile browser version of a Javascript library, pulling out all require dependencies and putting them in one file.
  • compile a node.js version of the same library, but ignoring those require dependencies 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.

@jrburke

jrburke commented Nov 15, 2011

Copy link
Copy Markdown

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.

@bytespider

Copy link
Copy Markdown
Author

Thank you. I considered using has.js to switch between the two styles of require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment