Skip to content

feat: Codegen feature flags #28920

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

Merged
merged 24 commits into from
Apr 25, 2025
Merged

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Apr 15, 2025

This commit adds "deno_features" crate that contains definitions of all unstable features in Deno.

Based on these definitions, both Rust and JS code is generated ensuring that the two are always
in sync.

In addition some of flag handling was rewritten to use the generated definitions, instead
of hand rolling these flag definitions.

"sloppy-imports",
"lockfile-v5",
])
.chain(["fmt-component", "fmt-sql", "npm-lazy-caching", "npm-patch"])
Copy link
Member Author

Choose a reason for hiding this comment

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

These few were never defined as unstable flags (ie. only available as options to unstable key in deno.jsonc file). We should decide if we want to make them flags.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will address it in a follow up PR

Copy link
Member Author

Choose a reason for hiding this comment

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

We should decide how we're gonna handle them once a feature is promoted to stable - are the flags getting:
a) hidden and have no effect
b) hidden and printing warning
c) removed and crashing previous invocations
d) once promoted an opposite (--no-<name>) flag is added

Copy link
Member

Choose a reason for hiding this comment

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

prefer c because its easiest

@@ -6124,6 +6044,7 @@ fn unstable_args_parse(
flags.unstable_config.legacy_flag_enabled = true;
}

// TODO(bartlomieju): this should be factored out since these are configured via UNSTABLE_GRANULAR_FLAGS
flags.unstable_config.bare_node_builtins =
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like UnstableConfig should be codegened as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Better to do it in a follow up PR

@bartlomieju
Copy link
Member Author

The JSON schema for feature flags (

"examples": [
"broadcast-channel",
"bare-node-builtins",
"byonm",
"cron",
"detect-cjs",
"ffi",
"fs",
"fmt-component",
"fmt-sql",
"http",
"kv",
"net",
"node-globals",
"sloppy-imports",
"temporal",
"unsafe-proto",
"webgpu",
"worker-options"
]
}
},
) should be codegened as well

@bartlomieju bartlomieju added this to the 2.3.0 milestone Apr 22, 2025
Copy link
Member

@crowlKats crowlKats left a comment

Choose a reason for hiding this comment

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

LGTM

@bartlomieju bartlomieju enabled auto-merge (squash) April 25, 2025 06:31
@bartlomieju bartlomieju merged commit 189ccff into denoland:main Apr 25, 2025
17 checks passed
@bartlomieju bartlomieju deleted the unstable_flags_struct branch April 25, 2025 11:05
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.

4 participants