smaller code splitting for merged chunks

This commit is contained in:
Tobias Koppers 2013-10-30 23:25:02 +01:00
parent e0a8dbc037
commit c32b233a4f
1 changed files with 7 additions and 2 deletions

View File

@ -23,8 +23,13 @@ RequireEnsureDependency.Template.prototype.apply = function(dep, source, outputO
if(outputOptions.pathinfo) comment = "/*! " + requestShortener.shorten(depBlock.chunkName) + " */ ";
source.replace(depBlock.chunkNameRange[0], depBlock.chunkNameRange[1]-1, comment + "0");
}
if(depBlock.chunk && depBlock.chunk.id) {
source.replace(depBlock.expr.callee.range[0], depBlock.expr.callee.range[1]-1, "require.e/*nsure*/");
source.replace(depBlock.expr.arguments[0].range[0], depBlock.expr.arguments[0].range[1]-1, (depBlock.chunk && depBlock.chunk.id || 0) + "" + asComment(depBlock.chunkReason));
source.replace(depBlock.expr.arguments[0].range[0], depBlock.expr.arguments[0].range[1]-1, (depBlock.chunk.id) + "" + asComment(depBlock.chunkReason));
} else {
source.replace(depBlock.expr.range[0], depBlock.expr.arguments[1].range[0]-1, "/*require.ensure*/(");
source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.range[1]-1, "(require))");
}
}
function asComment(str) {