@@ -27,6 +27,10 @@ const {
27
27
} = require ( 'internal/source_map/source_map_cache' ) ;
28
28
const assert = require ( 'internal/assert' ) ;
29
29
const resolvedPromise = PromiseResolve ( ) ;
30
+ let debug = require ( 'internal/util/debuglog' ) . debuglog ( 'esm' , ( fn ) => {
31
+ debug = fn ;
32
+ } ) ;
33
+ const { writeFileSync } = require ( 'fs' ) ;
30
34
31
35
const noop = FunctionPrototype ;
32
36
@@ -87,8 +91,7 @@ class ModuleJob {
87
91
return job . modulePromise ;
88
92
} ) ;
89
93
90
- if ( promises !== undefined )
91
- await SafePromiseAllReturnVoid ( promises ) ;
94
+ if ( promises !== undefined ) await SafePromiseAllReturnVoid ( promises ) ;
92
95
93
96
return SafePromiseAllReturnArrayLike ( dependencyJobs ) ;
94
97
} ;
@@ -111,17 +114,21 @@ class ModuleJob {
111
114
}
112
115
113
116
async _instantiate ( ) {
117
+ writeFileSync ( 1 , 'ModuleJob::instantiate()\n' ) ;
114
118
const jobsInGraph = new SafeSet ( ) ;
115
119
const addJobsToDependencyGraph = async ( moduleJob ) => {
116
120
if ( jobsInGraph . has ( moduleJob ) ) {
117
121
return ;
118
122
}
119
123
jobsInGraph . add ( moduleJob ) ;
124
+ writeFileSync ( 1 , 'ModuleJob::instantiate() getting linked jobs\n' ) ;
120
125
const dependencyJobs = await moduleJob . linked ;
126
+ writeFileSync ( 1 , 'ModuleJob::instantiate() got linked jobs\n' ) ;
121
127
return SafePromiseAllReturnVoid ( dependencyJobs , addJobsToDependencyGraph ) ;
122
128
} ;
123
129
await addJobsToDependencyGraph ( this ) ;
124
130
131
+ writeFileSync ( 1 , 'ModuleJob::instantiate() job added to dep graph\n' ) ;
125
132
try {
126
133
if ( ! hasPausedEntry && this . inspectBrk ) {
127
134
hasPausedEntry = true ;
@@ -131,6 +138,7 @@ class ModuleJob {
131
138
this . module . instantiate ( ) ;
132
139
}
133
140
} catch ( e ) {
141
+ writeFileSync ( 1 , `ModuleJob::instantiate() error: ${ e . stack } \n` ) ;
134
142
decorateErrorStack ( e ) ;
135
143
// TODO(@bcoe): Add source map support to exception that occurs as result
136
144
// of missing named export. This is currently not possible because
@@ -210,12 +218,16 @@ class ModuleJob {
210
218
}
211
219
212
220
async run ( ) {
221
+ writeFileSync ( 1 , `ModuleJob::run() instantiating: ${ this . url } \n` ) ;
213
222
await this . instantiate ( ) ;
223
+ writeFileSync ( 1 , `ModuleJob::run() instantiated: ${ this . url } \n` ) ;
214
224
const timeout = - 1 ;
215
225
const breakOnSigint = false ;
216
226
try {
217
227
await this . module . evaluate ( timeout , breakOnSigint ) ;
228
+ writeFileSync ( 1 , `ModuleJob::run() evaluation complete: ${ this . module } \n` ) ;
218
229
} catch ( e ) {
230
+ writeFileSync ( 1 , `ModuleJob::run() error: ${ e . stack } \n` ) ;
219
231
if ( e ?. name === 'ReferenceError' &&
220
232
isCommonJSGlobalLikeNotDefinedError ( e . message ) ) {
221
233
e . message += ' in ES module scope' ;
@@ -237,6 +249,7 @@ class ModuleJob {
237
249
'to use the \'.cjs\' file extension.' ;
238
250
}
239
251
}
252
+ writeFileSync ( 1 , `ModuleJob::run() throwing error: ${ e . stack } \n` ) ;
240
253
throw e ;
241
254
}
242
255
return { __proto__ : null , module : this . module } ;
0 commit comments