Skip to content

Commit 7c47074

Browse files
authored
fix: generate sourcesContent when Node.js debugger is enabled (#670)
1 parent 315d5f4 commit 7c47074

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/utils/transform/get-esbuild-options.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ export const baseConfig = Object.freeze({
1010
loader: 'default',
1111
});
1212

13+
// match Node.js debugger flags
14+
// https://nodejs.org/api/cli.html#--inspecthostport
15+
const NODE_DEBUGGER_FLAG_REGEX = /^--inspect(?:-brk|-port|-publish-uid|-wait)?(?:=|$)/;
16+
17+
const isNodeDebuggerEnabled = process.execArgv.some(flag => NODE_DEBUGGER_FLAG_REGEX.test(flag));
18+
1319
export const cacheConfig = {
1420
...baseConfig,
1521

1622
sourcemap: true,
1723

1824
/**
1925
* Improve performance by only generating sourcesContent
20-
* when V8 coverage is enabled
26+
* when V8 coverage is enabled or Node.js debugger is enabled
2127
*
2228
* https://esbuild.github.io/api/#sources-content
2329
*/
24-
sourcesContent: Boolean(process.env.NODE_V8_COVERAGE),
30+
sourcesContent: Boolean(process.env.NODE_V8_COVERAGE) || isNodeDebuggerEnabled,
2531

2632
/**
2733
* Smaller output for cache and marginal performance improvement:

0 commit comments

Comments
 (0)