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,18 @@ if (isMainThread) {
116115
117116const {
118117 emitWarning
119- } = NativeModule . require ( 'internal/process/warning' ) ;
118+ } = require ( 'internal/process/warning' ) ;
120119
121120process . emitWarning = emitWarning ;
122121
122+ const {
123+ setupTaskQueue,
124+ queueMicrotask
125+ } = require ( 'internal/process/task_queues' ) ;
123126const {
124127 nextTick,
125128 runNextTicks
126- } = NativeModule . require ( 'internal/process/task_queues' ) . setupTaskQueue ( ) ;
129+ } = setupTaskQueue ( ) ;
127130
128131process . nextTick = nextTick ;
129132// Used to emulate a tick manually in the JS land.
@@ -161,7 +164,7 @@ if (credentials.implementsPosixCredentials) {
161164
162165if ( isMainThread ) {
163166 const { getStdout, getStdin, getStderr } =
164- NativeModule . require ( 'internal/process/stdio' ) . getMainThreadStdio ( ) ;
167+ require ( 'internal/process/stdio' ) . getMainThreadStdio ( ) ;
165168 setupProcessStdio ( getStdout , getStdin , getStderr ) ;
166169} else {
167170 const { getStdout, getStdin, getStderr } =
@@ -173,7 +176,7 @@ if (config.hasInspector) {
173176 const {
174177 enable,
175178 disable
176- } = NativeModule . require ( 'internal/inspector_async_hook' ) ;
179+ } = require ( 'internal/inspector_async_hook' ) ;
177180 internalBinding ( 'inspector' ) . registerAsyncHook ( enable , disable ) ;
178181}
179182
@@ -183,30 +186,27 @@ if (!config.noBrowserGlobals) {
183186 // https://console.spec.whatwg.org/#console-namespace
184187 exposeNamespace ( global , 'console' , createGlobalConsole ( global . console ) ) ;
185188
186- const { URL , URLSearchParams } = NativeModule . require ( 'internal/url' ) ;
189+ const { URL , URLSearchParams } = require ( 'internal/url' ) ;
187190 // https://url.spec.whatwg.org/#url
188191 exposeInterface ( global , 'URL' , URL ) ;
189192 // https://url.spec.whatwg.org/#urlsearchparams
190193 exposeInterface ( global , 'URLSearchParams' , URLSearchParams ) ;
191194
192195 const {
193196 TextEncoder, TextDecoder
194- } = NativeModule . require ( 'internal/encoding' ) ;
197+ } = require ( 'internal/encoding' ) ;
195198 // https://encoding.spec.whatwg.org/#textencoder
196199 exposeInterface ( global , 'TextEncoder' , TextEncoder ) ;
197200 // https://encoding.spec.whatwg.org/#textdecoder
198201 exposeInterface ( global , 'TextDecoder' , TextDecoder ) ;
199202
200203 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
201- const timers = NativeModule . require ( 'timers' ) ;
204+ const timers = require ( 'timers' ) ;
202205 defineOperation ( global , 'clearInterval' , timers . clearInterval ) ;
203206 defineOperation ( global , 'clearTimeout' , timers . clearTimeout ) ;
204207 defineOperation ( global , 'setInterval' , timers . setInterval ) ;
205208 defineOperation ( global , 'setTimeout' , timers . setTimeout ) ;
206209
207- const {
208- queueMicrotask
209- } = NativeModule . require ( 'internal/process/task_queues' ) ;
210210 defineOperation ( global , 'queueMicrotask' , queueMicrotask ) ;
211211
212212 // Non-standard extensions:
@@ -265,7 +265,7 @@ Object.defineProperty(process, 'features', {
265265 fatalException,
266266 setUncaughtExceptionCaptureCallback,
267267 hasUncaughtExceptionCaptureCallback
268- } = NativeModule . require ( 'internal/process/execution' ) ;
268+ } = require ( 'internal/process/execution' ) ;
269269
270270 process . _fatalException = fatalException ;
271271 process . setUncaughtExceptionCaptureCallback =
@@ -275,7 +275,7 @@ Object.defineProperty(process, 'features', {
275275}
276276
277277function setupProcessObject ( ) {
278- const EventEmitter = NativeModule . require ( 'events' ) ;
278+ const EventEmitter = require ( 'events' ) ;
279279 const origProcProto = Object . getPrototypeOf ( process ) ;
280280 Object . setPrototypeOf ( origProcProto , EventEmitter . prototype ) ;
281281 EventEmitter . call ( process ) ;
@@ -359,7 +359,7 @@ function setupGlobalProxy() {
359359}
360360
361361function setupBuffer ( ) {
362- const { Buffer } = NativeModule . require ( 'buffer' ) ;
362+ const { Buffer } = require ( 'buffer' ) ;
363363 const bufferBinding = internalBinding ( 'buffer' ) ;
364364
365365 // Only after this point can C++ use Buffer::New()
@@ -377,9 +377,9 @@ function setupBuffer() {
377377
378378function createGlobalConsole ( consoleFromVM ) {
379379 const consoleFromNode =
380- NativeModule . require ( 'internal/console/global' ) ;
380+ require ( 'internal/console/global' ) ;
381381 if ( config . hasInspector ) {
382- const inspector = NativeModule . require ( 'internal/util/inspector' ) ;
382+ const inspector = require ( 'internal/util/inspector' ) ;
383383 // This will be exposed by `require('inspector').console` later.
384384 inspector . consoleFromVM = consoleFromVM ;
385385 // TODO(joyeecheung): postpone this until the first time inspector
0 commit comments