mirror of https://github.com/webpack/webpack.git
refactor chunk.chunks usage to check for chunk existance
This commit is contained in:
parent
53f70c7aeb
commit
7972859640
|
|
@ -172,7 +172,7 @@ HotModuleReplacementPlugin.prototype.apply = function(compiler) {
|
|||
.replace(/\$require\$/g, this.requireFn)
|
||||
.replace(/\$hash\$/g, JSON.stringify(hash))
|
||||
.replace(/\$requestTimeout\$/g, requestTimeout)
|
||||
.replace(/\/\*foreachInstalledChunks\*\//g, chunk.chunks.length > 0 ? "for(var chunkId in installedChunks)" : "var chunkId = " + JSON.stringify(chunk.id) + ";")
|
||||
.replace(/\/\*foreachInstalledChunks\*\//g, chunk.getChunks().size > 0 ? "for(var chunkId in installedChunks)" : "var chunkId = " + JSON.stringify(chunk.id) + ";")
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class JsonpMainTemplatePlugin {
|
|||
|
||||
apply(mainTemplate) {
|
||||
mainTemplate.plugin("local-vars", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
|
|
@ -110,7 +110,7 @@ class JsonpMainTemplatePlugin {
|
|||
]);
|
||||
});
|
||||
mainTemplate.plugin("require-extensions", function(source, chunk) {
|
||||
if(chunk.chunks.length === 0) return source;
|
||||
if(chunk.getChunks().size === 0) return source;
|
||||
|
||||
return this.asString([
|
||||
source,
|
||||
|
|
@ -120,7 +120,7 @@ class JsonpMainTemplatePlugin {
|
|||
]);
|
||||
});
|
||||
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
var jsonpFunction = this.outputOptions.jsonpFunction;
|
||||
return this.asString([
|
||||
source,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ module.exports = class MainTemplate extends Template {
|
|||
});
|
||||
this.plugin("require-extensions", (source, chunk, hash) => {
|
||||
const buf = [];
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
buf.push("// This file contains only the entry chunk.");
|
||||
buf.push("// The chunk loading function for additional chunks");
|
||||
buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module.exports = class NodeMainTemplatePlugin {
|
|||
apply(mainTemplate) {
|
||||
const asyncChunkLoading = this.asyncChunkLoading;
|
||||
mainTemplate.plugin("local-vars", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
|
|
@ -28,7 +28,7 @@ module.exports = class NodeMainTemplatePlugin {
|
|||
return source;
|
||||
});
|
||||
mainTemplate.plugin("require-extensions", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const Template = require("../Template");
|
|||
class WebWorkerMainTemplatePlugin {
|
||||
apply(mainTemplate) {
|
||||
mainTemplate.plugin("local-vars", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
|
|
@ -48,7 +48,7 @@ class WebWorkerMainTemplatePlugin {
|
|||
]);
|
||||
});
|
||||
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
if(chunk.getChunks().size > 0) {
|
||||
const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
|
||||
return this.asString([
|
||||
source,
|
||||
|
|
|
|||
Loading…
Reference in New Issue