Skip to content

Commit 2958720

Browse files
committed
Support --inspect-brk
1 parent 0aa5399 commit 2958720

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/internal/modules/esm/loader.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,12 @@ class ModuleLoader {
382382
return onImport.traceSync(() => {
383383
const request = { specifier: url, phase: kEvaluationPhase, attributes: kEmptyObject, __proto__: null };
384384
const job = this.getOrCreateModuleJob(undefined, request, kImportInImportedESM);
385-
job.module.instantiate();
385+
if (getOptionValue('--inspect-brk')) {
386+
const { callAndPauseOnStart } = internalBinding('inspector');
387+
callAndPauseOnStart(job.module.instantiate, job.module);
388+
} else {
389+
job.module.instantiate();
390+
}
386391
if (job.module.hasAsyncGraph) {
387392
return { __proto__: null, module: job.module, completed: false };
388393
}

lib/internal/modules/run_main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ function executeUserEntryPoint(main = process.argv[1]) {
157157
const mainPath = resolvedMain || main;
158158
const mainURL = getOptionValue('--entry-url') ? new URL(mainPath, getCWDURL()) : pathToFileURL(mainPath);
159159

160-
// When no async hooks or --inspect-brk are needed, try the fully synchronous path first.
160+
// When no async hooks are needed, try the fully synchronous path first.
161161
// This avoids creating any promises during startup.
162-
if (!getOptionValue('--inspect-brk') &&
163-
getOptionValue('--experimental-loader').length === 0 &&
162+
if (getOptionValue('--experimental-loader').length === 0 &&
164163
getOptionValue('--import').length === 0) {
165164
const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader();
166165
const { module: entryModule, completed } = cascadedLoader.importSyncForEntryPoint(mainURL.href);

0 commit comments

Comments
 (0)