@@ -27,6 +27,10 @@ const {
2727} = require ( 'internal/source_map/source_map_cache' ) ;
2828const assert = require ( 'internal/assert' ) ;
2929const resolvedPromise = PromiseResolve ( ) ;
30+ let debug = require ( 'internal/util/debuglog' ) . debuglog ( 'esm' , ( fn ) => {
31+ debug = fn ;
32+ } ) ;
33+ const { writeFileSync } = require ( 'fs' ) ;
3034
3135const noop = FunctionPrototype ;
3236
@@ -87,8 +91,7 @@ class ModuleJob {
8791 return job . modulePromise ;
8892 } ) ;
8993
90- if ( promises !== undefined )
91- await SafePromiseAllReturnVoid ( promises ) ;
94+ if ( promises !== undefined ) await SafePromiseAllReturnVoid ( promises ) ;
9295
9396 return SafePromiseAllReturnArrayLike ( dependencyJobs ) ;
9497 } ;
@@ -111,17 +114,21 @@ class ModuleJob {
111114 }
112115
113116 async _instantiate ( ) {
117+ writeFileSync ( 1 , 'ModuleJob::instantiate()\n' ) ;
114118 const jobsInGraph = new SafeSet ( ) ;
115119 const addJobsToDependencyGraph = async ( moduleJob ) => {
116120 if ( jobsInGraph . has ( moduleJob ) ) {
117121 return ;
118122 }
119123 jobsInGraph . add ( moduleJob ) ;
124+ writeFileSync ( 1 , 'ModuleJob::instantiate() getting linked jobs\n' ) ;
120125 const dependencyJobs = await moduleJob . linked ;
126+ writeFileSync ( 1 , 'ModuleJob::instantiate() got linked jobs\n' ) ;
121127 return SafePromiseAllReturnVoid ( dependencyJobs , addJobsToDependencyGraph ) ;
122128 } ;
123129 await addJobsToDependencyGraph ( this ) ;
124130
131+ writeFileSync ( 1 , 'ModuleJob::instantiate() job added to dep graph\n' ) ;
125132 try {
126133 if ( ! hasPausedEntry && this . inspectBrk ) {
127134 hasPausedEntry = true ;
@@ -131,6 +138,7 @@ class ModuleJob {
131138 this . module . instantiate ( ) ;
132139 }
133140 } catch ( e ) {
141+ writeFileSync ( 1 , `ModuleJob::instantiate() error: ${ e . stack } \n` ) ;
134142 decorateErrorStack ( e ) ;
135143 // TODO(@bcoe): Add source map support to exception that occurs as result
136144 // of missing named export. This is currently not possible because
@@ -210,12 +218,16 @@ class ModuleJob {
210218 }
211219
212220 async run ( ) {
221+ writeFileSync ( 1 , `ModuleJob::run() instantiating: ${ this . url } \n` ) ;
213222 await this . instantiate ( ) ;
223+ writeFileSync ( 1 , `ModuleJob::run() instantiated: ${ this . url } \n` ) ;
214224 const timeout = - 1 ;
215225 const breakOnSigint = false ;
216226 try {
217227 await this . module . evaluate ( timeout , breakOnSigint ) ;
228+ writeFileSync ( 1 , `ModuleJob::run() evaluation complete: ${ this . module } \n` ) ;
218229 } catch ( e ) {
230+ writeFileSync ( 1 , `ModuleJob::run() error: ${ e . stack } \n` ) ;
219231 if ( e ?. name === 'ReferenceError' &&
220232 isCommonJSGlobalLikeNotDefinedError ( e . message ) ) {
221233 e . message += ' in ES module scope' ;
@@ -237,6 +249,7 @@ class ModuleJob {
237249 'to use the \'.cjs\' file extension.' ;
238250 }
239251 }
252+ writeFileSync ( 1 , `ModuleJob::run() throwing error: ${ e . stack } \n` ) ;
240253 throw e ;
241254 }
242255 return { __proto__ : null , module : this . module } ;
0 commit comments