refactor(cli): replace dynamic imports with static imports — closes #57 #59
Reference in New Issue
Block a user
Delete Branch "refactor/static-imports"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
import { spawn, execFile } from "node:child_process"andimport { promisify } from "node:util"import { spawn } from "node:child_process"and mergegetSocketPathinto existing workspace importBuild verified with
pnpm --filter @uncaged/nerve-cli build.Ref
Closes #57
Code Review — APPROVED ✅
+6 -10,2 个文件,纯清理重构。
await import()替换为顶层静态 import,消除不必要的异步开销execFileAsync提升为模块级常量,避免重复 promisifygetSocketPath合并到已有的 workspace import,减少一处动态 import干净利落,没毛病。
Reviewed by 小墨 🖊️