You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that the "dependencies" section is missing some details. What is special with the dependency name "exports"? What should happen if a module definition lists the "exports" dependency, and at the same time its factory function returns a value? Here is an example of that behavior:
If the factory function returns a value (an object, function, or any value that coerces to true), then that value should be assigned as the exported value for the module.
This means the exports module will be ignored.
AMD has a priority for the different exports variations (low - high):
if ["exports"] is in the dependencies list exports will be exported
if ["module"] is in the dependencies list module.exports will be exported, note that module.exports and exports are the same object if module.exports is not reassigned within the factory
if factory function returns a value (an object, function, or any value that coerces to true) it will be exported
The modules ["require", "exports", "module"] are based on the CommonJS modules specification.
Example of CommonJS module:
var foo = require("foo"),
bar = require("bar");
exports.foo = foo;
exports.bar = bar;
Convert it to AMD:
define(["require", "exports", "module", "foo", "bar"], function (require, exports, module) {
var foo = require("foo"),
bar = require("bar");
exports.foo = foo;
exports.bar = bar;
});
I think that the "dependencies" section is missing some details. What is special with the dependency name "exports"? What should happen if a module definition lists the "exports" dependency, and at the same time its factory function returns a value? Here is an example of that behavior:
https://github.com/Reactive-Extensions/RxJS-DOM/blob/921c35a28265466cda7fc2dcdbacfe688efcd456/rx.dom.js#L25
Should the return value of the factory function be used in this case, or should you save the "exports" object as the module value?
The text was updated successfully, but these errors were encountered: