2020-08-26 03:45:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MIT  License  http : //www.opensource.org/licenses/mit-license.php
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Author  Tobias  Koppers  @ sokra 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								* /  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"use strict" ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/** @typedef {import("../../declarations/WebpackOptions").ChunkLoadingType} ChunkLoadingType */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/** @typedef {import("../Compiler")} Compiler */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/** @type {WeakMap<Compiler, Set<ChunkLoadingType>>} */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  enabledTypes  =  new  WeakMap ( ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  getEnabledTypes  =  compiler  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									let  set  =  enabledTypes . get ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( set  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set  =  new  Set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										enabledTypes . set ( compiler ,  set ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  set ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  EnableChunkLoadingPlugin  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/ * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ param  { ChunkLoadingType }  type  library  type  that  should  be  available 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									constructor ( type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										this . type  =  type ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/ * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ param  { Compiler }  compiler  the  compiler  instance 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ param  { ChunkLoadingType }  type  type  of  library 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ returns  { void } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									static  setEnabled ( compiler ,  type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										getEnabledTypes ( compiler ) . add ( type ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/ * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ param  { Compiler }  compiler  the  compiler  instance 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ param  { ChunkLoadingType }  type  type  of  library 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ returns  { void } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									static  checkEnabled ( compiler ,  type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! getEnabledTypes ( compiler ) . has ( type ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											throw  new  Error ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-05 18:30:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												` Chunk loading type " ${ type } " is not enabled.  `  + 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 03:45:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
													"EnableChunkLoadingPlugin need to be used to enable this type of chunk loading. "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													'This usually happens through the "output.enabledChunkLoadingTypes" option. '  + 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-05 18:30:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													'If you are using a function as entry which sets "chunkLoading", you need to add all potential chunk loading types to "output.enabledChunkLoadingTypes". '  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													"These types are enabled: "  + 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 03:45:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
													Array . from ( getEnabledTypes ( compiler ) ) . join ( ", " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/ * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  Apply  the  plugin 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ param  { Compiler }  compiler  the  compiler  instance 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ returns  { void } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									apply ( compiler )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  {  type  }  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Only enable once
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  enabled  =  getEnabledTypes ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( enabled . has ( type ) )  return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										enabled . add ( type ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( typeof  type  ===  "string" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											switch  ( type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  "jsonp" :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													const  JsonpChunkLoadingPlugin  =  require ( "../web/JsonpChunkLoadingPlugin" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													new  JsonpChunkLoadingPlugin ( ) . apply ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  "import-scripts" :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													const  ImportScriptsChunkLoadingPlugin  =  require ( "../webworker/ImportScriptsChunkLoadingPlugin" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													new  ImportScriptsChunkLoadingPlugin ( ) . apply ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  "require" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-26 20:12:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													//@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 03:45:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
													const  CommonJsChunkLoadingPlugin  =  require ( "../node/CommonJsChunkLoadingPlugin" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													new  CommonJsChunkLoadingPlugin ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														asyncChunkLoading :  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} ) . apply ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  "async-node" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-26 20:12:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													//@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 03:45:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
													const  CommonJsChunkLoadingPlugin  =  require ( "../node/CommonJsChunkLoadingPlugin" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													new  CommonJsChunkLoadingPlugin ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														asyncChunkLoading :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} ) . apply ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 19:58:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												case  "import" :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													const  ModuleChunkLoadingPlugin  =  require ( "../esm/ModuleChunkLoadingPlugin" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													new  ModuleChunkLoadingPlugin ( ) . apply ( compiler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-10 16:42:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												case  "universal" : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													// TODO implement universal chunk loading
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													throw  new  Error ( "Universal Chunk Loading is not implemented yet" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 03:45:56 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													throw  new  Error ( ` Unsupported chunk loading type  ${ type } .
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Plugins  which  provide  custom  chunk  loading  types  must  call  EnableChunkLoadingPlugin . setEnabled ( compiler ,  type )  to  disable  this  error . ` );
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// TODO support plugin instances here
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// apply them to the compiler
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								module . exports  =  EnableChunkLoadingPlugin ;