Add dev launch config and preserve existing NODE_OPTIONS

Add a "Dev Launch CLI" VS Code debug configuration and fix
scripts/dev.js to preserve existing NODE_OPTIONS (e.g. --inspect
flags injected by VS Code debugger) instead of overwriting them.
This commit is contained in:
DragonnZhang 2026-02-10 16:45:04 +08:00
parent 66f754e203
commit 3c513b6271
2 changed files with 18 additions and 2 deletions

View file

@ -67,13 +67,16 @@ register('${loaderUrl}', pathToFileURL('./'));
`;
writeFileSync(registerPath, registerCode);
// Preserve existing NODE_OPTIONS (e.g. VS Code debugger injects --inspect flags via NODE_OPTIONS)
const existingNodeOptions = process.env.NODE_OPTIONS || '';
const importFlag = `--import ${pathToFileURL(registerPath).href}`;
const env = {
...process.env,
DEV: 'true',
CLI_VERSION: 'dev',
NODE_ENV: 'development',
// Use --import with register() instead of deprecated --loader
NODE_OPTIONS: `--import ${pathToFileURL(registerPath).href}`,
NODE_OPTIONS: `${existingNodeOptions} ${importFlag}`.trim(),
};
const nodeArgs = [tsxPath, cliEntry, ...process.argv.slice(2)];