From db40fee69f94fd6d869c04985c59c47367c4b1cc Mon Sep 17 00:00:00 2001 From: Kevin Whinnery Date: Fri, 22 Dec 2023 17:01:07 -0600 Subject: [PATCH] add full list of flags (#245) --- runtime/manual/tools/unstable_flags.md | 254 ++++++++++++++++--------- 1 file changed, 169 insertions(+), 85 deletions(-) diff --git a/runtime/manual/tools/unstable_flags.md b/runtime/manual/tools/unstable_flags.md index 5685cf1d8..2face4ed1 100644 --- a/runtime/manual/tools/unstable_flags.md +++ b/runtime/manual/tools/unstable_flags.md @@ -9,7 +9,17 @@ help text by running: deno --help ``` -## Configuration in `deno.json` +## Using flags at the command line + +You can enable a feature flag when you run a Deno program from the command line +by passing in the flag as an option to the CLI. Here's an example of running a +program with the `--unstable-workspaces` flag enabled: + +```sh +deno run --unstable-workspaces main.ts +``` + +## Configuring flags in `deno.json` You can specify which unstable features you'd like to enable for your project using a @@ -24,33 +34,23 @@ using a The possible values in the `unstable` array are the flag names with the `--unstable-` prefix removed. -## `--unstable` +## Configuration via environment variables -Before more recent Deno versions (1.38+), unstable APIs were made available all -at once using the `--unstable` flag. Notably, [Deno KV](/kv/manual) and other -cloud primitive APIs are available behind this flag. To run a program with -access to these unstable features, you would run your script with: +Some flags can be enabled by setting a value (any value) for an environment +variable of a given name, rather than being passed as a flag or `deno.json` +configuration option. Flags that are settable via environment variables will be +noted below. -```sh -deno run --unstable your_script.ts -``` - -In the future, we will use more granular feature flags to enable specific APIs, -as described below. Most features behind the older `--unstable` flag now also -have their own granular feature flag. - -## `--unstable-bare-node-builtins` - -:::info Enable via environment variable - -This feature flag can also be enabled by setting any value for the following +Here's an example of setting the `--unstable-bare-node-builtins` flag via environment variable: ```sh export DENO_UNSTABLE_BARE_NODE_BUILTINS=true ``` -::: +## `--unstable-bare-node-builtins` + +**Environment variable:** `DENO_UNSTABLE_BARE_NODE_BUILTINS` This flag enables you to [import Node.js built-in modules](../node/node_specifiers.md) without a `node:` @@ -64,24 +64,9 @@ import { readFileSync } from "fs"; console.log(readFileSync("deno.json", { encoding: "utf8" })); ``` -Use the feature flag when executing a script to enable this behavior. - -```sh -deno run -A --unstable-bare-node-builtins ./example.ts -``` - ## `--unstable-byonm` -:::info Enable via environment variable - -This feature flag can also be enabled by setting any value for the following -environment variable: - -```sh -export DENO_UNSTABLE_BYONM=true -``` - -::: +**Environment variable:** `DENO_UNSTABLE_BYONM` This feature flag enables support for resolving modules from a local `node_modules` folder that you manage outside of Deno with @@ -120,24 +105,9 @@ console.log(cowsay.say({ })); ``` -Use the feature flag when executing a script to enable this behavior. - -```sh -deno run -A --unstable-byonm ./example.ts -``` - ## `--unstable-sloppy-imports` -:::info Enable via environment variable - -This feature flag can also be enabled by setting any value for the following -environment variable: - -```sh -export DENO_UNSTABLE_SLOPPY_IMPORTS=true -``` - -::: +**Environment variable:** `DENO_UNSTABLE_SLOPPY_IMPORTS` This flag enables behavior which will infer file extensions from imports that do not include them. Normally, the import statement below would produce an error: @@ -154,10 +124,6 @@ export const Example = "Example"; Executing the script with sloppy imports enabled will remove the error, but provide guidance that a more performant syntax should be used. -```sh -deno run --unstable-sloppy-imports foo.ts -``` - Sloppy imports will allow (but print warnings for) the following: - Omit file extensions from imports @@ -176,49 +142,167 @@ This flag enables this property. Note that it is not recommended to use this, but if you really need to use a package that relies on it, the escape hatch is now available to you. - +No new features will be exposed using this method, and it will be removed in a +future release.