Skip to content

Commit

Permalink
Merge pull request #4927 from webpack/bugfix/require-ensure-var-inject
Browse files Browse the repository at this point in the history
fix variable injection in require.ensure
  • Loading branch information
sokra committed May 25, 2017
2 parents 0dd0830 + da08b89 commit 5ec15f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 1 addition & 7 deletions lib/dependencies/RequireEnsureDependenciesBlock.js
Expand Up @@ -11,14 +11,8 @@ module.exports = class RequireEnsureDependenciesBlock extends AsyncDependenciesB
super(chunkName, module, loc);
this.expr = expr;
const successBodyRange = successExpression && successExpression.body && successExpression.body.range;
const errorBodyRange = errorExpression && errorExpression.body && errorExpression.body.range;
this.range = null;
if(successBodyRange) {
if(errorBodyRange) {
this.range = [successBodyRange[0] + 1, errorBodyRange[1] - 1];
} else {
this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
}
this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
}
this.chunkNameRange = chunkNameRange;
const dep = new RequireEnsureDependency(this);
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions test/cases/chunks/var-inject-error-handler/index.js
@@ -0,0 +1,7 @@
it("should handle var injection in require.ensure with error callback", function(done) {
require.ensure([], function(require) {
require("./empty");
var x = module.x;
done();
}, function(error) {}, "chunk-with-var-inject");
});

0 comments on commit 5ec15f8

Please sign in to comment.