3333
3434// This file is compiled as if it's wrapped in a function with arguments
3535// passed by node::RunBootstrapping()
36- /* global process, loaderExports , isMainThread, ownsProcessState */
36+ /* global process, require, internalBinding , isMainThread, ownsProcessState */
3737/* global primordials */
3838
39- const { internalBinding, NativeModule } = loaderExports ;
4039const { Object, Symbol } = primordials ;
4140const config = internalBinding ( 'config' ) ;
42- const { deprecate } = NativeModule . require ( 'internal/util' ) ;
41+ const { deprecate } = require ( 'internal/util' ) ;
4342
4443setupProcessObject ( ) ;
4544
@@ -50,17 +49,17 @@ process.domain = null;
5049process . _exiting = false ;
5150
5251// Bootstrappers for all threads, including worker threads and main thread
53- const perThreadSetup = NativeModule . require ( 'internal/process/per_thread' ) ;
52+ const perThreadSetup = require ( 'internal/process/per_thread' ) ;
5453// Bootstrappers for the main thread only
5554let mainThreadSetup ;
5655// Bootstrappers for the worker threads only
5756let workerThreadSetup ;
5857if ( ownsProcessState ) {
59- mainThreadSetup = NativeModule . require (
58+ mainThreadSetup = require (
6059 'internal/process/main_thread_only'
6160 ) ;
6261} else {
63- workerThreadSetup = NativeModule . require (
62+ workerThreadSetup = require (
6463 'internal/process/worker_thread_only'
6564 ) ;
6665}
@@ -116,14 +115,14 @@ if (isMainThread) {
116115
117116const {
118117 emitWarning
119- } = NativeModule . require ( 'internal/process/warning' ) ;
118+ } = require ( 'internal/process/warning' ) ;
120119
121120process . emitWarning = emitWarning ;
122121
123122const {
124123 nextTick,
125124 runNextTicks
126- } = NativeModule . require ( 'internal/process/next_tick' ) . setup ( ) ;
125+ } = require ( 'internal/process/next_tick' ) . setup ( ) ;
127126
128127process . nextTick = nextTick ;
129128// Used to emulate a tick manually in the JS land.
@@ -161,7 +160,7 @@ if (credentials.implementsPosixCredentials) {
161160
162161if ( isMainThread ) {
163162 const { getStdout, getStdin, getStderr } =
164- NativeModule . require ( 'internal/process/stdio' ) . getMainThreadStdio ( ) ;
163+ require ( 'internal/process/stdio' ) . getMainThreadStdio ( ) ;
165164 setupProcessStdio ( getStdout , getStdin , getStderr ) ;
166165} else {
167166 const { getStdout, getStdin, getStderr } =
@@ -173,7 +172,7 @@ if (isMainThread) {
173172// process. They use the same functions as the JS embedder API. These callbacks
174173// are setup immediately to prevent async_wrap.setupHooks() from being hijacked
175174// and the cost of doing so is negligible.
176- const { nativeHooks } = NativeModule . require ( 'internal/async_hooks' ) ;
175+ const { nativeHooks } = require ( 'internal/async_hooks' ) ;
177176internalBinding ( 'async_wrap' ) . setupHooks ( nativeHooks ) ;
178177
179178// XXX(joyeecheung): this has to be done after the initial load of
@@ -183,7 +182,7 @@ if (config.hasInspector) {
183182 const {
184183 enable,
185184 disable
186- } = NativeModule . require ( 'internal/inspector_async_hook' ) ;
185+ } = require ( 'internal/inspector_async_hook' ) ;
187186 internalBinding ( 'inspector' ) . registerAsyncHook ( enable , disable ) ;
188187}
189188
@@ -193,22 +192,22 @@ if (!config.noBrowserGlobals) {
193192 // https://console.spec.whatwg.org/#console-namespace
194193 exposeNamespace ( global , 'console' , createGlobalConsole ( global . console ) ) ;
195194
196- const { URL , URLSearchParams } = NativeModule . require ( 'internal/url' ) ;
195+ const { URL , URLSearchParams } = require ( 'internal/url' ) ;
197196 // https://url.spec.whatwg.org/#url
198197 exposeInterface ( global , 'URL' , URL ) ;
199198 // https://url.spec.whatwg.org/#urlsearchparams
200199 exposeInterface ( global , 'URLSearchParams' , URLSearchParams ) ;
201200
202201 const {
203202 TextEncoder, TextDecoder
204- } = NativeModule . require ( 'internal/encoding' ) ;
203+ } = require ( 'internal/encoding' ) ;
205204 // https://encoding.spec.whatwg.org/#textencoder
206205 exposeInterface ( global , 'TextEncoder' , TextEncoder ) ;
207206 // https://encoding.spec.whatwg.org/#textdecoder
208207 exposeInterface ( global , 'TextDecoder' , TextDecoder ) ;
209208
210209 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
211- const timers = NativeModule . require ( 'timers' ) ;
210+ const timers = require ( 'timers' ) ;
212211 defineOperation ( global , 'clearInterval' , timers . clearInterval ) ;
213212 defineOperation ( global , 'clearTimeout' , timers . clearTimeout ) ;
214213 defineOperation ( global , 'setInterval' , timers . setInterval ) ;
@@ -302,7 +301,7 @@ Object.defineProperty(process, 'features', {
302301 fatalException,
303302 setUncaughtExceptionCaptureCallback,
304303 hasUncaughtExceptionCaptureCallback
305- } = NativeModule . require ( 'internal/process/execution' ) ;
304+ } = require ( 'internal/process/execution' ) ;
306305
307306 process . _fatalException = fatalException ;
308307 process . setUncaughtExceptionCaptureCallback =
@@ -312,7 +311,7 @@ Object.defineProperty(process, 'features', {
312311}
313312
314313function setupProcessObject ( ) {
315- const EventEmitter = NativeModule . require ( 'events' ) ;
314+ const EventEmitter = require ( 'events' ) ;
316315 const origProcProto = Object . getPrototypeOf ( process ) ;
317316 Object . setPrototypeOf ( origProcProto , EventEmitter . prototype ) ;
318317 EventEmitter . call ( process ) ;
@@ -391,7 +390,7 @@ function setupGlobalProxy() {
391390}
392391
393392function setupBuffer ( ) {
394- const { Buffer } = NativeModule . require ( 'buffer' ) ;
393+ const { Buffer } = require ( 'buffer' ) ;
395394 const bufferBinding = internalBinding ( 'buffer' ) ;
396395
397396 // Only after this point can C++ use Buffer::New()
@@ -404,9 +403,9 @@ function setupBuffer() {
404403
405404function createGlobalConsole ( consoleFromVM ) {
406405 const consoleFromNode =
407- NativeModule . require ( 'internal/console/global' ) ;
406+ require ( 'internal/console/global' ) ;
408407 if ( config . hasInspector ) {
409- const inspector = NativeModule . require ( 'internal/util/inspector' ) ;
408+ const inspector = require ( 'internal/util/inspector' ) ;
410409 // This will be exposed by `require('inspector').console` later.
411410 inspector . consoleFromVM = consoleFromVM ;
412411 // TODO(joyeecheung): postpone this until the first time inspector
@@ -424,8 +423,7 @@ function setupQueueMicrotask() {
424423 get ( ) {
425424 process . emitWarning ( 'queueMicrotask() is experimental.' ,
426425 'ExperimentalWarning' ) ;
427- const { queueMicrotask } =
428- NativeModule . require ( 'internal/queue_microtask' ) ;
426+ const { queueMicrotask } = require ( 'internal/queue_microtask' ) ;
429427
430428 Object . defineProperty ( global , 'queueMicrotask' , {
431429 value : queueMicrotask ,
0 commit comments