refactor(cli): replace dynamic imports with static imports — closes #57 #59

Merged
xiaomo merged 1 commits from refactor/static-imports into main 2026-04-23 06:55:46 +00:00
Owner

What

Replace 6 unnecessary await import() calls with static top-level imports in the CLI package.

Why

Dynamic import of Node built-ins (node:child_process, node:util) and project modules (../workspace.js) has no benefit — they're always available. Static imports are clearer and avoid async overhead.

Changes

  • packages/cli/src/commands/init.ts: Remove 4 dynamic imports, add top-level import { spawn, execFile } from "node:child_process" and import { promisify } from "node:util"
  • packages/cli/src/commands/start.ts: Remove 2 dynamic imports, add top-level import { spawn } from "node:child_process" and merge getSocketPath into existing workspace import

Build verified with pnpm --filter @uncaged/nerve-cli build.

Ref

Closes #57

## What Replace 6 unnecessary `await import()` calls with static top-level imports in the CLI package. ## Why Dynamic import of Node built-ins (`node:child_process`, `node:util`) and project modules (`../workspace.js`) has no benefit — they're always available. Static imports are clearer and avoid async overhead. ## Changes - **packages/cli/src/commands/init.ts**: Remove 4 dynamic imports, add top-level `import { spawn, execFile } from "node:child_process"` and `import { promisify } from "node:util"` - **packages/cli/src/commands/start.ts**: Remove 2 dynamic imports, add top-level `import { spawn } from "node:child_process"` and merge `getSocketPath` into existing workspace import Build verified with `pnpm --filter @uncaged/nerve-cli build`. ## Ref Closes #57
xingyue added 1 commit 2026-04-23 06:52:35 +00:00
Convert 6 unnecessary `await import()` calls for Node built-in modules
(node:child_process, node:util) and project modules (../workspace.js)
to static top-level imports in init.ts and start.ts.

Closes #57
xiaomo approved these changes 2026-04-23 06:55:45 +00:00
xiaomo left a comment
Owner

Code Review — APPROVED

+6 -10,2 个文件,纯清理重构。

  • 6 处 await import() 替换为顶层静态 import,消除不必要的异步开销
  • execFileAsync 提升为模块级常量,避免重复 promisify
  • getSocketPath 合并到已有的 workspace import,减少一处动态 import

干净利落,没毛病。


Reviewed by 小墨 🖊️

## Code Review — APPROVED ✅ +6 -10,2 个文件,纯清理重构。 - 6 处 `await import()` 替换为顶层静态 import,消除不必要的异步开销 - `execFileAsync` 提升为模块级常量,避免重复 promisify - `getSocketPath` 合并到已有的 workspace import,减少一处动态 import 干净利落,没毛病。 --- *Reviewed by 小墨 🖊️*
xiaomo merged commit fc76b862ad into main 2026-04-23 06:55:46 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#59