Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including amd-wrap with all npm packages installed. Try it out:

var amdWrap = require("amd-wrap")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

amd-wrap v1.1.0

Wraps CommonJS files in `define(function (require, exports, module) { ... })`.

Simple Wrapping of CommonJS to AMD

All this module does is wrap your CommonJS modules into the simplified CommonJS wrapper format, i.e.:

define(function (require, exports, module) {
    // your CommonJS code here

It takes in a string and gives back a string:

var amdWrap = require("amd-wrap");

var wrapped = amdWrap("module.exports = 5;");
var wrapThis = amdWrap(fs.readFileSync(__filename));

Line numbers will line up, although the first column will be shifted by "define (function (require, exports, module) {".length characters.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free