build: migrate from tsup to rslib

Replace tsup (esbuild-based) with rslib (rspack-based) across all packages.

tsup's built-in nodeProtocolPlugin strips the 'node:' prefix from all
Node.js builtins. Unlike node:fs etc., node:sqlite has no unprefixed
form, causing ERR_MODULE_NOT_FOUND at runtime. rslib handles node:
imports correctly without any workarounds.

Changes:
- Replace tsup.config.ts with rslib.config.ts in core, daemon, cli
- Swap tsup → @rslib/core in devDependencies
- Fix log-store.ts params type (Record<string, unknown> → Record<string, string | number>)
- Fix logStream.fd type cast in start.ts
- Exclude __tests__ from CLI tsconfig to avoid DTS errors
- All 356 tests pass, nerve init works correctly

Closes #70

小橘 🍊(NEKO Team)
This commit is contained in:
2026-04-23 09:48:45 +00:00
parent a084205b47
commit 1b5a52ea4d
14 changed files with 355 additions and 515 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.0",
"tsup": "^8.0.0",
"@rslib/core": "^0.21.3",
"typescript": "^5.5.0"
}
}
+2 -1
View File
@@ -18,7 +18,7 @@
},
"scripts": {
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
"build": "tsup",
"build": "rslib build",
"test": "vitest run"
},
"dependencies": {
@@ -26,6 +26,7 @@
"citty": "^0.1.6"
},
"devDependencies": {
"@rslib/core": "^0.21.3",
"@types/node": "^22.0.0",
"@uncaged/nerve-daemon": "workspace:*",
"vitest": "^4.1.5"
+25
View File
@@ -0,0 +1,25 @@
import { defineConfig } from "@rslib/core";
export default defineConfig({
lib: [
{
format: "esm",
dts: true,
banner: {
js: "#!/usr/bin/env node",
},
},
],
source: {
entry: {
index: "src/index.ts",
cli: "src/cli.ts",
"daemon-bootstrap": "src/daemon-bootstrap.ts",
},
},
output: {
target: "node",
cleanDistPath: true,
externals: ["@uncaged/nerve-daemon"],
},
});
+1 -1
View File
@@ -76,7 +76,7 @@ async function runDaemon(nerveRoot: string): Promise<void> {
const child = spawn(process.execPath, [bootstrapPath], {
detached: true,
stdio: ["ignore", logStream.fd, logStream.fd],
stdio: ["ignore", (logStream as any).fd, (logStream as any).fd],
env: { ...process.env, NERVE_ROOT: nerveRoot },
cwd: nerveRoot,
});
+2 -1
View File
@@ -6,5 +6,6 @@
"composite": false,
"types": ["node"]
},
"include": ["src"]
"include": ["src"],
"exclude": ["src/__tests__"]
}
-13
View File
@@ -1,13 +0,0 @@
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts", "src/cli.ts", "src/daemon-bootstrap.ts"],
format: ["esm"],
dts: true,
clean: true,
banner: {
js: "#!/usr/bin/env node",
},
/** Daemon is loaded from workspace node_modules at runtime — never bundle it. */
external: ["@uncaged/nerve-daemon"],
});
+5 -2
View File
@@ -3,20 +3,23 @@
"version": "0.1.4",
"type": "module",
"main": "dist/index.js",
"files": ["dist"],
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"types": "dist/index.d.ts",
"scripts": {
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
"build": "tsup",
"build": "rslib build",
"test": "vitest run"
},
"dependencies": {
"yaml": "^2.8.3"
},
"devDependencies": {
"@rslib/core": "^0.21.3",
"vitest": "^4.1.5"
}
}
+19
View File
@@ -0,0 +1,19 @@
import { defineConfig } from "@rslib/core";
export default defineConfig({
lib: [
{
format: "esm",
dts: true,
},
],
source: {
entry: {
index: "src/index.ts",
},
},
output: {
target: "node",
cleanDistPath: true,
},
});
-8
View File
@@ -1,8 +0,0 @@
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm"],
dts: true,
clean: true,
});
+2 -1
View File
@@ -12,7 +12,7 @@
},
"scripts": {
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
"build": "tsup",
"build": "rslib build",
"test": "vitest run"
},
"dependencies": {
@@ -21,6 +21,7 @@
"yaml": "^2.8.3"
},
"devDependencies": {
"@rslib/core": "^0.21.3",
"@types/node": "^22.0.0",
"vitest": "^4.1.5"
}
+20
View File
@@ -0,0 +1,20 @@
import { defineConfig } from "@rslib/core";
export default defineConfig({
lib: [
{
format: "esm",
dts: true,
},
],
source: {
entry: {
index: "src/index.ts",
"sense-worker": "src/sense-worker.ts",
},
},
output: {
target: "node",
cleanDistPath: true,
},
});
+1 -1
View File
@@ -335,7 +335,7 @@ export function createLogStore(dbPath: string): LogStore {
function query(filter: LogQuery = {}): LogEntry[] {
const conditions: string[] = [];
const params: Record<string, unknown> = {};
const params: Record<string, string | number> = {};
if (filter.source !== undefined) {
conditions.push("source = @source");
-8
View File
@@ -1,8 +0,0 @@
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts", "src/sense-worker.ts"],
format: ["esm"],
dts: true,
clean: true,
});
+277 -478
View File
File diff suppressed because it is too large Load Diff