@@ -1317,15 +1317,6 @@ Module.prototype.require = function(id) { |
1317 | 1317 | }; |
1318 | 1318 |
|
1319 | 1319 | let requireModuleWarningMode; |
1320 | | -/** |
1321 | | - * Resolved path to `process.argv[1]` will be lazily placed here |
1322 | | - * (needed for setting breakpoint when called with `--inspect-brk`). |
1323 | | - * @type {string | undefined} |
1324 | | - */ |
1325 | | -let resolvedArgv; |
1326 | | -let hasPausedEntry = false; |
1327 | | -/** @type {import('vm').Script} */ |
1328 | | - |
1329 | 1320 | /** |
1330 | 1321 | * Resolve and evaluate it synchronously as ESM if it's ESM. |
1331 | 1322 | * @param {Module} mod CJS module instance |
@@ -1536,32 +1527,6 @@ Module.prototype._compile = function(content, filename, format) { |
1536 | 1527 | return; |
1537 | 1528 | } |
1538 | 1529 |
|
1539 | | - // TODO(joyeecheung): the detection below is unnecessarily complex. Using the |
1540 | | - // kIsMainSymbol, or a kBreakOnStartSymbol that gets passed from |
1541 | | - // higher level instead of doing hacky detection here. |
1542 | | - let inspectorWrapper = null; |
1543 | | - if (getOptionValue('--inspect-brk') && process._eval == null) { |
1544 | | - if (!resolvedArgv) { |
1545 | | - // We enter the repl if we're not given a filename argument. |
1546 | | - if (process.argv[1]) { |
1547 | | - try { |
1548 | | - resolvedArgv = Module._resolveFilename(process.argv[1], null, false); |
1549 | | - } catch { |
1550 | | - // We only expect this codepath to be reached in the case of a |
1551 | | - // preloaded module (it will fail earlier with the main entry) |
1552 | | - assert(ArrayIsArray(getOptionValue('--require'))); |
1553 | | - } |
1554 | | - } else { |
1555 | | - resolvedArgv = 'repl'; |
1556 | | - } |
1557 | | - } |
1558 | | - |
1559 | | - // Set breakpoint on module start |
1560 | | - if (resolvedArgv && !hasPausedEntry && filename === resolvedArgv) { |
1561 | | - hasPausedEntry = true; |
1562 | | - inspectorWrapper = internalBinding('inspector').callAndPauseOnStart; |
1563 | | - } |
1564 | | - } |
1565 | 1530 | const dirname = path.dirname(filename); |
1566 | 1531 | const require = makeRequireFunction(this, redirects); |
1567 | 1532 | let result; |
@@ -1571,9 +1536,10 @@ Module.prototype._compile = function(content, filename, format) { |
1571 | 1536 | if (requireDepth === 0) { statCache = new SafeMap(); } |
1572 | 1537 | setHasStartedUserCJSExecution(); |
1573 | 1538 | this[kIsExecuting] = true; |
1574 | | - if (inspectorWrapper) { |
1575 | | - result = inspectorWrapper(compiledWrapper, thisValue, exports, |
1576 | | - require, module, filename, dirname); |
| 1539 | + if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) { |
| 1540 | + const { callAndPauseOnStart } = internalBinding('inspector'); |
| 1541 | + result = callAndPauseOnStart(compiledWrapper, thisValue, exports, |
| 1542 | + require, module, filename, dirname); |
1577 | 1543 | } else { |
1578 | 1544 | result = ReflectApply(compiledWrapper, thisValue, |
1579 | 1545 | [exports, require, module, filename, dirname]); |
|