Skip to content

feat: Add tsdown build setup with TypeScript support#165

Draft
akash-joshi wants to merge 3 commits intoharfbuzz:mainfrom
akash-joshi:feat/tsdown-setup
Draft

feat: Add tsdown build setup with TypeScript support#165
akash-joshi wants to merge 3 commits intoharfbuzz:mainfrom
akash-joshi:feat/tsdown-setup

Conversation

@akash-joshi
Copy link

@akash-joshi akash-joshi commented Feb 5, 2026

Hi folks, this PR adds tsdown build tooling with WebAssembly support, enabling TypeScript development for harfbuzzjs. This addresses the discussion in #99 about modernising the TypeScript setup.

This was based on @lianghai 's comment on the Svelte London chat. I wanted to create a rough draft of what a tsdown-based setup could look like.


AI Generated Summary Below

  • Add tsdown configuration with rolldown-plugin-wasm for WASM support
  • Add TypeScript configuration and type definitions for hbjs.js and hb.js
  • Add TypeScript entry point (src/index.ts) that re-exports types
  • Update package.json with dual ESM/CJS exports and build scripts
  • Bundle outputs to dist/ with generated .d.ts declaration files

Changes

New files

  • tsdown.config.ts - Build config with WASM plugin
  • tsconfig.json - TypeScript compiler configuration
  • src/index.ts - TypeScript entry point
  • src/types.d.ts - Type definitions (HBHandle, HBFont, HBBuffer, etc.)
  • hbjs.d.ts - Sidecar type declarations for hbjs.js
  • hb.d.ts - Sidecar type declarations for hb.js

Modified files

  • package.json - Added build scripts, exports field, and dev dependencies
  • .gitignore - Added dist/

Build output

dist/
├── index.cjs      (58.5 kB) - CommonJS bundle
├── index.mjs      (58.7 kB) - ESM bundle
├── index.d.cts    - CJS type declarations
├── index.d.mts    - ESM type declarations
└── hb.wasm        - Copied WASM binary

Test plan

  • TypeScript compiles without errors (npx tsc --noEmit)
  • Build succeeds (npm run build:ts)
  • All 68 tests pass (npx mocha test/index.js)

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

Comments