Deno
The Deno module gives Deno code one shared way to test, lint, format, and
type-check. Each deno.json or deno.jsonc is a standalone project or a Deno
workspace, and the module exposes each kind as a collection, so a check can run
one project, one workspace, or everything. The same checks run locally, in CI,
and in Dagger Cloud.
Add it to your workspace
dagger module install dagger.io/js/deno
Run the checks
| Check | What it runs |
|---|---|
deno/projects/test, deno/workspaces/test | deno test |
deno/projects/lint, deno/workspaces/lint | deno lint |
deno/projects/type-check, deno/workspaces/type-check | deno check |
deno/projects/format-check, deno/workspaces/format-check | deno fmt --check |
deno/projects/format/stale, deno/workspaces/format/stale | Fails when deno fmt would change a file |
dagger check --deno # every Deno check
dagger check --deno --check=test # deno test everywhere
dagger check --deno-project=apps/api # every check for one project
dagger check --deno-workspace=. --check=lint # deno lint for one workspace
A check over several projects or workspaces reports every one that fails.
Projects and workspaces
| Flag | Collection | Key |
|---|---|---|
--deno-project | projects | Directory holding a standalone project's config, relative to the workspace root. The root is . |
--deno-workspace | workspaces | Directory holding a Deno workspace's config, relative to the workspace root |
List the keys with dagger list deno-projects -a and dagger list deno-workspaces -a. Select collection items describes how to select items.
Every directory holding deno.json or deno.jsonc at or below the directory
dagger runs from is found, plus the nearest one that encloses it. A config
with a non-empty workspace array is a Deno workspace. Its members are checked
through the workspace and are not keys of their own. Every other config is a
standalone project. When dagger runs from inside a member, that member is a
project, and its commands run from the workspace root, scoped to the member.
Format the source
format-check only reports whether files are formatted; the format
generator rewrites them and returns a changeset. Dagger prints the diff and
asks before writing. Add -y to apply it without prompting:
dagger generate --deno # preview the diff
dagger generate -y --deno-project=apps/api # apply it for one project
Compile a binary
compile builds a standalone executable from an entrypoint (default main.ts)
and returns it as a file to export. It is named app unless outputName says
otherwise:
dagger api call deno project --path . \
compile --entrypoint main.ts --target x86_64-unknown-linux-gnu \
export --path ./bin/app
project returns the project that contains a path, and workspace returns the
Deno workspace that contains one.
Configure it
List the current settings with dagger module settings deno, then change one with
dagger module settings deno <key> <value>. They live in dagger.toml under
[modules.deno.settings]:
version(default2.9.3) is the Deno version of the default base image,denoland/deno:alpine-<version>. Pin this so every project is tested, linted, and formatted against the same Deno release.baseis the base container Deno runs in (for exampledocker.io/denoland/deno:debian). It must havedenoon itsPATH. Withbaseset,versionstill decides how permissions are passed, so set it to the releasebasecarries.permissions(defaultconfig) sets the permissionstestandcompilerun with.configuses the permission sets indeno.json(-P),allgrants everything (-A), andnonegrants nothing. With aversionbefore 2.5.0,configmakestestuse-A.testArgs(default empty) are extradeno testflags, such as["--doc", "--parallel"].typeCheckArgs(default empty) are extradeno checkflags, such as["--allow-import"].typeCheckTargets(default["."]) are whattype-checkchecks, relative to each project or workspace root, such as["mod.ts"]. The config'sexcludestill applies.
# Pin the Deno version for the whole workspace
dagger module settings deno version 2.9.3
[modules.deno.settings]
version = "2.9.3"
permissions = "all"
testArgs = ["--parallel"]
Working with other modules
Reach for this module whenever the repo contains one or more Deno projects,
especially when they should share the same Deno version and CI checks. The
base field and the install function expose a Deno-ready container you can
hand to other modules, and version prints the configured toolchain version.