Skip to content

Commit

Permalink
emit correct code for requirejs.onError
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 7, 2017
1 parent b95af19 commit 8a737f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/RequireJsStuffPlugin.js
Expand Up @@ -23,7 +23,7 @@ module.exports = class RequireJsStuffPlugin {
parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency("undefined"));

parser.plugin("expression require.version", ParserHelpers.toConstantDependency(JSON.stringify("0.0.0")));
parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency(JSON.stringify("__webpack_require__.oe")));
parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency("__webpack_require__.oe"));
});
});
}
Expand Down
Empty file.
13 changes: 11 additions & 2 deletions test/cases/parsing/requirejs/index.js
@@ -1,11 +1,20 @@
it("should ignore require.config", function() {
require.config({

});
requirejs.config({

});
});
it("should have a require.version", function() {
require.version.should.be.type("string");
});
it("should have a requirejs.onError function", function() {
function f(){}
requirejs.onError.should.be.type("function"); // has default handler
var org = requirejs.onError;
requirejs.onError = f;
requirejs.onError.should.be.eql(f);
requirejs.onError = org;
require(["./file.js"], function() {});
});

0 comments on commit 8a737f3

Please sign in to comment.