Skip to content

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

License

Notifications You must be signed in to change notification settings

domenic/amd-wrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

See also: amd-wrap-legacy, which has a few more affordances for use when transitioning a larger codebase from CommonJS to AMD.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published