Skip to content

build: switch ogpeek from tsc to tsdown#12

Draft
minjun0219 wants to merge 3 commits into
mainfrom
claude/switch-to-tsdown-I8xvj
Draft

build: switch ogpeek from tsc to tsdown#12
minjun0219 wants to merge 3 commits into
mainfrom
claude/switch-to-tsdown-I8xvj

Conversation

@minjun0219

@minjun0219 minjun0219 commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Summary

Switches packages/ogpeek's build tool from tsc to tsdown (Rolldown + oxc). The engine is small (one dependency) with two entry points (., ./fetch), so the transition cost is low and the speed gain is clear.

  • Build time: ~800ms (down from the tsc baseline)
  • Output identical: dist/{index,fetch}.{js,d.ts} plus sourcemaps — exports mapping unchanged
  • npm tarball layout: identical (README + dist/* + package.json)

Changes

File Change
packages/ogpeek/package.json build: "pnpm run typecheck && tsdown", add tsdown ^0.21.10, drop rimraf
packages/ogpeek/tsdown.config.ts New — 2 entries, ESM, dts/sourcemap on, fixedExtension: false
pnpm-lock.yaml tsdown and transitive deps

tsdown.config.ts

export default defineConfig({
  entry: ["src/index.ts", "src/fetch.ts"],
  format: "esm",
  dts: true,
  sourcemap: true,
  target: "node20",
  clean: true,
  fixedExtension: false, // keep .js / .d.ts
});

htmlparser2 lives in dependencies, so tsdown keeps it external by default — no explicit external config needed (v0.21 deprecated external in favor of deps.neverBundle).

Trade-off

tsdown does not typecheck (oxc-based transpile). To preserve the prior safety where build failed on type errors, build now chains tsc --noEmit && tsdown. Type regressions still fail the build exactly as before; the only new surface is a separate typecheck script for callers that want the check without bundling.

Test plan

  • pnpm -F ogpeek build — verify dist/ outputs (index.js, fetch.js, *.d.ts, *.js.map)
  • pnpm -F ogpeek test — 33/33 pass
  • pnpm -F ogpeek typecheck — pass
  • pnpm -F website typecheck — pass (chains ogpeek build)
  • dist/index.js does not bundle htmlparser2 (external preserved)
  • dist/index.js has no Node-only leakage from fetch.ts (CLAUDE.md principle 1)
  • npm pack --dry-run tarball layout matches the previous output
  • CI pass

https://claude.ai/code/session_01Y9ikfab6CoTdXf9i64Fe61


Generated by Claude Code

빌드 시간을 ~수 초에서 약 800ms로 단축. 산출물은 기존과 동일하게
dist/{index,fetch}.{js,d.ts} 형태로 유지된다.

- tsdown.config.ts 신설: 두 엔트리(.,/fetch), ESM 단일 포맷, dts/sourcemap on
- fixedExtension: false 로 .js / .d.ts 확장자 유지 → exports 매핑 그대로
- htmlparser2 는 dependencies 항목이라 tsdown 기본 동작상 external 유지
- typecheck 는 여전히 tsc --noEmit 으로 분리 (tsdown 은 oxc 기반이라
  타입 검사를 하지 않음)
- rimraf 는 tsdown 내장 clean 으로 대체되어 제거
Copilot AI review requested due to automatic review settings April 25, 2026 01:46
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ogpeek e82cb50 Commit Preview URL

Branch Preview URL
Apr 26 2026, 12:19 AM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

packages/ogpeek의 빌드 파이프라인을 tsc 기반에서 tsdown(Rolldown + oxc) 기반으로 전환해, dist/{index,fetch}.{js,d.ts} 산출물을 유지하면서 빌드 시간을 단축하려는 PR입니다.

Changes:

  • packages/ogpeek의 빌드 스크립트를 tsdown으로 변경하고 rimraf를 제거
  • tsdown.config.ts를 추가해 entry 2개(index, fetch) / ESM / dts / sourcemap / clean 옵션을 설정
  • pnpm-lock.yamltsdown 및 하위 의존성을 반영

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
pnpm-lock.yaml tsdown 도입에 따른 신규 의존성(rolldown, dts 플러그인 등) lock 반영 및 rimraf 제거
packages/ogpeek/tsdown.config.ts ogpeek 번들링/타입 산출을 위한 tsdown 설정 파일 신설
packages/ogpeek/package.json buildtsdown으로 전환하고 devDependencies 갱신
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/ogpeek/package.json:55

  • build no longer runs TypeScript typechecking (it just bundles). Any downstream scripts that relied on pnpm -F ogpeek build to fail on type errors (e.g. website's typecheck which calls ogpeek build) will stop catching ogpeek type regressions. Consider either (a) updating those callers to run ogpeek typecheck explicitly, or (b) making build run typecheck and introducing a separate bundle/build:fast script for tsdown-only bundling.
    "build": "tsdown",
    "prepack": "pnpm run build",
    "test": "vitest run",
    "test:watch": "vitest",
    "typecheck": "tsc --noEmit"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"scripts": {
"build": "rimraf dist && tsc -p .",
"build": "tsdown",
"prepack": "pnpm run build",

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepack currently runs only build, but build no longer typechecks. That means pnpm pack/pnpm publish could produce tarballs even when there are TypeScript errors. Suggest including typecheck in prepack (or adding a dedicated prepack/release script that runs typecheck + tests + build).

Suggested change
"prepack": "pnpm run build",
"prepack": "pnpm run typecheck && pnpm run test && pnpm run build",

Copilot uses AI. Check for mistakes.
build에 tsc --noEmit을 선행시켜 website의 build 체인과 npm prepack 경로
양쪽에서 ogpeek 타입 회귀를 다시 잡도록 복구한다.

https://claude.ai/code/session_01Y9ikfab6CoTdXf9i64Fe61
@minjun0219 minjun0219 changed the title ogpeek 빌드 도구를 tsc → tsdown으로 전환 Switch ogpeek build tool from tsc to tsdown Apr 26, 2026
@minjun0219 minjun0219 changed the title Switch ogpeek build tool from tsc to tsdown build: switch ogpeek from tsc to tsdown Apr 26, 2026
@minjun0219 minjun0219 marked this pull request as draft April 29, 2026 01:26
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.

3 participants