Skip to content

Commit

Permalink
Fixes typo reported by NoKarma that caused module.exports assignments…
Browse files Browse the repository at this point in the history
… to not work if the the 'module' dependency was not the last dependency in the list. Nice find. Added a new unit test so this does not regress in the future.
  • Loading branch information
jrburke committed Oct 1, 2010
1 parent 415faea commit 079e8b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion require.js
Expand Up @@ -1315,7 +1315,7 @@ var require;
ret = defined[name]; ret = defined[name];
} else { } else {
if (cjsModule && "exports" in cjsModule) { if (cjsModule && "exports" in cjsModule) {
ret = defined[name] = depModule.exports; ret = defined[name] = cjsModule.exports;
} else { } else {
if (name in defined && !usingExports) { if (name in defined && !usingExports) {
req.onError(new Error(name + " has already been defined")); req.onError(new Error(name + " has already been defined"));
Expand Down
4 changes: 4 additions & 0 deletions tests/exports/assign2.js
@@ -0,0 +1,4 @@
require.def(["module", "exports", "require"],
function (module, exports, require) {
module.exports = "assign2";
});
5 changes: 3 additions & 2 deletions tests/exports/exports-tests.js
@@ -1,15 +1,16 @@
require({ require({
baseUrl: require.isBrowser ? "./" : "./exports/" baseUrl: require.isBrowser ? "./" : "./exports/"
}, },
["require", "vanilla", "funcSet", "assign"], ["require", "vanilla", "funcSet", "assign", "assign2"],
function(require, vanilla, funcSet, assign) { function(require, vanilla, funcSet, assign, assign2) {
doh.register( doh.register(
"exports", "exports",
[ [
function exports(t){ function exports(t){
t.is("vanilla", vanilla.name); t.is("vanilla", vanilla.name);
t.is("funcSet", funcSet); t.is("funcSet", funcSet);
t.is("assign", assign); t.is("assign", assign);
t.is("assign2", assign2);
} }
] ]
); );
Expand Down

0 comments on commit 079e8b1

Please sign in to comment.