A Cloudflare Workers-native fork of isomorphic-git
npm install @ashishkumar472/cf-gitA Cloudflare Workers-native fork of isomorphic-git, ported to work with the Cloudflare Workers runtime.


- SHA-1 Hashing: Uses crypto.subtle.digestSync() (Workers-specific synchronous crypto API)
- No CommonJS Dependencies: Removed sha.js, async-lock, and path-browserify
- Pure ESM: All modules are ES modules with no CommonJS fallbacks
#### src/utils/shasum.js
- Replaced sha.js with native crypto.subtle.digestSync()
- Falls back to async crypto.subtle.digest() if needed
- Workers-only: No Node.js crypto support
#### src/utils/join.js
- Replaced path-browserify with simple string-based path joining
- Sufficient for git operations which always use forward slashes
#### src/utils/AsyncLock.js
- Replaced async-lock with queue-based implementation
Tests run in actual Cloudflare Workers runtime using @cloudflare/vitest-pool-workers:
``bashRun Workers-specific tests
npm run test:workers
Why This Fork?
The original
isomorphic-git uses CommonJS modules (require()) which don't work in Cloudflare Workers' ESM-only environment. Instead of using polyfills, we modified the source to use native Workers APIs directly, resulting in:- Faster performance - Native crypto is faster than polyfills
- Smaller bundle - Fewer dependencies
- No build issues - No CommonJS transformation needed
- Type-safe - Proper Workers types
- Tested - Tests run in actual Workers runtime
Development
`bash
Install dependencies
npm install --legacy-peer-depsBuild
npm run buildTest in Workers environment
npm run test:workersFormat code
npm run format
`Installation
`bash
npm install @ashishkumar472/cf-git
or
bun add @ashishkumar472/cf-git
`Usage
`javascript
import git from '@ashishkumar472/cf-git'
import http from '@ashishkumar472/cf-git/http/web'// All isomorphic-git APIs work the same way
await git.clone({
fs,
http,
dir: '/repo',
url: 'https://github.com/owner/repo',
})
``Works with:
- Cloudflare Workers
- Cloudflare Pages Functions
- Miniflare (local development)
- Vitest with Workers pool
Does NOT work with:
- Node.js (use original isomorphic-git)
- Browser (no digestSync support)
- Other edge runtimes without Workers APIs
MIT (same as original isomorphic-git)
Based on isomorphic-git by William Hilton and contributors.