2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								From: Cheng Zhao <zcbenz@gmail.com>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Date: Sun, 27 Mar 2016 14:42:26 +0900
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Subject: Pass all globals through "require"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								(cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-18 22:23:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								index 31649227ed8eb36f58ec0b88d498b9e45009f76b..61605a052f976dc7fad224c3c81c2187f3862cdb 100644
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								--- a/lib/internal/modules/cjs/loader.js
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+++ b/lib/internal/modules/cjs/loader.js
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-20 09:22:08 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -142,6 +142,13 @@ const {
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-11 11:33:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   CHAR_FORWARD_SLASH,
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 } = require('internal/constants');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// Store the "global" variable from global scope into a local scope, so we can
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// still reference it from this file even after we deleted the "global" variable
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// from the global scope.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+const localGlobal = global;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// Do the same for "Buffer".
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+const localBuffer = Buffer;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-17 16:08:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 const {
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-18 22:23:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   isProxy,
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-17 16:08:57 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 } = require('internal/util/types');
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-20 09:22:08 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1249,10 +1256,12 @@ Module.prototype._compile = function(content, filename) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-17 08:50:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   if (requireDepth === 0) statCache = new SafeMap();
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   if (inspectorWrapper) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     result = inspectorWrapper(compiledWrapper, thisValue, exports,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                              require, module, filename, dirname);
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-24 13:02:04 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                              require, module, filename, dirname,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                              process, localGlobal, localBuffer);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-17 08:50:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     result = ReflectApply(compiledWrapper, thisValue,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                          [exports, require, module, filename, dirname]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                          [exports, require, module, filename,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                           dirname, process, localGlobal, localBuffer]);
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   }
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-24 13:02:04 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   hasLoadedAnyUserCJSModule = true;
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-16 10:23:04 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   if (requireDepth === 0) statCache = null;
							 |