Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Last active February 11, 2024 22:26
Show Gist options
  • Save unscriptable/4747843 to your computer and use it in GitHub Desktop.
Save unscriptable/4747843 to your computer and use it in GitHub Desktop.
AMD modules that look like CJS Modules/1.1
define(function (require, exports) {
var foo = require('foo');
exports.bar = 'bar';
});
// this also works:
define(function (require) {
var foo = require('foo');
return { bar: 'bar' };
});
// as does this:
define(function (require, exports, module) {
var foo = require('foo');
module.exports = { bar: 'bar' };
});
@unscriptable
Copy link
Author

no, the require, exports, and module are injected when there are no dependencies listed in the define(), but there are factory params.

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