Skip to content

Commit

Permalink
fix: generate sourcesContent when Node.js debugger is enabled (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
char8x authored Oct 26, 2024
1 parent 315d5f4 commit 7c47074
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils/transform/get-esbuild-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ export const baseConfig = Object.freeze({
loader: 'default',
});

// match Node.js debugger flags
// https://nodejs.org/api/cli.html#--inspecthostport
const NODE_DEBUGGER_FLAG_REGEX = /^--inspect(?:-brk|-port|-publish-uid|-wait)?(?:=|$)/;

const isNodeDebuggerEnabled = process.execArgv.some(flag => NODE_DEBUGGER_FLAG_REGEX.test(flag));

export const cacheConfig = {
...baseConfig,

sourcemap: true,

/**
* Improve performance by only generating sourcesContent
* when V8 coverage is enabled
* when V8 coverage is enabled or Node.js debugger is enabled
*
* https://esbuild.github.io/api/#sources-content
*/
sourcesContent: Boolean(process.env.NODE_V8_COVERAGE),
sourcesContent: Boolean(process.env.NODE_V8_COVERAGE) || isNodeDebuggerEnabled,

/**
* Smaller output for cache and marginal performance improvement:
Expand Down

0 comments on commit 7c47074

Please sign in to comment.