Skip to content

Commit 7972859

Browse files
committed
refactor chunk.chunks usage to check for chunk existance
1 parent 53f70c7 commit 7972859

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

lib/HotModuleReplacementPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ HotModuleReplacementPlugin.prototype.apply = function(compiler) {
172172
.replace(/\$require\$/g, this.requireFn)
173173
.replace(/\$hash\$/g, JSON.stringify(hash))
174174
.replace(/\$requestTimeout\$/g, requestTimeout)
175-
.replace(/\/\*foreachInstalledChunks\*\//g, chunk.chunks.length > 0 ? "for(var chunkId in installedChunks)" : "var chunkId = " + JSON.stringify(chunk.id) + ";")
175+
.replace(/\/\*foreachInstalledChunks\*\//g, chunk.getChunks().size > 0 ? "for(var chunkId in installedChunks)" : "var chunkId = " + JSON.stringify(chunk.id) + ";")
176176
]);
177177
});
178178

lib/JsonpMainTemplatePlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class JsonpMainTemplatePlugin {
1010

1111
apply(mainTemplate) {
1212
mainTemplate.plugin("local-vars", function(source, chunk) {
13-
if(chunk.chunks.length > 0) {
13+
if(chunk.getChunks().size > 0) {
1414
return this.asString([
1515
source,
1616
"",
@@ -110,7 +110,7 @@ class JsonpMainTemplatePlugin {
110110
]);
111111
});
112112
mainTemplate.plugin("require-extensions", function(source, chunk) {
113-
if(chunk.chunks.length === 0) return source;
113+
if(chunk.getChunks().size === 0) return source;
114114

115115
return this.asString([
116116
source,
@@ -120,7 +120,7 @@ class JsonpMainTemplatePlugin {
120120
]);
121121
});
122122
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
123-
if(chunk.chunks.length > 0) {
123+
if(chunk.getChunks().size > 0) {
124124
var jsonpFunction = this.outputOptions.jsonpFunction;
125125
return this.asString([
126126
source,

lib/MainTemplate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module.exports = class MainTemplate extends Template {
9999
});
100100
this.plugin("require-extensions", (source, chunk, hash) => {
101101
const buf = [];
102-
if(chunk.chunks.length > 0) {
102+
if(chunk.getChunks().size > 0) {
103103
buf.push("// This file contains only the entry chunk.");
104104
buf.push("// The chunk loading function for additional chunks");
105105
buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);

lib/node/NodeMainTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = class NodeMainTemplatePlugin {
1414
apply(mainTemplate) {
1515
const asyncChunkLoading = this.asyncChunkLoading;
1616
mainTemplate.plugin("local-vars", function(source, chunk) {
17-
if(chunk.chunks.length > 0) {
17+
if(chunk.getChunks().size > 0) {
1818
return this.asString([
1919
source,
2020
"",
@@ -28,7 +28,7 @@ module.exports = class NodeMainTemplatePlugin {
2828
return source;
2929
});
3030
mainTemplate.plugin("require-extensions", function(source, chunk) {
31-
if(chunk.chunks.length > 0) {
31+
if(chunk.getChunks().size > 0) {
3232
return this.asString([
3333
source,
3434
"",

lib/webworker/WebWorkerMainTemplatePlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Template = require("../Template");
99
class WebWorkerMainTemplatePlugin {
1010
apply(mainTemplate) {
1111
mainTemplate.plugin("local-vars", function(source, chunk) {
12-
if(chunk.chunks.length > 0) {
12+
if(chunk.getChunks().size > 0) {
1313
return this.asString([
1414
source,
1515
"",
@@ -48,7 +48,7 @@ class WebWorkerMainTemplatePlugin {
4848
]);
4949
});
5050
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
51-
if(chunk.chunks.length > 0) {
51+
if(chunk.getChunks().size > 0) {
5252
const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
5353
return this.asString([
5454
source,

0 commit comments

Comments
 (0)