lib/modules.js
function wrap(err, js) {
		if (err) { return next(err); }

		var deps = exports.dependencies(id, js), params = [], undef = '';

		// make sure require, exports, and module are properly passed into the factory
		if (/\brequire\b/.test(js)) { params.push('require'); }
		if (/\bexports\b/.test(js)) { params.push('exports'); }
		if (/\bmodule\b/.test(js)) { params.push('module'); }

		// make sure code follows the `exports` path instead of `define` path once wrapped
		if (/\bdefine\.amd\b/.test(js)) { undef = 'var define;'; }

		if (deps.length) {
			deps = ',' + JSON.stringify(params.concat(deps));
		} else if (params.length) {
			params = [ 'require', 'exports', 'module' ];
		}

		js = 'define(' + JSON.stringify(id) + deps + ',function(' + params + ')' +
				'{' + js + '\n' + undef + '}' + // rely on hoisting for define
			');\n';
		next(null, js);
	}
function wrap(err, js) {
		if (err) { return next(err); }

		var deps = exports.dependencies(id, js), params = [], undef = '';

		// make sure require, exports, and module are properly passed into the factory
		if (/\brequire\b/.test(js)) { params.push('require'); }
		if (/\bexports\b/.test(js)) { params.push('exports'); }
		if (/\bmodule\b/.test(js)) { params.push('module'); }

		// make sure code follows the `exports` path instead of `define` path once wrapped
		if (/\bdefine\.amd\b/.test(js)) { undef = 'var define;'; }

		if (deps.length) {
			deps = ',' + JSON.stringify(params.concat(deps));
		} else if (params.length) {
			params = [ 'require', 'exports', 'module' ];
		}

		js = 'define(' + JSON.stringify(id) + deps + ',function(' + params + ')' +
				'{' + js + '\n' + undef + '}' + // rely on hoisting for define
			');\n';
		next(null, js);
	}
function wrap ( err , js ) { if ( err ) { return next ( err ) ; } var deps = exports . dependencies ( id , js ) , params = [ ] , undef = '' ; // make sure require, exports, and module are properly passed into the factory if ( / \brequire\b / . test ( js ) ) { params . push ( 'require' ) ; } if ( / \bexports\b / . test ( js ) ) { params . push ( 'exports' ) ; } if ( / \bmodule\b / . test ( js ) ) { params . push ( 'module' ) ; } // make sure code follows the `exports` path instead of `define` path once wrapped if ( / \bdefine\.amd\b / . test ( js ) ) { undef = 'var define;' ; } if ( deps . length ) { deps = ',' + JSON . stringify ( params . concat ( deps ) ) ; } else if ( params . length ) { params = [ 'require' , 'exports' , 'module' ] ; } js = 'define(' + JSON . stringify ( id ) + deps + ',function(' + params + ')' + '{' + js + '\n' + undef + '}' + // rely on hoisting for define ');\n' ; next ( null , js ) ; }
convert commonjs to amd
convert commonjs to amd