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(/\$require\$/g, this.requireFn)
 | 
				
			||||||
				.replace(/\$hash\$/g, JSON.stringify(hash))
 | 
									.replace(/\$hash\$/g, JSON.stringify(hash))
 | 
				
			||||||
				.replace(/\$requestTimeout\$/g, requestTimeout)
 | 
									.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) {
 | 
						apply(mainTemplate) {
 | 
				
			||||||
		mainTemplate.plugin("local-vars", function(source, chunk) {
 | 
							mainTemplate.plugin("local-vars", function(source, chunk) {
 | 
				
			||||||
			if(chunk.chunks.length > 0) {
 | 
								if(chunk.getChunks().size > 0) {
 | 
				
			||||||
				return this.asString([
 | 
									return this.asString([
 | 
				
			||||||
					source,
 | 
										source,
 | 
				
			||||||
					"",
 | 
										"",
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,7 @@ class JsonpMainTemplatePlugin {
 | 
				
			||||||
			]);
 | 
								]);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		mainTemplate.plugin("require-extensions", function(source, chunk) {
 | 
							mainTemplate.plugin("require-extensions", function(source, chunk) {
 | 
				
			||||||
			if(chunk.chunks.length === 0) return source;
 | 
								if(chunk.getChunks().size === 0) return source;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return this.asString([
 | 
								return this.asString([
 | 
				
			||||||
				source,
 | 
									source,
 | 
				
			||||||
| 
						 | 
					@ -120,7 +120,7 @@ class JsonpMainTemplatePlugin {
 | 
				
			||||||
			]);
 | 
								]);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
 | 
							mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
 | 
				
			||||||
			if(chunk.chunks.length > 0) {
 | 
								if(chunk.getChunks().size > 0) {
 | 
				
			||||||
				var jsonpFunction = this.outputOptions.jsonpFunction;
 | 
									var jsonpFunction = this.outputOptions.jsonpFunction;
 | 
				
			||||||
				return this.asString([
 | 
									return this.asString([
 | 
				
			||||||
					source,
 | 
										source,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,7 +99,7 @@ module.exports = class MainTemplate extends Template {
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		this.plugin("require-extensions", (source, chunk, hash) => {
 | 
							this.plugin("require-extensions", (source, chunk, hash) => {
 | 
				
			||||||
			const buf = [];
 | 
								const buf = [];
 | 
				
			||||||
			if(chunk.chunks.length > 0) {
 | 
								if(chunk.getChunks().size > 0) {
 | 
				
			||||||
				buf.push("// This file contains only the entry chunk.");
 | 
									buf.push("// This file contains only the entry chunk.");
 | 
				
			||||||
				buf.push("// The chunk loading function for additional chunks");
 | 
									buf.push("// The chunk loading function for additional chunks");
 | 
				
			||||||
				buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);
 | 
									buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ module.exports = class NodeMainTemplatePlugin {
 | 
				
			||||||
	apply(mainTemplate) {
 | 
						apply(mainTemplate) {
 | 
				
			||||||
		const asyncChunkLoading = this.asyncChunkLoading;
 | 
							const asyncChunkLoading = this.asyncChunkLoading;
 | 
				
			||||||
		mainTemplate.plugin("local-vars", function(source, chunk) {
 | 
							mainTemplate.plugin("local-vars", function(source, chunk) {
 | 
				
			||||||
			if(chunk.chunks.length > 0) {
 | 
								if(chunk.getChunks().size > 0) {
 | 
				
			||||||
				return this.asString([
 | 
									return this.asString([
 | 
				
			||||||
					source,
 | 
										source,
 | 
				
			||||||
					"",
 | 
										"",
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ module.exports = class NodeMainTemplatePlugin {
 | 
				
			||||||
			return source;
 | 
								return source;
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		mainTemplate.plugin("require-extensions", function(source, chunk) {
 | 
							mainTemplate.plugin("require-extensions", function(source, chunk) {
 | 
				
			||||||
			if(chunk.chunks.length > 0) {
 | 
								if(chunk.getChunks().size > 0) {
 | 
				
			||||||
				return this.asString([
 | 
									return this.asString([
 | 
				
			||||||
					source,
 | 
										source,
 | 
				
			||||||
					"",
 | 
										"",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@ const Template = require("../Template");
 | 
				
			||||||
class WebWorkerMainTemplatePlugin {
 | 
					class WebWorkerMainTemplatePlugin {
 | 
				
			||||||
	apply(mainTemplate) {
 | 
						apply(mainTemplate) {
 | 
				
			||||||
		mainTemplate.plugin("local-vars", function(source, chunk) {
 | 
							mainTemplate.plugin("local-vars", function(source, chunk) {
 | 
				
			||||||
			if(chunk.chunks.length > 0) {
 | 
								if(chunk.getChunks().size > 0) {
 | 
				
			||||||
				return this.asString([
 | 
									return this.asString([
 | 
				
			||||||
					source,
 | 
										source,
 | 
				
			||||||
					"",
 | 
										"",
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ class WebWorkerMainTemplatePlugin {
 | 
				
			||||||
			]);
 | 
								]);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
 | 
							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 || ""));
 | 
									const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
 | 
				
			||||||
				return this.asString([
 | 
									return this.asString([
 | 
				
			||||||
					source,
 | 
										source,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue