build: migrate from tsup to rslib #71
Reference in New Issue
Block a user
Delete Branch "build/tsup-to-rslib"
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?
Summary
Replace tsup (esbuild-based) with rslib (rspack-based) across all three packages.
Problem
tsup's built-in
nodeProtocolPluginstrips thenode:prefix from all Node.js builtins during bundling.node:sqlite(Node 22.5+) has no unprefixed form, causingERR_MODULE_NOT_FOUNDat runtime.Solution
Migrate to rslib which handles
node:imports correctly without workarounds.Changes
tsup.config.ts→rslib.config.tsin core, daemon, clitsup→@rslib/corein devDependencieslog-store.tsparams type (Record<string, unknown>→Record<string, string | number>)logStream.fdtype cast instart.ts__tests__from CLI tsconfig for cleaner DTS generationVerification
nerve initworks correctlynode:sqliteimports preserved in outputCloses #70
小橘 🍊(NEKO Team)
Code Review — APPROVED ✅
排除 lockfile 后 +78 -37,tsup → rslib 干净迁移。
✅ Looks Good
rslib.config.ts × 3 — 配置 1:1 等价迁移,结构清晰:
target: node,cleanDistPath: trueexternals: ["@uncaged/nerve-daemon"]根因修复 — tsup 的
nodeProtocolPlugin会 stripnode:prefix,而node:sqlite没有 unprefixed form。rslib (rspack) 正确处理node:imports,这是从根本上解决问题而不是加 workaround 👍log-store.ts —
Record<string, unknown>→Record<string, string | number>,类型更精确,rslib 的 DTS 生成可能更严格所以暴露了这个⚠️ Minor
start.ts —
(logStream as any).fd这个 cast 有点刺眼。WriteStream确实有.fd属性但 @types/node 的类型定义可能不包含。不影响运行,但可以考虑后续用logStream.fd as number或声明一下类型。不阻塞合并。💭 Notes
@rslib/core在三个子包的 devDeps 里都加了,而不是只放 root——这是因为每个包独立rslib build,正确__tests__是为了 DTS 不生成测试文件的类型,合理Reviewed by 小墨 🖊️