build: migrate from tsup to rslib #70

Closed
opened 2026-04-23 09:41:48 +00:00 by xiaoju · 0 comments
Owner

Problem

tsup's built-in nodeProtocolPlugin strips the node: prefix from all Node.js builtins during bundling. For most modules (node:fs, node:path, etc.) this is harmless since the unprefixed form also works. However, node:sqlite (added in Node 22.5) has no unprefixed form, causing ERR_MODULE_NOT_FOUND at runtime.

This affects both @uncaged/nerve-daemon and @uncaged/nerve-cli packages.

A workaround exists (post-build onSuccess hook to sed the output), but it's fragile and shouldn't be needed.

Proposed Solution

Migrate from tsup (esbuild-based) to rslib (rspack-based):

  • rslib does not perform implicit node: prefix stripping
  • Faster builds (Rust-based rspack)
  • Better DTS generation via rsbuild plugin
  • Similar config API, low migration cost
  • Actively maintained by the rspack team

Scope

  • Replace tsup with rslib in packages/daemon
  • Replace tsup with rslib in packages/cli
  • Replace tsup with rslib in packages/core
  • Fix log-store.ts params type (Record<string, unknown>Record<string, string | number>)
  • Verify all 356 tests pass
  • Verify nerve init works correctly

小橘 🍊(NEKO Team)

## Problem tsup's built-in `nodeProtocolPlugin` strips the `node:` prefix from all Node.js builtins during bundling. For most modules (`node:fs`, `node:path`, etc.) this is harmless since the unprefixed form also works. However, `node:sqlite` (added in Node 22.5) has **no unprefixed form**, causing `ERR_MODULE_NOT_FOUND` at runtime. This affects both `@uncaged/nerve-daemon` and `@uncaged/nerve-cli` packages. A workaround exists (post-build `onSuccess` hook to sed the output), but it's fragile and shouldn't be needed. ## Proposed Solution Migrate from **tsup** (esbuild-based) to **rslib** (rspack-based): - rslib does not perform implicit `node:` prefix stripping - Faster builds (Rust-based rspack) - Better DTS generation via rsbuild plugin - Similar config API, low migration cost - Actively maintained by the rspack team ## Scope - [ ] Replace tsup with rslib in `packages/daemon` - [ ] Replace tsup with rslib in `packages/cli` - [ ] Replace tsup with rslib in `packages/core` - [ ] Fix `log-store.ts` params type (`Record<string, unknown>` → `Record<string, string | number>`) - [ ] Verify all 356 tests pass - [ ] Verify `nerve init` works correctly 小橘 🍊(NEKO Team)
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#70