mirror of https://github.com/webpack/webpack.git
edge case where injecting into require.e functions #102
This commit is contained in:
parent
2dd0ba9552
commit
bedd59390c
|
@ -82,6 +82,7 @@ NormalModule.prototype.source = function(dependencyTemplates, outputOptions, req
|
|||
var _source = this._source;
|
||||
if(!_source) return new RawSource("throw new Error('No source availible');");
|
||||
var source = new ReplaceSource(_source);
|
||||
var topLevelBlock = this;
|
||||
function doDep(dep) {
|
||||
var template = dependencyTemplates.get(dep.Class);
|
||||
if(!template) throw new Error("No template for dependency: " + dep.Class.name);
|
||||
|
@ -106,7 +107,9 @@ NormalModule.prototype.source = function(dependencyTemplates, outputOptions, req
|
|||
if(varNames.length == 0) return;
|
||||
|
||||
varStartCode += "/* WEBPACK VAR INJECTION */(function(require, " + varNames.join(", ") + ") {";
|
||||
varEndCode = "}.call(exports, require, " + varExpressions.map(function(e) {return e.source()}).join(", ") + "))" + varEndCode;
|
||||
// exports === this in the topLevelBlock, but exports do compress better...
|
||||
varEndCode = (topLevelBlock === block ? "}.call(exports, require, " : "}.call(this, require, ") +
|
||||
varExpressions.map(function(e) {return e.source()}).join(", ") + "))" + varEndCode;
|
||||
|
||||
varNames.length = 0;
|
||||
varExpressions.length = 0;
|
||||
|
|
Loading…
Reference in New Issue