Skip to content

Instantly share code, notes, and snippets.

@KidkArolis
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KidkArolis/65caaa958f66bd46dbe6 to your computer and use it in GitHub Desktop.
Save KidkArolis/65caaa958f66bd46dbe6 to your computer and use it in GitHub Desktop.
Convert CJS to AMD using r.js
var requirejs = require("requirejs")
requirejs.tools.useLib("build", function (req) {
req(["commonJs"], function (cjs) {
// first arg is filename (not sure why that matters yet)
// second arg - the code
var converted = cjs.convert("foo", "module.exports = 42;");
console.log(converted);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment