Skip to content

Commit

Permalink
OpenNTFGH-67 Unexpected webpack require behaviour
Browse files Browse the repository at this point in the history
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Oct 19, 2017
1 parent 19f842c commit 28ed887
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/DojoAMDMainTemplate.runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ module.exports = function() {
}
}
if (!result) {
throw new Error('Module not found: ' + mid);
var msg = 'Module not found: ' + mid;
if (noInstall) {
throw new Error(msg);
} else {
console.error(msg);
}
}
return result;
}
Expand Down
11 changes: 10 additions & 1 deletion test/TestCases/dependencies/simple/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["exports", "module", "./dep"], function(exports, module, dep) {
define(["exports", "module", "./dep"], function (exports, module, dep) {
it("should compile", function(done) {
done();
});
Expand Down Expand Up @@ -39,6 +39,15 @@ define(["exports", "module", "./dep"], function(exports, module, dep) {
});
});

it("runtime require", function (done) {
var deps = ["missingModule", "test/dep"];
require(deps, function (reqMissingModule, reqDep) {
(typeof reqMissingModule).should.be.eql("undefined");
reqDep.should.be.eql(dep);
done();
});
});

dep.runTests();

});

0 comments on commit 28ed887

Please sign in to comment.