Skip to content

Commit 823ff2a

Browse files
samchonclaude
andcommitted
Bundle the api package with rolldown and a workspace self-reference
The api package no longer rewrites its own name through a tsconfig path alias and @ttsc/paths. Instead it declares itself in devDependencies via workspace:^, so the nestia-generated self-imports resolve through the package "exports" field — the same Node/TypeScript self-reference mechanism consumers use after npm publish, where the type-only imports survive solely in the d.ts files and pnpm rewrites the workspace protocol to a real semver on pack. The bespoke in-memory rollup + terser pipeline is replaced by the typia-style rolldown config: ttsc keeps emitting lib/*.js + d.ts, and rolldown feeds the TypeScript sources through @ttsc/unplugin to emit 1:1 ESM twins at lib/*.mjs with preserveModules. dependabot now tracks rolldown so the new toolchain stays fresh. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9pGKmKPpm1pbc8TkjQqUx
1 parent 1c9aa46 commit 823ff2a

7 files changed

Lines changed: 356 additions & 482 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ updates:
1919
- dependency-name: "typescript"
2020
- dependency-name: "ttsc"
2121
- dependency-name: "@ttsc/*"
22+
- dependency-name: "rolldown"
2223
groups:
2324
Samchon:
2425
patterns:
@@ -40,3 +41,6 @@ updates:
4041
- "typescript"
4142
- "ttsc"
4243
- "@ttsc/*"
44+
Rolldown:
45+
patterns:
46+
- "rolldown"

packages/api/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
".": "./src/index.ts"
88
},
99
"scripts": {
10-
"build": "pnpm build:sdk && pnpm build:ttsc && pnpm build:rollup",
10+
"build": "pnpm build:sdk && pnpm build:ttsc && pnpm build:rolldown",
1111
"build:sdk": "cd ../backend && pnpm build:sdk",
12-
"build:ttsc": "ttsc -p tsconfig.json",
13-
"build:rollup": "rollup -c",
12+
"build:ttsc": "rimraf lib && ttsc -p tsconfig.json",
13+
"build:rolldown": "rolldown -c",
1414
"format": "ttsc format -p tsconfig.json",
1515
"lint": "ttsc -p tsconfig.json --noEmit",
1616
"prepack": "pnpm build"
@@ -37,10 +37,12 @@
3737
"typia": "catalog:samchon"
3838
},
3939
"devDependencies": {
40-
"@rollup/plugin-terser": "^0.4.4",
40+
"@ORGANIZATION/PROJECT-api": "workspace:^",
4141
"@ttsc/lint": "catalog:typescript",
42-
"@ttsc/paths": "catalog:typescript",
43-
"rollup": "^4.18.0",
42+
"@ttsc/unplugin": "catalog:typescript",
43+
"rimraf": "catalog:utils",
44+
"rolldown": "catalog:rolldown",
45+
"tinyglobby": "^0.2.12",
4446
"ttsc": "catalog:typescript",
4547
"typescript": "catalog:typescript"
4648
},

packages/api/rolldown.config.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import ttsc from "@ttsc/unplugin/rolldown";
2+
import path from "node:path";
3+
import { globSync } from "tinyglobby";
4+
5+
// The `.mjs` build feeds the TypeScript sources straight to rolldown, which
6+
// transpiles them natively; `@ttsc/unplugin` applies the project's ttsc
7+
// plugins on the way in. `preserveModules` keeps the 1:1 module layout, so
8+
// every `lib/<path>.js` from the main ttsc build gets a genuine ESM twin at
9+
// `lib/<path>.mjs` — named exports intact, no facade chunks, no CommonJS
10+
// transcoding. Everything outside `src/` is an external module, including the
11+
// package's type-only imports of itself.
12+
export default {
13+
input: globSync("./src/**/*.ts"),
14+
external: (id) => !id.startsWith(".") && !path.isAbsolute(id),
15+
output: {
16+
dir: "./lib",
17+
format: "esm",
18+
sourcemap: true,
19+
entryFileNames: "[name].mjs",
20+
preserveModules: true,
21+
preserveModulesRoot: "src",
22+
},
23+
plugins: [ttsc()],
24+
};

packages/api/rollup.config.js

Lines changed: 0 additions & 152 deletions
This file was deleted.

packages/api/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"stripInternal": true,
66
"outDir": "lib",
77
"rootDir": "src",
8-
"paths": {
9-
"@ORGANIZATION/PROJECT-api": ["./src"]
10-
},
118
"experimentalDecorators": true,
129
"emitDecoratorMetadata": true
1310
},

0 commit comments

Comments
 (0)