Lesson 3 of 9 · 23m
The Standard Library and the Built-In Toolchain
Use Deno's standard library, task runner, formatter, linter, test runner, and cache model to reduce dependency surface without pretending batteries are free.
The pitch for Deno's standard library is not that it contains everything. It is that common primitives are curated enough that you do not need a random package with twelve transitive dependencies to parse flags, serve HTTP, compare paths, or write tests. The win is fewer trust decisions and less dependency churn. The trap is assuming "standard" means frozen forever.
Standard library means curated modules
Typical usage is intentionally boring:
import { serve } from "jsr:@std/http/server";
import { join } from "jsr:@std/path";
import { parseArgs } from "jsr:@std/cli/parse-args";
serve((req) => new Response(join("/srv", new URL(req.url).pathname)));JSR versions matter. Pin them in deno.json, review upgrades, and read release notes. A standard library still evolves; it just evolves with a clearer compatibility contract than a pile of unrelated packages.
The integrated toolchain changes team behavior
One installation gives you:
deno fmt --check
deno lint
deno check main.ts
deno test --allow-read=test/fixtures
deno task devThe practical effect is cultural. Formatting arguments disappear. Lint is versioned with the runtime. Tests do not need a second runner configuration. Junior engineers can clone the repo and execute the same commands senior engineers use in CI.
The cache is part of the artifact supply chain
Deno downloads remote dependencies into a content-addressed cache. Key commands:
deno info main.ts
deno cache --lock=deno.lock main.ts
deno vendor main.tsdeno.lock records integrity data. --frozen or checked lockfiles prevent surprise updates in CI and production. Vendoring can help offline or highly controlled environments, but it creates repository noise and update procedures you must actually follow.
HTTP is simple until production
Deno's native HTTP server is excellent for small services and workers:
Deno.serve({ port: 8080 }, async (req) => {
if (new URL(req.url).pathname === "/healthz") {
return new Response("ok", { headers: { "content-type": "text/plain" } });
}
return new Response("not found", { status: 404 });
});Simple does not mean operationally complete. You still own graceful shutdown, request timeouts, body size limits, structured logging, metrics, and reverse-proxy behavior. The runtime will not save you from application design.
Field notes
- Pin JSR versions; "standard" does not mean versionless.
- Commit
deno.lockfor applications. Libraries can make different tradeoffs, but applications need reproducibility. deno vendoris a supply-chain tool, not a substitute for dependency review.- Built-in tooling reduces packages, not responsibility. Timeouts and resource limits are still yours.
- Standard library modules are composable, but they are not a framework. Do not expect routing, validation, auth, and observability to appear by osmosis.
Was this lesson helpful?