From 7534034055f1f6c4b809d66f7015b2049b090e4b Mon Sep 17 00:00:00 2001 From: Luna <279187109+lunadogbot@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:12:27 +0000 Subject: [PATCH] docs: document `compile.include` / `compile.exclude` in deno.json (2.8) Adds a "Configuring include/exclude in deno.json" subsection to compile.md and a new "Compile config" section to configuration.md covering the new declarative include/exclude lists. Notes that CLI flags merge with the config rather than replacing it. Refs denoland/deno#33024 --- runtime/fundamentals/configuration.md | 22 ++++++++++++++++++++++ runtime/reference/cli/compile.md | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) 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