Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

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 updates

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

…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 updates
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

⚠️ No Changeset found

Latest commit: 0d12508

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 14, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11919

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11919

miniflare

npm i https://pkg.pr.new/miniflare@11919

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11919

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11919

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11919

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11919

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11919

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11919

wrangler

npm i https://pkg.pr.new/wrangler@11919

commit: 0d12508

};

/**
* Parses a compatibility date string (YYYY-MM-DD) into a comparable integer.
Copy link
Contributor

Choose a reason for hiding this comment

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

YYYY-MM-DD is a comparable string, do we need to parse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants