Skip to content

Commit 1c1a5ca

Browse files
committed
smaller bundles without Code Splittings
1 parent 308ddf2 commit 1c1a5ca

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

lib/JsonpMainTemplatePlugin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) {
2626
}
2727
return source;
2828
});
29+
mainTemplate.plugin("require-extensions", function(source, chunk) {
30+
if(chunk.chunks.length === 0) return source;
31+
return this.asString([
32+
source,
33+
"",
34+
"// on error function for async loading",
35+
this.requireFn + ".oe = function(err) { throw err; };"
36+
]);
37+
});
2938
mainTemplate.plugin("jsonp-script", function(_, chunk, hash) {
3039
var filename = this.outputOptions.filename;
3140
var chunkFilename = this.outputOptions.chunkFilename;

lib/MainTemplate.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ function MainTemplate(outputOptions) {
9191
buf.push("// expose the module cache");
9292
buf.push(this.requireFn + ".c = installedModules;");
9393

94-
buf.push("");
95-
buf.push("// on error function for async loading");
96-
buf.push(this.requireFn + ".oe = function(err) { throw err; };");
97-
9894
var publicPath = this.getPublicPath({
9995
hash: hash
10096
});
@@ -119,6 +115,7 @@ MainTemplate.prototype.render = function(hash, chunk, moduleTemplate, dependency
119115
buf.push("}");
120116
buf.push("");
121117
buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
118+
buf.push("");
122119
buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
123120
var source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
124121
if(chunk.modules.some(function(module) {

0 commit comments

Comments
 (0)