2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/*
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									MIT License http://www.opensource.org/licenses/mit-license.php
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Author Tobias Koppers @sokra
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								*/
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"use strict";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									JAVASCRIPT_MODULE_TYPE_AUTO,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									JAVASCRIPT_MODULE_TYPE_DYNAMIC,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									JAVASCRIPT_MODULE_TYPE_ESM
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								} = require("./ModuleTypeConstants");
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const ConstDependency = require("./dependencies/ConstDependency");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const ExportsInfoDependency = require("./dependencies/ExportsInfoDependency");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/** @typedef {import("./Compiler")} Compiler */
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-11 21:46:57 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const PLUGIN_NAME = "ExportsInfoApiPlugin";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class ExportsInfoApiPlugin {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									/**
							 | 
						
					
						
							
								
									
										
										
										
											2020-04-23 16:48:36 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									 * Apply the plugin
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									 * @param {Compiler} compiler the compiler instance
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									 * @returns {void}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									apply(compiler) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										compiler.hooks.compilation.tap(
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											PLUGIN_NAME,
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											(compilation, { normalModuleFactory }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												compilation.dependencyTemplates.set(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													ExportsInfoDependency,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													new ExportsInfoDependency.Template()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												 * @param {JavascriptParser} parser the parser
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												 * @returns {void}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												const handler = parser => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													parser.hooks.expressionMemberChain
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
														.for("__webpack_exports_info__")
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
														.tap(PLUGIN_NAME, (expr, members) => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
															const dep =
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																members.length >= 2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																	? new ExportsInfoDependency(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																			expr.range,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																			members.slice(0, -1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																			members[members.length - 1]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																	  )
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-03 20:10:55 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
																	: new ExportsInfoDependency(expr.range, null, members[0]);
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
															dep.loc = expr.loc;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															parser.state.module.addDependency(dep);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
														});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													parser.hooks.expression
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
														.for("__webpack_exports_info__")
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
														.tap(PLUGIN_NAME, expr => {
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
															const dep = new ConstDependency("true", expr.range);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															dep.loc = expr.loc;
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-30 13:40:40 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
															parser.state.module.addPresentationalDependency(dep);
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
															return true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
														});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												normalModuleFactory.hooks.parser
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													.for(JAVASCRIPT_MODULE_TYPE_AUTO)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													.tap(PLUGIN_NAME, handler);
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
												normalModuleFactory.hooks.parser
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													.tap(PLUGIN_NAME, handler);
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
												normalModuleFactory.hooks.parser
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-01 01:56:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													.for(JAVASCRIPT_MODULE_TYPE_ESM)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													.tap(PLUGIN_NAME, handler);
							 | 
						
					
						
							
								
									
										
										
										
											2019-08-22 22:59:37 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								module.exports = ExportsInfoApiPlugin;
							 |