Skip to content

refactor: migrate to pnpm workspace monorepo#50

Merged
ronload merged 2 commits into
mainfrom
refactor/migrate-to-monorepo-workspace
Jun 24, 2026
Merged

refactor: migrate to pnpm workspace monorepo#50
ronload merged 2 commits into
mainfrom
refactor/migrate-to-monorepo-workspace

Conversation

@ronload

@ronload ronload commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Why

地址英譯與 3+3 郵遞區號比對是本專案最有價值、最難複製的部分,而 npm 上目前沒有把這塊做好的套件。為了日後能將它獨立成可重用、可發佈的 library,程式碼需要先變成 workspace——讓核心邏輯與 Next.js app 分離,並讓 app 像使用外部依賴一樣消費它。

這個 PR 是結構上的第一步:把單一 Next.js 套件拆成 pnpm workspace,並以 web app 作為抽出後核心的第一個消費者(dogfood)。

What changed

  • apps/web — 既有的 Next.js app(UI、頁面、SSG 區頁、ETL 腳本、public/data)原封不動移入。
  • packages/core@zipkit/core — 從 src/lib 抽出的無框架依賴核心邏輯:lookup-zipcode(3+3 特異性比對)、format-english-address(UPU 英譯)、共用 types。純函式,不依賴 React/Next。
  • app 透過 Next transpilePackages 消費 @zipkit/coreexports 指向 TS 原始碼,目前沒有 build step(延後到真的要發佈套件時再做)。
  • root package.json 持有 workspace scripts,透過 --filter delegate 給 apps/web;Prettier 改由 repo root 執行。
  • 更新 .gitignore / .prettierignore 路徑,README 改寫為新結構。

Review note

808 個檔案變更,但 798 個是純 rename(app 移入 apps/web/)。實質 diff 約 10 個檔案:新增的 workspace/package 設定與 import 改寫。淨 +170 / −100。

Verification

  • pnpm check(recursive typecheck + lint + Prettier)通過
  • pnpm --filter web build 通過 — 379 個靜態頁全數生成

Follow-ups(不在此 PR)

  • 部署前需在 Vercel 將專案 Root Directory 設為 apps/web
  • 後續:為 @zipkit/core 補 Vitest golden tests,再做真正的 build / publish pipeline。

ronload added 2 commits June 24, 2026 12:34
Restructure the single Next.js package into a pnpm workspace:

- apps/web: the Next.js app (UI, App Router pages, SSG district routes,
  ETL scripts, and public/data)
- packages/core (@zipkit/core): framework-agnostic domain logic extracted
  from src/lib -- lookup-zipcode (3+3 specificity matching),
  format-english-address (UPU formatting), and shared types

The app consumes @zipkit/core via Next transpilePackages; exports point at
the TS source, so there is no build step yet. Root package.json holds
workspace scripts that delegate to apps/web via --filter, and Prettier now
runs from the repo root. Updated .gitignore and .prettierignore paths.
Update file paths (apps/web, packages/core), rewrite the project structure
tree for the workspace, and note the monorepo in the tech stack.
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zipkit Ready Ready Preview, Comment Jun 24, 2026 4:43am

@ronload ronload merged commit a4ce09f into main Jun 24, 2026
4 checks passed
@ronload ronload deleted the refactor/migrate-to-monorepo-workspace branch June 24, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant