@@ -56,6 +56,9 @@ function getTranslators() {
56
56
}
57
57
const { getOptionValue } = require ( 'internal/options' ) ;
58
58
59
+ const dc = require ( 'diagnostics_channel' ) ;
60
+ const onLoad = dc . tracingChannel ( 'module.import' ) ;
61
+
59
62
/**
60
63
* @typedef {object } ExportedHooks
61
64
* @property {Function } globalPreload Global preload hook.
@@ -374,14 +377,18 @@ class ESMLoader {
374
377
return module ;
375
378
} ;
376
379
const ModuleJob = require ( 'internal/modules/esm/module_job' ) ;
377
- const job = new ModuleJob (
378
- this , url , undefined , evalInstance , false , false ) ;
379
- this . moduleMap . set ( url , undefined , job ) ;
380
- const { module } = await job . run ( ) ;
380
+ const namespace = await onLoad . tracePromise ( async ( ) => {
381
+ const job = new ModuleJob (
382
+ this , url , undefined , evalInstance , false , false ) ;
383
+ this . moduleMap . set ( url , undefined , job ) ;
384
+
385
+ const { module } = await job . run ( ) ;
386
+ return module . getNamespace ( ) ;
387
+ } , { parentURL : '<eval>' , url } ) ;
381
388
382
389
return {
383
390
__proto__ : null ,
384
- namespace : module . getNamespace ( ) ,
391
+ namespace,
385
392
} ;
386
393
}
387
394
@@ -513,9 +520,14 @@ class ESMLoader {
513
520
const jobs = new Array ( count ) ;
514
521
515
522
for ( let i = 0 ; i < count ; i ++ ) {
516
- jobs [ i ] = this . getModuleJob ( specifiers [ i ] , parentURL , importAssertions )
517
- . then ( ( job ) => job . run ( ) )
518
- . then ( ( { module } ) => module . getNamespace ( ) ) ;
523
+ jobs [ i ] = onLoad . tracePromise ( async ( ) => {
524
+ const job = await this . getModuleJob ( specifiers [ i ] , parentURL , importAssertions ) ;
525
+ const { module } = await job . run ( ) ;
526
+ return module . getNamespace ( ) ;
527
+ } , {
528
+ parentURL,
529
+ url : specifiers [ i ]
530
+ } ) ;
519
531
}
520
532
521
533
const namespaces = await SafePromiseAllReturnArrayLike ( jobs ) ;
0 commit comments