diff --git a/runtime/fundamentals/configuration.md b/runtime/fundamentals/configuration.md index 679a48c22..3f6ffa382 100644 --- a/runtime/fundamentals/configuration.md +++ b/runtime/fundamentals/configuration.md @@ -738,6 +738,28 @@ this requires an explicit opt-in with `-P` and is not loaded by default. If you're ok with this risk, then this feature will be useful for you. +## Compile config + +The `"compile"` block configures +[`deno compile`](/runtime/reference/cli/compile/) without requiring you to +repeat flags on every invocation. Starting in Deno 2.8 you can declare which +extra files or directories to bundle into the executable, and which paths to +exclude: + +```jsonc title="deno.json" +{ + "compile": { + "include": ["names.csv", "data", "worker.ts"], + "exclude": ["data/secrets", "**/*.test.ts"] + } +} +``` + +`--include` and `--exclude` flags on the command line are merged with these +lists rather than replacing them. The `"compile"` block can also carry +`permissions` (see +[Test, bench, and compile permissions](#test-bench-and-compile-permissions)). + ## An example `deno.json` file ```json diff --git a/runtime/reference/cli/compile.md b/runtime/reference/cli/compile.md index 4a164615d..96b0e83fa 100644 --- a/runtime/reference/cli/compile.md +++ b/runtime/reference/cli/compile.md @@ -114,6 +114,24 @@ const dataFiles = Deno.readDirSync(import.meta.dirname + "/data"); Note this currently only works for files on the file system and not remote files. +### Configuring `include` / `exclude` in `deno.json` + +Starting in Deno 2.8, the `--include` and `--exclude` paths can be set +declaratively in `deno.json` so you don't have to repeat them on every +`deno compile` invocation: + +```jsonc title="deno.json" +{ + "compile": { + "include": ["names.csv", "data", "worker.ts"], + "exclude": ["data/secrets", "**/*.test.ts"] + } +} +``` + +CLI flags are merged with the config — `--include` and `--exclude` add to the +lists in `deno.json` rather than replacing them. + ## Workers Similarly to non-statically analyzable dynamic imports, code for