Skip to content

Commit 6cc0d95

Browse files
feat(build)!: migrate to Bun and add standalone binary compilation
BREAKING CHANGES: - Package is now ESM-only (removed CommonJS builds) - Development requires Bun 1.2+ instead of pnpm - Node.js 22+ still supported for runtime consumption Features: - Add standalone binary compilation with Bun's --compile flag - Support for linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64 - Baseline and modern CPU variants (Haswell/AVX2+) - New GitHub workflow for automated binary builds on releases - Binary build script with cross-platform support - Maintain Node.js compatibility with runtime detection for Bun.CryptoHasher Build System: - Replace tsup with Bun.build() for faster builds (~0.6s vs 1.5s) - Simplify package exports to ESM default only - Update all 30+ benchmark scripts to use Bun - Remove pnpm workspace configuration CI/CD: - Update all GitHub workflows to use Bun - Add build-binaries.yml workflow with artifact publishing - Use SHA-pinned GitHub Actions for security - Configure proper permissions and credential handling Development: - Replace pnpm scripts with Bun equivalents - Update Husky hooks for Bun compatibility - Simplify build configuration with fewer dependencies - Maintain compatibility with Node.js 22+ runtime
1 parent 2cf89e7 commit 6cc0d95

47 files changed

Lines changed: 1569 additions & 4045 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/migrate-to-bun.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
"h2m-parser": major
3+
---
4+
5+
**BREAKING CHANGES:** Migrate to Bun and add standalone binary compilation
6+
7+
This release introduces significant infrastructure changes:
8+
9+
- **ESM-only package**: Removed CommonJS builds. The package now exports only ESM format.
10+
- **Bun development requirement**: Development now requires Bun 1.2+ instead of pnpm.
11+
- **Node.js runtime compatibility maintained**: Runtime consumption still supports Node.js 22+.
12+
13+
**New Features:**
14+
- Standalone binary compilation using Bun's `--compile` flag
15+
- Cross-platform support: linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64
16+
- Baseline and modern CPU variants (Haswell/AVX2+)
17+
- Automated GitHub workflow for binary builds on releases
18+
- Runtime detection for Bun.CryptoHasher with Node.js fallback for hash computation
19+
20+
**Build System:**
21+
- Replaced tsup with Bun.build() for faster builds (~0.6s vs 1.5s)
22+
- Simplified package exports to ESM default only
23+
- Updated all 30+ benchmark scripts to use Bun
24+
- Removed pnpm workspace configuration
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build Binaries
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
ref:
9+
description: 'Git ref (tag or branch) to build from'
10+
required: false
11+
default: ''
12+
13+
concurrency:
14+
group: build-binaries-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
permissions:
18+
contents: read
19+
20+
env:
21+
OUTDIR: dist/bin
22+
23+
jobs:
24+
build:
25+
name: Build Bun binaries
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
with:
33+
persist-credentials: false
34+
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.ref || github.ref }}
35+
36+
- name: Setup Bun
37+
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
38+
with:
39+
bun-version: latest
40+
41+
- name: Install dependencies
42+
run: bun install --frozen-lockfile
43+
44+
- name: Verify project
45+
run: bun run verify
46+
47+
- name: Build baseline binaries
48+
run: bun run build:binary --all --outdir "$OUTDIR"
49+
50+
- name: Build modern binaries
51+
run: bun run build:binary --all --modern --outdir "$OUTDIR"
52+
53+
- name: Generate checksums
54+
run: |
55+
cd "$OUTDIR"
56+
sha256sum h2m-* > SHA256SUMS
57+
58+
- name: Upload artifacts
59+
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
60+
with:
61+
name: h2m-binaries-${{ github.run_id }}
62+
path: ${{ env.OUTDIR }}/*
63+
if-no-files-found: error
64+
65+
publish:
66+
name: Attach release assets
67+
runs-on: ubuntu-latest
68+
if: github.event_name == 'release'
69+
needs: build
70+
permissions:
71+
contents: write
72+
steps:
73+
- name: Download artifacts
74+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
75+
with:
76+
name: h2m-binaries-${{ github.run_id }}
77+
path: ${{ env.OUTDIR }}
78+
79+
- name: List artifacts
80+
run: ls -R $OUTDIR
81+
82+
- name: Publish to GitHub Release
83+
uses: softprops/action-gh-release@62c96d0c4e8a889135c1f3a25910db8dbe0e85f7 # v2.3.4
84+
with:
85+
files: ${{ env.OUTDIR }}/*
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/performance-regression.yml

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
paths:
1010
- 'src/**'
1111
- 'package.json'
12-
- 'pnpm-lock.yaml'
12+
- 'bun.lock'
1313
push:
1414
branches:
1515
- main
@@ -32,21 +32,16 @@ jobs:
3232
persist-credentials: false
3333
lfs: true
3434

35-
- name: Setup pnpm
36-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
35+
- name: Setup Bun
36+
uses: oven-sh/setup-bun@v2
3737
with:
38-
run_install: false
39-
40-
- name: Setup Node.js
41-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
42-
with:
43-
node-version: '24'
38+
bun-version: latest
4439

4540
- name: Install dependencies
46-
run: pnpm install --frozen-lockfile
41+
run: bun install --frozen-lockfile
4742

4843
- name: Build project
49-
run: pnpm build
44+
run: bun build
5045

5146
- name: Restore main baseline
5247
run: |
@@ -136,21 +131,16 @@ jobs:
136131
fetch-depth: 0
137132
lfs: true
138133

139-
- name: Setup pnpm
140-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
141-
with:
142-
run_install: false
143-
144-
- name: Setup Node.js
145-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
134+
- name: Setup Bun
135+
uses: oven-sh/setup-bun@v2
146136
with:
147-
node-version: '24'
137+
bun-version: latest
148138

149139
- name: Install dependencies
150-
run: pnpm install --frozen-lockfile
140+
run: bun install --frozen-lockfile
151141

152142
- name: Build project
153-
run: pnpm build
143+
run: bun build
154144

155145
- name: Capture baseline
156146
run: node bench/capture-baseline.js

.github/workflows/release.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,34 @@ jobs:
2727
fetch-depth: 0 # Fetch all history for changesets
2828
persist-credentials: false
2929

30-
- name: Setup pnpm
31-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
30+
- name: Setup Bun
31+
uses: oven-sh/setup-bun@v2
32+
with:
33+
bun-version: latest
3234

3335
- name: Setup Node.js
3436
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5.0.0
3537
with:
3638
node-version: 24
37-
cache: 'pnpm'
3839
registry-url: 'https://registry.npmjs.org'
3940
always-auth: true
4041

4142
- name: Install dependencies
42-
run: pnpm install --frozen-lockfile
43+
run: bun install --frozen-lockfile
4344

4445
- name: Verify build
4546
run: |
46-
pnpm lint
47-
pnpm typecheck
48-
pnpm test
49-
pnpm build
47+
bun lint
48+
bun typecheck
49+
bun test
50+
bun build
5051
5152
- name: Create Release Pull Request or Publish
5253
id: changesets
5354
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba #v1.5.3
5455
with:
55-
publish: pnpm changeset publish
56-
version: pnpm changeset version
56+
publish: bun changeset publish
57+
version: bun changeset version
5758
commit: 'chore(release): version packages'
5859
title: 'chore(release): version packages'
5960
createGithubReleases: true

.github/workflows/test.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,22 @@ jobs:
2929
persist-credentials: false
3030
lfs: true
3131

32-
- name: Setup pnpm
33-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
34-
35-
- name: Setup Node.js ${{ matrix.node }}
36-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5.0.0
32+
- name: Setup Bun
33+
uses: oven-sh/setup-bun@v2
3734
with:
38-
node-version: ${{ matrix.node }}
39-
cache: 'pnpm'
35+
bun-version: latest
4036

4137
- name: Install dependencies
42-
run: pnpm install --frozen-lockfile
38+
run: bun install --frozen-lockfile
4339

4440
- name: Lint
45-
run: pnpm lint
41+
run: bun lint
4642

4743
- name: Type check
48-
run: pnpm typecheck
44+
run: bun typecheck
4945

5046
- name: Test
51-
run: pnpm test
47+
run: bun test
5248

5349
- name: Build
54-
run: pnpm build
50+
run: bun build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules
22
.DS_Store
33
dist
4+
dist/bin
45
coverage
56
bench/output
67
bench/artifacts/

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pnpm lint-staged
1+
bun lint-staged

0 commit comments

Comments
 (0)