Commit 0d12508
committed
feat(miniflare): add getWorkerdFeatureFlags() for compatibility flag resolution
Add a TypeScript implementation that replicates workerd's C++ compileCompatibilityFlags()
function. This computes which compatibility flags are enabled based on:
- Compatibility date (flags enabled after their compatEnableDate)
- Explicit compatibility flags (enable/disable overrides)
- Implied flags (cascading dependencies between flags)
Files added:
- scripts/build-capnp-compat.mjs: Build script that downloads compatibility-date.capnp
from workerd, compiles it with capnp-es, and extracts annotation metadata
- src/shared/compatibility-date.ts: Cap'n Proto types generated by capnp-es
- src/shared/compatibility-flags-metadata.ts: Extracted annotation metadata
- src/shared/compatibility-flags.ts: Main implementation with getWorkerdFeatureFlags()
- test/shared/compatibility-flags.spec.ts: Test suite
Also updates:
- package.json: Added capnp:compat script
- tsconfig.json: Include the build script for type checking
- GitHub workflow: Auto-regenerate compatibility flags on workerd dependency updates1 parent c808a6f commit 0d12508
File tree
8 files changed
+4060
-2
lines changed- .github/workflows
- packages/miniflare
- scripts
8 files changed
+4060
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
0 commit comments