fix: fix worker-build missing route generation (#20808)

Add build:routes:worker script that generates routes-worker.js with
WORKER_BUILD=true before running tsdown for worker builds. Also add
alias for routes.json to resolve static module resolution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
DIYgod
2026-01-04 13:50:16 +08:00
committed by GitHub
parent e27f501643
commit eaf1159521
2 changed files with 4 additions and 1 deletions

View File

@@ -31,7 +31,8 @@
"build:lib": "npm run build:routes && tsdown --config ./tsdown-lib.config.ts",
"build:routes": "cross-env NODE_ENV=dev tsx scripts/workflow/build-routes.ts",
"vercel-build": "npm run build:routes && tsdown --config ./tsdown-vercel.config.ts",
"worker-build": "tsdown --config ./tsdown-worker.config.ts",
"build:routes:worker": "cross-env NODE_ENV=dev WORKER_BUILD=true tsx scripts/workflow/build-routes.ts",
"worker-build": "npm run build:routes:worker && tsdown --config ./tsdown-worker.config.ts",
"worker-dev": "npm run worker-build && wrangler dev",
"worker-deploy": "npm run worker-build && wrangler deploy",
"worker-test": "npm run worker-build && vitest run lib/worker.worker.test.ts",

View File

@@ -91,5 +91,7 @@ export default defineConfig({
'xxhash-wasm': path.resolve('./lib/shims/xxhash-wasm.ts'),
// Routes file with Worker-specific build (match relative import from lib/)
'../assets/build/routes.js': path.resolve('./assets/build/routes-worker.js'),
// routes.json is only used in test environment, but rolldown still tries to resolve it
'../assets/build/routes.json': path.resolve('./assets/build/routes-worker.js'),
},
});