| 
									
										
										
										
											2013-10-28 23:21:29 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-12 02:09:49 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2013-10-28 23:21:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | const NormalModule = require("../NormalModule"); | 
					
						
							| 
									
										
										
										
											2020-08-23 03:54:34 +08:00
										 |  |  | const LazySet = require("../util/LazySet"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const LoaderDependency = require("./LoaderDependency"); | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | const LoaderImportDependency = require("./LoaderImportDependency"); | 
					
						
							| 
									
										
										
										
											2013-10-28 23:21:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | /** @typedef {import("../../declarations/LoaderContext").LoaderPluginLoaderContext} LoaderPluginLoaderContext */ | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | /** @typedef {import("../Compilation").DepConstructor} DepConstructor */ | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | /** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */ | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | /** @typedef {import("../Compiler")} Compiler */ | 
					
						
							| 
									
										
										
										
											2018-07-10 23:18:45 +08:00
										 |  |  | /** @typedef {import("../Module")} Module */ | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | /** @typedef {import("../Module").BuildInfo} BuildInfo */ | 
					
						
							| 
									
										
										
										
											2018-07-10 23:18:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @callback ImportModuleCallback | 
					
						
							| 
									
										
										
										
											2021-12-24 20:27:31 +08:00
										 |  |  |  * @param {(Error | null)=} err error object | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  |  * @param {any=} exports exports of the evaluated module | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2024-06-11 21:09:50 +08:00
										 |  |  |  * @typedef {object} ImportModuleOptions | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  |  * @property {string=} layer the target layer | 
					
						
							| 
									
										
										
										
											2021-04-15 01:48:22 +08:00
										 |  |  |  * @property {string=} publicPath the target public path | 
					
						
							| 
									
										
										
										
											2022-02-21 21:23:47 +08:00
										 |  |  |  * @property {string=} baseUri target base uri | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-12 02:09:49 +08:00
										 |  |  | class LoaderPlugin { | 
					
						
							| 
									
										
										
										
											2021-04-12 15:17:43 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2024-06-11 21:09:50 +08:00
										 |  |  | 	 * @param {object} options options | 
					
						
							| 
									
										
										
										
											2021-04-12 15:17:43 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 	constructor(options = {}) {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Apply the plugin | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler instance | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-12 02:09:49 +08:00
										 |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap( | 
					
						
							|  |  |  | 			"LoaderPlugin", | 
					
						
							|  |  |  | 			(compilation, { normalModuleFactory }) => { | 
					
						
							|  |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					LoaderDependency, | 
					
						
							|  |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 				compilation.dependencyFactories.set( | 
					
						
							|  |  |  | 					LoaderImportDependency, | 
					
						
							|  |  |  | 					normalModuleFactory | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:01:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		compiler.hooks.compilation.tap("LoaderPlugin", compilation => { | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 			const moduleGraph = compilation.moduleGraph; | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | 			NormalModule.getCompilationHooks(compilation).loader.tap( | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				"LoaderPlugin", | 
					
						
							| 
									
										
										
										
											2018-11-12 21:13:55 +08:00
										 |  |  | 				loaderContext => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					loaderContext.loadModule = (request, callback) => { | 
					
						
							|  |  |  | 						const dep = new LoaderDependency(request); | 
					
						
							| 
									
										
										
										
											2018-07-10 23:18:45 +08:00
										 |  |  | 						dep.loc = { | 
					
						
							|  |  |  | 							name: request | 
					
						
							|  |  |  | 						}; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						const factory = compilation.dependencyFactories.get( | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 							/** @type {DepConstructor} */ (dep.constructor) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 						if (factory === undefined) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							return callback( | 
					
						
							|  |  |  | 								new Error( | 
					
						
							| 
									
										
										
										
											2019-06-09 17:23:42 +08:00
										 |  |  | 									`No module factory available for dependency type: ${dep.constructor.name}` | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								) | 
					
						
							|  |  |  | 							); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2024-09-27 02:38:33 +08:00
										 |  |  | 						const oldFactorizeQueueContext = | 
					
						
							|  |  |  | 							compilation.factorizeQueue.getContext(); | 
					
						
							|  |  |  | 						compilation.factorizeQueue.setContext("load-module"); | 
					
						
							|  |  |  | 						const oldAddModuleQueueContext = | 
					
						
							|  |  |  | 							compilation.addModuleQueue.getContext(); | 
					
						
							|  |  |  | 						compilation.addModuleQueue.setContext("load-module"); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 						compilation.buildQueue.increaseParallelism(); | 
					
						
							|  |  |  | 						compilation.handleModuleCreation( | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								factory, | 
					
						
							|  |  |  | 								dependencies: [dep], | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 								originModule: | 
					
						
							|  |  |  | 									/** @type {NormalModule} */ | 
					
						
							|  |  |  | 									(loaderContext._module), | 
					
						
							| 
									
										
										
										
											2019-12-20 19:45:55 +08:00
										 |  |  | 								context: loaderContext.context, | 
					
						
							|  |  |  | 								recursive: false | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 							}, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							err => { | 
					
						
							| 
									
										
										
										
											2024-09-27 02:38:33 +08:00
										 |  |  | 								compilation.factorizeQueue.setContext(oldFactorizeQueueContext); | 
					
						
							|  |  |  | 								compilation.addModuleQueue.setContext(oldAddModuleQueueContext); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 								compilation.buildQueue.decreaseParallelism(); | 
					
						
							|  |  |  | 								if (err) { | 
					
						
							|  |  |  | 									return callback(err); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								const referencedModule = moduleGraph.getModule(dep); | 
					
						
							|  |  |  | 								if (!referencedModule) { | 
					
						
							|  |  |  | 									return callback(new Error("Cannot load the module")); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2021-02-06 08:04:42 +08:00
										 |  |  | 								if (referencedModule.getNumberOfErrors() > 0) { | 
					
						
							|  |  |  | 									return callback( | 
					
						
							|  |  |  | 										new Error("The loaded module contains errors") | 
					
						
							|  |  |  | 									); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 								const moduleSource = referencedModule.originalSource(); | 
					
						
							|  |  |  | 								if (!moduleSource) { | 
					
						
							| 
									
										
										
										
											2021-02-06 08:04:42 +08:00
										 |  |  | 									return callback( | 
					
						
							|  |  |  | 										new Error( | 
					
						
							|  |  |  | 											"The module created for a LoaderDependency must have an original source" | 
					
						
							|  |  |  | 										) | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 									); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2024-07-31 09:56:53 +08:00
										 |  |  | 								let map; | 
					
						
							|  |  |  | 								let source; | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 								if (moduleSource.sourceAndMap) { | 
					
						
							|  |  |  | 									const sourceAndMap = moduleSource.sourceAndMap(); | 
					
						
							|  |  |  | 									map = sourceAndMap.map; | 
					
						
							|  |  |  | 									source = sourceAndMap.source; | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									map = moduleSource.map(); | 
					
						
							|  |  |  | 									source = moduleSource.source(); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2020-08-23 03:54:34 +08:00
										 |  |  | 								const fileDependencies = new LazySet(); | 
					
						
							|  |  |  | 								const contextDependencies = new LazySet(); | 
					
						
							|  |  |  | 								const missingDependencies = new LazySet(); | 
					
						
							|  |  |  | 								const buildDependencies = new LazySet(); | 
					
						
							|  |  |  | 								referencedModule.addCacheDependencies( | 
					
						
							|  |  |  | 									fileDependencies, | 
					
						
							|  |  |  | 									contextDependencies, | 
					
						
							|  |  |  | 									missingDependencies, | 
					
						
							|  |  |  | 									buildDependencies | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								for (const d of fileDependencies) { | 
					
						
							|  |  |  | 									loaderContext.addDependency(d); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								for (const d of contextDependencies) { | 
					
						
							|  |  |  | 									loaderContext.addContextDependency(d); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								for (const d of missingDependencies) { | 
					
						
							|  |  |  | 									loaderContext.addMissingDependency(d); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 								} | 
					
						
							| 
									
										
										
										
											2020-08-23 03:54:34 +08:00
										 |  |  | 								for (const d of buildDependencies) { | 
					
						
							|  |  |  | 									loaderContext.addBuildDependency(d); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 								} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 								return callback( | 
					
						
							|  |  |  | 									null, | 
					
						
							|  |  |  | 									source, | 
					
						
							|  |  |  | 									/** @type {object | null} */ (map), | 
					
						
							|  |  |  | 									referencedModule | 
					
						
							|  |  |  | 								); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						); | 
					
						
							|  |  |  | 					}; | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 					/** | 
					
						
							|  |  |  | 					 * @param {string} request the request string to load the module from | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 					 * @param {ImportModuleOptions} options options | 
					
						
							|  |  |  | 					 * @param {ImportModuleCallback} callback callback returning the exports | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 					 * @returns {void} | 
					
						
							|  |  |  | 					 */ | 
					
						
							|  |  |  | 					const importModule = (request, options, callback) => { | 
					
						
							|  |  |  | 						const dep = new LoaderImportDependency(request); | 
					
						
							|  |  |  | 						dep.loc = { | 
					
						
							|  |  |  | 							name: request | 
					
						
							|  |  |  | 						}; | 
					
						
							|  |  |  | 						const factory = compilation.dependencyFactories.get( | 
					
						
							|  |  |  | 							/** @type {DepConstructor} */ (dep.constructor) | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 						if (factory === undefined) { | 
					
						
							|  |  |  | 							return callback( | 
					
						
							|  |  |  | 								new Error( | 
					
						
							|  |  |  | 									`No module factory available for dependency type: ${dep.constructor.name}` | 
					
						
							|  |  |  | 								) | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 							); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2024-09-27 00:31:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						const oldFactorizeQueueContext = | 
					
						
							|  |  |  | 							compilation.factorizeQueue.getContext(); | 
					
						
							|  |  |  | 						compilation.factorizeQueue.setContext("import-module"); | 
					
						
							|  |  |  | 						const oldAddModuleQueueContext = | 
					
						
							|  |  |  | 							compilation.addModuleQueue.getContext(); | 
					
						
							|  |  |  | 						compilation.addModuleQueue.setContext("import-module"); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 						compilation.buildQueue.increaseParallelism(); | 
					
						
							|  |  |  | 						compilation.handleModuleCreation( | 
					
						
							|  |  |  | 							{ | 
					
						
							|  |  |  | 								factory, | 
					
						
							|  |  |  | 								dependencies: [dep], | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 								originModule: | 
					
						
							|  |  |  | 									/** @type {NormalModule} */ | 
					
						
							|  |  |  | 									(loaderContext._module), | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 								contextInfo: { | 
					
						
							|  |  |  | 									issuerLayer: options.layer | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 								}, | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 								context: loaderContext.context, | 
					
						
							| 
									
										
										
										
											2024-01-23 17:32:02 +08:00
										 |  |  | 								connectOrigin: false, | 
					
						
							|  |  |  | 								checkCycle: true | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 							}, | 
					
						
							|  |  |  | 							err => { | 
					
						
							| 
									
										
										
										
											2024-09-27 00:31:30 +08:00
										 |  |  | 								compilation.factorizeQueue.setContext(oldFactorizeQueueContext); | 
					
						
							|  |  |  | 								compilation.addModuleQueue.setContext(oldAddModuleQueueContext); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 								compilation.buildQueue.decreaseParallelism(); | 
					
						
							|  |  |  | 								if (err) { | 
					
						
							|  |  |  | 									return callback(err); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								const referencedModule = moduleGraph.getModule(dep); | 
					
						
							|  |  |  | 								if (!referencedModule) { | 
					
						
							|  |  |  | 									return callback(new Error("Cannot load the module")); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2024-09-26 01:34:39 +08:00
										 |  |  | 								compilation.buildQueue.increaseParallelism(); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 								compilation.executeModule( | 
					
						
							|  |  |  | 									referencedModule, | 
					
						
							|  |  |  | 									{ | 
					
						
							|  |  |  | 										entryOptions: { | 
					
						
							| 
									
										
										
										
											2022-02-21 21:23:47 +08:00
										 |  |  | 											baseUri: options.baseUri, | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 											publicPath: options.publicPath | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 									}, | 
					
						
							|  |  |  | 									(err, result) => { | 
					
						
							| 
									
										
										
										
											2024-09-26 01:34:39 +08:00
										 |  |  | 										compilation.buildQueue.decreaseParallelism(); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 										if (err) return callback(err); | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 										const { | 
					
						
							|  |  |  | 											fileDependencies, | 
					
						
							|  |  |  | 											contextDependencies, | 
					
						
							|  |  |  | 											missingDependencies, | 
					
						
							|  |  |  | 											buildDependencies, | 
					
						
							|  |  |  | 											cacheable, | 
					
						
							|  |  |  | 											assets, | 
					
						
							|  |  |  | 											exports | 
					
						
							|  |  |  | 										} = /** @type {ExecuteModuleResult} */ (result); | 
					
						
							|  |  |  | 										for (const d of fileDependencies) { | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 											loaderContext.addDependency(d); | 
					
						
							|  |  |  | 										} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 										for (const d of contextDependencies) { | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 											loaderContext.addContextDependency(d); | 
					
						
							|  |  |  | 										} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 										for (const d of missingDependencies) { | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 											loaderContext.addMissingDependency(d); | 
					
						
							|  |  |  | 										} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 										for (const d of buildDependencies) { | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 											loaderContext.addBuildDependency(d); | 
					
						
							|  |  |  | 										} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 										if (cacheable === false) loaderContext.cacheable(false); | 
					
						
							|  |  |  | 										for (const [name, { source, info }] of assets) { | 
					
						
							|  |  |  | 											const buildInfo = | 
					
						
							|  |  |  | 												/** @type {BuildInfo} */ | 
					
						
							|  |  |  | 												( | 
					
						
							|  |  |  | 													/** @type {NormalModule} */ (loaderContext._module) | 
					
						
							|  |  |  | 														.buildInfo | 
					
						
							|  |  |  | 												); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 											if (!buildInfo.assets) { | 
					
						
							|  |  |  | 												buildInfo.assets = Object.create(null); | 
					
						
							|  |  |  | 												buildInfo.assetsInfo = new Map(); | 
					
						
							| 
									
										
										
										
											2021-04-12 15:17:43 +08:00
										 |  |  | 											} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 											/** @type {NonNullable<BuildInfo["assets"]>} */ | 
					
						
							|  |  |  | 											(buildInfo.assets)[name] = source; | 
					
						
							|  |  |  | 											/** @type {NonNullable<BuildInfo["assetsInfo"]>} */ | 
					
						
							|  |  |  | 											(buildInfo.assetsInfo).set(name, info); | 
					
						
							| 
									
										
										
										
											2021-04-10 02:45:59 +08:00
										 |  |  | 										} | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 										callback(null, exports); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 									} | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 					}; | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-06 11:08:48 +08:00
										 |  |  | 					// eslint-disable-next-line no-warning-comments
 | 
					
						
							|  |  |  | 					// @ts-ignore Overloading doesn't work
 | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 					loaderContext.importModule = (request, options, callback) => { | 
					
						
							|  |  |  | 						if (!callback) { | 
					
						
							|  |  |  | 							return new Promise((resolve, reject) => { | 
					
						
							|  |  |  | 								importModule(request, options || {}, (err, result) => { | 
					
						
							|  |  |  | 									if (err) reject(err); | 
					
						
							|  |  |  | 									else resolve(result); | 
					
						
							| 
									
										
										
										
											2021-04-09 21:50:25 +08:00
										 |  |  | 								}); | 
					
						
							| 
									
										
										
										
											2021-09-02 22:18:41 +08:00
										 |  |  | 							}); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						return importModule(request, options || {}, callback); | 
					
						
							|  |  |  | 					}; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2013-10-28 23:21:29 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2017-01-12 02:09:49 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = LoaderPlugin; |