-
Notifications
You must be signed in to change notification settings - Fork 240
Closed
Description
Build + Startup Improvements (Production)
Problem
When running the production build (pnpm build) and then starting the server, the app fails with an ESM module resolution error because the internal package @traderalice/opentypebb exports point at src/ instead of built dist/ files.
Additionally, there is no convenient start script for running the production build after pnpm build.
Suggested Fix (Markdown + Code Examples)
1) Add a start script to package.json
This allows users to run pnpm start after building.
{
"scripts": {
"dev": "tsx src/main.ts",
"dev:ui": "pnpm --filter open-alice-ui dev",
- "build": "pnpm --filter opentypebb build && pnpm build:ui && pnpm build:backend",
+ "build": "pnpm --filter opentypebb build && pnpm build:ui && pnpm build:backend",
"build:ui": "pnpm --filter open-alice-ui build",
"build:backend": "tsup src/main.ts --format esm --dts",
"test": "vitest run",
"test:watch": "vitest",
+ "start": "node dist/main.js"
},
"keywords": [
"trading",
"ai-agent",
"crypto",
"securities",
"file-driven"
],
...
}2) Fix @traderalice/opentypebb exports (point to dist/)
When the root app imports @traderalice/opentypebb, Node resolves the package entry points via exports. The exports currently point at source .ts files, so running the built app fails unless the TS sources are present.
Update packages/opentypebb/package.json:
{
"name": "@traderalice/opentypebb",
"version": "0.1.2",
"description": "TypeScript port of OpenBB Platform — financial data infrastructure",
"type": "module",
"exports": {
".": {
- "import": "./src/index.ts",
- "types": "./src/index.ts"
+ "import": "./dist/index.js",
+ "types": "./dist/index.d.ts"
},
"./server": {
- "import": "./src/server.ts",
- "types": "./src/server.ts"
+ "import": "./dist/server.js",
+ "types": "./dist/server.d.ts"
}
},
"files": [
"dist"
],
...
}3) Ensure build order includes opentypebb
Make sure the top-level build script builds opentypebb first so the main app can import it successfully.
{
"scripts": {
- "build": "pnpm build:ui && pnpm build:backend",
+ "build": "pnpm --filter opentypebb build && pnpm build:ui && pnpm build:backend",
"build:ui": "pnpm --filter open-alice-ui build",
"build:backend": "tsup src/main.ts --format esm --dts",
...
},
...
}Expected Result
pnpm buildcompletes successfullypnpm startruns the production server on port 3002- No
ERR_MODULE_NOT_FOUNDrelated toopentypebbin production mode
Environment
- Node.js 22+
- pnpm 10+
- OpenAlice version:
0.9.0-beta.5
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels