Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workerd:compatibility-flags internal built-in module #326

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jan 28, 2023

For use only by built-in TypeScript modules, this provides an import that gives information on the currently set compatibility flags.

e.g.

import { default as flags } from 'worker:compatibility-flags';
console.log(flags.nodeJsCompat); // true|false

The flags are set as readonly booleans on the export.

Note that this does introduce an issue if we rename any of the compatibility flags. Right now renaming will cause a compile error in the native code because the getWhatever method names will change. However, we won't get errors during compile for the typescript side unless we also someone automatically generate a ts.d for this built-in from the capnp definitions.

@jasnell jasnell requested review from mikea and kentonv January 28, 2023 00:50
src/workerd/api/node/node.h Outdated Show resolved Hide resolved
src/workerd/jsg/resource.h Outdated Show resolved Hide resolved
@kentonv
Copy link
Member

kentonv commented Feb 1, 2023

Looks good but needs squash. (I'm paranoid about accidentally merging fixups after it has happened a couple times. FWIW given the "view changes" button it's OK to not push fixups but instead just force-push a rewrite, as long as you don't rebase on main in the same push.)

Copy link
Contributor

@mikea mikea left a comment

Choose a reason for hiding this comment

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

nice

@jasnell jasnell force-pushed the jsnell/internal-compatibilityflags-module branch from 751d2b4 to 5030acc Compare February 2, 2023 22:00
For use only by built-in TypeScript modules, this provides an import
that gives information on the currently set compatibility flags.

e.g.

```
import { default as flags } from 'worker:compatibility-flags';
console.log(flags.nodeJsCompat); // true|false
```

The flags are set as readonly booleans on the export.
@jasnell jasnell force-pushed the jsnell/internal-compatibilityflags-module branch from 5030acc to fa00599 Compare February 2, 2023 22:01
@jasnell jasnell merged commit 42d45ba into main Feb 2, 2023
@jasnell jasnell deleted the jsnell/internal-compatibilityflags-module branch February 2, 2023 22:42
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