@@ -1332,15 +1332,6 @@ Module.prototype.require = function(id) {
13321332 }
13331333} ;
13341334
1335- /**
1336- * Resolved path to `process.argv[1]` will be lazily placed here
1337- * (needed for setting breakpoint when called with `--inspect-brk`).
1338- * @type {string | undefined }
1339- */
1340- let resolvedArgv ;
1341- let hasPausedEntry = false ;
1342- /** @type {import('vm').Script } */
1343-
13441335/**
13451336 * Resolve and evaluate it synchronously as ESM if it's ESM.
13461337 * @param {Module } mod CJS module instance
@@ -1542,32 +1533,6 @@ Module.prototype._compile = function(content, filename, format) {
15421533 return ;
15431534 }
15441535
1545- // TODO(joyeecheung): the detection below is unnecessarily complex. Using the
1546- // kIsMainSymbol, or a kBreakOnStartSymbol that gets passed from
1547- // higher level instead of doing hacky detection here.
1548- let inspectorWrapper = null ;
1549- if ( getOptionValue ( '--inspect-brk' ) && process . _eval == null ) {
1550- if ( ! resolvedArgv ) {
1551- // We enter the repl if we're not given a filename argument.
1552- if ( process . argv [ 1 ] ) {
1553- try {
1554- resolvedArgv = Module . _resolveFilename ( process . argv [ 1 ] , null , false ) ;
1555- } catch {
1556- // We only expect this codepath to be reached in the case of a
1557- // preloaded module (it will fail earlier with the main entry)
1558- assert ( ArrayIsArray ( getOptionValue ( '--require' ) ) ) ;
1559- }
1560- } else {
1561- resolvedArgv = 'repl' ;
1562- }
1563- }
1564-
1565- // Set breakpoint on module start
1566- if ( resolvedArgv && ! hasPausedEntry && filename === resolvedArgv ) {
1567- hasPausedEntry = true ;
1568- inspectorWrapper = internalBinding ( 'inspector' ) . callAndPauseOnStart ;
1569- }
1570- }
15711536 const dirname = path . dirname ( filename ) ;
15721537 const require = makeRequireFunction ( this , redirects ) ;
15731538 let result ;
@@ -1577,9 +1542,10 @@ Module.prototype._compile = function(content, filename, format) {
15771542 if ( requireDepth === 0 ) { statCache = new SafeMap ( ) ; }
15781543 setHasStartedUserCJSExecution ( ) ;
15791544 this [ kIsExecuting ] = true ;
1580- if ( inspectorWrapper ) {
1581- result = inspectorWrapper ( compiledWrapper , thisValue , exports ,
1582- require , module , filename , dirname ) ;
1545+ if ( this [ kIsMainSymbol ] && getOptionValue ( '--inspect-brk' ) ) {
1546+ const { callAndPauseOnStart } = internalBinding ( 'inspector' ) ;
1547+ result = callAndPauseOnStart ( compiledWrapper , thisValue , exports ,
1548+ require , module , filename , dirname ) ;
15831549 } else {
15841550 result = ReflectApply ( compiledWrapper , thisValue ,
15851551 [ exports , require , module , filename , dirname ] ) ;
0 commit comments