diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-11-01 23:15:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 23:15:08 +0100 |
commit | 24c3c9695865bb478f5651da4982b7e0a34afc72 (patch) | |
tree | 5afe78a8c67bb9e9c1cd69d56a9a0c68bca67515 /cli/worker.rs | |
parent | 42c426e7695a0037032d1ac5237830800eeaaed4 (diff) |
feat: granular --unstable-* flags (#20968)
This commit adds granular `--unstable-*` flags:
- "--unstable-broadcast-channel"
- "--unstable-ffi"
- "--unstable-fs"
- "--unstable-http"
- "--unstable-kv"
- "--unstable-net"
- "--unstable-worker-options"
- "--unstable-cron"
These flags are meant to replace a "catch-all" flag - "--unstable", that
gives a binary control whether unstable features are enabled or not. The
downside of this flag that allowing eg. Deno KV API also enables the FFI
API (though the latter is still gated with a permission).
These flags can also be specified in `deno.json` file under `unstable`
key.
Currently, "--unstable" flag works the same way - I will open a follow
up PR that will print a warning when using "--unstable" and suggest to use
concrete "--unstable-*" flag instead. We plan to phase out "--unstable"
completely in Deno 2.
Diffstat (limited to 'cli/worker.rs')
-rw-r--r-- | cli/worker.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/cli/worker.rs b/cli/worker.rs index 58bd96642..5022b39f1 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -529,6 +529,16 @@ impl CliMainWorkerFactory { let mut extensions = ops::cli_exts(shared.npm_resolver.clone()); extensions.append(&mut custom_extensions); + // TODO(bartlomieju): this is cruft, update FeatureChecker to spit out + // list of enabled features. + let feature_checker = shared.feature_checker.clone(); + let mut unstable_features = Vec::with_capacity(8); + for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS { + if feature_checker.check(feature_name) { + unstable_features.push(*id); + } + } + let options = WorkerOptions { bootstrap: BootstrapOptions { args: shared.options.argv.clone(), @@ -544,6 +554,7 @@ impl CliMainWorkerFactory { runtime_version: version::deno().to_string(), ts_version: version::TYPESCRIPT.to_string(), unstable: shared.options.unstable, + unstable_features, user_agent: version::get_user_agent().to_string(), inspect: shared.options.is_inspecting, has_node_modules_dir: shared.options.has_node_modules_dir, @@ -580,7 +591,7 @@ impl CliMainWorkerFactory { shared.compiled_wasm_module_store.clone(), ), stdio, - feature_checker: shared.feature_checker.clone(), + feature_checker, }; let worker = MainWorker::bootstrap_from_options( @@ -704,6 +715,16 @@ fn create_web_worker_callback( .join(checksum::gen(&[key.as_bytes()])) }); + // TODO(bartlomieju): this is cruft, update FeatureChecker to spit out + // list of enabled features. + let feature_checker = shared.feature_checker.clone(); + let mut unstable_features = Vec::with_capacity(8); + for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS { + if feature_checker.check(feature_name) { + unstable_features.push(*id); + } + } + let options = WebWorkerOptions { bootstrap: BootstrapOptions { args: shared.options.argv.clone(), @@ -719,6 +740,7 @@ fn create_web_worker_callback( runtime_version: version::deno().to_string(), ts_version: version::TYPESCRIPT.to_string(), unstable: shared.options.unstable, + unstable_features, user_agent: version::get_user_agent().to_string(), inspect: shared.options.is_inspecting, has_node_modules_dir: shared.options.has_node_modules_dir, @@ -752,7 +774,7 @@ fn create_web_worker_callback( ), stdio: stdio.clone(), cache_storage_dir, - feature_checker: shared.feature_checker.clone(), + feature_checker, }; WebWorker::bootstrap_from_options( |