Skip to content

Add Node version guard for unsupported runtimes#319

Merged
iamtoruk merged 1 commit into
mainfrom
fix/node-version-guard
May 12, 2026
Merged

Add Node version guard for unsupported runtimes#319
iamtoruk merged 1 commit into
mainfrom
fix/node-version-guard

Conversation

@iamtoruk
Copy link
Copy Markdown
Member

Summary

  • Split CLI into a 15-line launcher (src/cli.ts) + full CLI (src/main.ts)
  • Launcher checks for Node >= 22.13.0 before dynamically importing main bundle
  • Users on Node 18 get a clear upgrade message instead of a cryptic SyntaxError: Invalid regular expression flags from string-width
  • Aligned engines field to >=22.13.0 to match the actual floor
  • Cross-platform build (no cp dependency)

Closes #232.

Why two files?

The crash is a parse error -- Node 18 can't even load the bundle because string-width uses the /v regex flag (Node 20+). A runtime check in the same file won't help because the file fails to parse before any code runs. The launcher must be a separate file that Node 18 can parse.

Build output

  • dist/cli.js -- 400-byte launcher (version check + dynamic import)
  • dist/main.js -- 667KB bundle (the actual CLI)

Test plan

  • 678/678 tests pass
  • node dist/cli.js --version works
  • node dist/cli.js report --format json produces valid output
  • Version gate correctly blocks 18.x, 22.0-22.12
  • Version gate correctly allows 22.13+, 23.x, 24.x
  • Build works cross-platform (no cp dependency)
  • Dynamic import has .catch() for proper error handling

Split CLI into a tiny launcher (src/cli.ts) that checks for Node >= 22.13.0
before dynamically importing the full CLI (src/main.ts). Users on Node 18
now get a clear upgrade message instead of a cryptic regex parse error from
string-width. Closes #232.
@iamtoruk iamtoruk merged commit 38e41e9 into main May 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SyntaxError: Invalid regular expression flags on Pi

1 participant