Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ out/

# production
build/
dist/

# misc
.DS_Store
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- [MapLibre GL JS](https://maplibre.org/) -- 台灣行政區地圖
- [TypeScript](https://www.typescriptlang.org/) 6
- [pnpm](https://pnpm.io/) workspace monorepo(`apps/web` 應用 + `packages/core` 核心邏輯)
- [tsdown](https://tsdown.dev/) -- `@zipkit/core` 套件建置(Rolldown 驅動,輸出 ESM + 型別宣告)

## 快速開始

Expand Down Expand Up @@ -108,8 +109,12 @@ packages/
lookup-zipcode.ts # 3+3 郵遞區號特異性評分比對
format-english-address.ts # UPU 格式英譯
types.ts # 共用領域型別
tsdown.config.ts # tsdown 建置設定(輸出 ESM + .d.ts 至 dist/)
dist/ # 建置產物(不納入版本控制)
```

`@zipkit/core` 以 [tsdown](https://tsdown.dev/) 建置為 `dist/`(ESM + 型別宣告),`apps/web` 消費編譯後的套件而非 TS 原始碼。凡會觸及 web 的指令(`dev`、`build`、`lint`、`typecheck`)皆會先建置 `@zipkit/core`,確保 `dist/` 就緒。

## 資料來源

本專案使用以下第三方開源資料:
Expand Down
1 change: 0 additions & 1 deletion apps/web/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
transpilePackages: ["@zipkit/core"],
rewrites() {
return {
beforeFiles: [
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "pnpm --filter @zipkit/core build && next build",
"start": "next start",
"lint": "eslint",
"typecheck": "tsc --noEmit",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"private": true,
"packageManager": "pnpm@10.33.0",
"scripts": {
"dev": "pnpm --filter web dev",
"dev": "pnpm --filter @zipkit/core build && pnpm --filter web dev",
"build": "pnpm --filter web build",
"start": "pnpm --filter web start",
"lint": "pnpm --filter web lint",
"typecheck": "pnpm --recursive typecheck",
"lint": "pnpm --filter @zipkit/core build && pnpm --filter web lint",
"typecheck": "pnpm --filter @zipkit/core build && pnpm --recursive typecheck",
"etl": "pnpm --filter web etl",
"test": "pnpm --recursive run test",
"format": "prettier --write .",
"format:check": "prettier --check .",
"check": "pnpm --recursive typecheck && pnpm --filter web lint && prettier --check ."
"check": "pnpm --filter @zipkit/core build && pnpm --recursive typecheck && pnpm --filter web lint && prettier --check ."
},
"devDependencies": {
"prettier": "^3.8.4",
Expand Down
15 changes: 11 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
"type": "module",
"exports": {
".": {
"types": "./src/index.ts",
"default": "./src/index.ts"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsdown",
"dev": "tsdown --watch",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest"
},
"devDependencies": {
"tsdown": "^0.22.3",
"typescript": "^6.0.3",
"vitest": "^4.1.9"
}
Expand Down
9 changes: 9 additions & 0 deletions packages/core/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "tsdown";

export default defineConfig({
entry: ["src/index.ts"],
format: ["esm"],
platform: "neutral",
dts: true,
clean: true,
});
Loading
Loading