Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Last active February 11, 2024 22:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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' };
});
@juandopazo
Copy link

Are those appended at the last of the parameter list when there are dependencies?

@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