Skip to content

Replace the obsolete internal compat flags module#4630

Merged
jasnell merged 1 commit intomainfrom
jasnell/use-global-compat-flags
Jul 30, 2025
Merged

Replace the obsolete internal compat flags module#4630
jasnell merged 1 commit intomainfrom
jasnell/use-global-compat-flags

Conversation

@jasnell
Copy link
Collaborator

@jasnell jasnell commented Jul 29, 2025

Use the globalThis.Cloudflare instead.

As a follow-up todo for later, we should look at automatically generating types from the compat flag definitions so that globalThis.Cloudflare can be more than just a Record<string, boolean | undefined> /cc @penalosa

@jasnell jasnell requested review from a team as code owners July 29, 2025 02:06
@jasnell jasnell requested a review from a team July 29, 2025 02:06
@jasnell jasnell requested a review from a team as a code owner July 29, 2025 02:06
@jasnell jasnell requested a review from a team July 29, 2025 02:07
@anonrig

This comment was marked as outdated.

@jasnell

This comment was marked as outdated.

@jasnell

This comment was marked as outdated.

@anonrig

This comment was marked as outdated.

@jasnell jasnell changed the title Replace the obsolute internal compat flags module Replace the obsolete internal compat flags module Jul 29, 2025
@jasnell jasnell force-pushed the jasnell/use-global-compat-flags branch from d1a6a85 to a7e4f36 Compare July 29, 2025 03:21
Use the globalThis.Cloudflare instead.
@jasnell jasnell force-pushed the jasnell/use-global-compat-flags branch from 33d1482 to d11efc3 Compare July 29, 2025 03:53
@@ -0,0 +1,3 @@
declare namespace Cloudflare {
const compatibilityFlags: Record<string, boolean>;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@penalosa ... it should be possible to generate this directly from the compat flags capnp definitions, both for internal and external use. If you can help guide I can do the work ;-)

the structure is simple...

declare namespace Cloudflare {
  const compatibilityFlags: {
    readonly foo: boolean,
    //...
  };
}

Where there is one readonly foo: boolean entry for every enable flag in the capnp.

Copy link
Member

Choose a reason for hiding this comment

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

What about adding a js script, that uses capnp-es, to tools folder that updates flags.d.TS and we import that file in here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah something like that should work. I don't think it's worth blocking on it tho. This is something we can incrementally improve on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Going to mark this resolved so I can merge but will unresolve it after so we don't forget ;-)

@jasnell jasnell requested review from a team and anonrig July 30, 2025 17:48
@jasnell jasnell merged commit 3548d09 into main Jul 30, 2025
21 of 22 checks passed
@jasnell jasnell deleted the jasnell/use-global-compat-flags branch July 30, 2025 19:11
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.

3 participants