| 
									
										
										
										
											2015-05-17 00:27:59 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 16:33:01 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2015-05-17 00:27:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const DllModuleFactory = require("./DllModuleFactory"); | 
					
						
							| 
									
										
										
										
											2016-12-29 16:33:01 +08:00
										 |  |  | const DllEntryDependency = require("./dependencies/DllEntryDependency"); | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | const EntryDependency = require("./dependencies/EntryDependency"); | 
					
						
							| 
									
										
										
										
											2016-12-29 16:33:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class DllEntryPlugin { | 
					
						
							| 
									
										
										
										
											2017-01-06 01:53:18 +08:00
										 |  |  | 	constructor(context, entries, name) { | 
					
						
							| 
									
										
										
										
											2016-12-29 16:33:01 +08:00
										 |  |  | 		this.context = context; | 
					
						
							|  |  |  | 		this.entries = entries; | 
					
						
							|  |  |  | 		this.name = name; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap( | 
					
						
							|  |  |  | 			"DllEntryPlugin", | 
					
						
							|  |  |  | 			(compilation, { normalModuleFactory }) => { | 
					
						
							|  |  |  | 				const dllModuleFactory = new DllModuleFactory(); | 
					
						
							|  |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					DllEntryDependency, | 
					
						
							|  |  |  | 					dllModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				compilation.dependencyFactories.set( | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 					EntryDependency, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:01:25 +08:00
										 |  |  | 		compiler.hooks.make.tapAsync("DllEntryPlugin", (compilation, callback) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			compilation.addEntry( | 
					
						
							|  |  |  | 				this.context, | 
					
						
							|  |  |  | 				new DllEntryDependency( | 
					
						
							|  |  |  | 					this.entries.map((e, idx) => { | 
					
						
							| 
									
										
										
										
											2018-08-14 22:40:37 +08:00
										 |  |  | 						const dep = new EntryDependency(e); | 
					
						
							| 
									
										
										
										
											2018-06-25 16:43:59 +08:00
										 |  |  | 						dep.loc = { | 
					
						
							|  |  |  | 							name: this.name, | 
					
						
							|  |  |  | 							index: idx | 
					
						
							|  |  |  | 						}; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						return dep; | 
					
						
							|  |  |  | 					}), | 
					
						
							|  |  |  | 					this.name | 
					
						
							|  |  |  | 				), | 
					
						
							|  |  |  | 				this.name, | 
					
						
							|  |  |  | 				callback | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2016-12-29 16:33:01 +08:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = DllEntryPlugin; |