denoland/deno
JSR support
Active contributors: David Sherret, Luca Casonato, Bartek Iwańczuk
Purpose
JSR (the JavaScript Registry, https://jsr.io) is Deno's modern open-source package registry. It's TypeScript-first, immutable, designed for ESM, and integrates with the Deno toolchain end-to-end (deno publish, jsr: specifiers, deno add jsr:@scope/pkg).
Inside the codebase, JSR shows up in cli/jsr.rs, libs/resolver, the cli/lsp/jsr.rs (for editor completions), and the deno publish subcommand under cli/tools/publish/.
Specifier shape
jsr:@scope/package
jsr:@scope/package@1.2.3
jsr:@scope/package@^1
jsr:@scope/package/sub/pathResolution:
- Hit the JSR meta endpoint for
@scope/packageto get the available versions and their export maps. - Pick the version that satisfies the constraint.
- Use the export map to translate
jsr:@scope/package/sub/pathinto a concrete file URL on JSR's CDN. - Fetch the file, transpile if needed (JSR-published packages often ship
.ts). - Record in
deno.lock.
Where the code lives
| Concern | File |
|---|---|
| Specifier parsing + JSR meta fetching | cli/jsr.rs |
| Resolution glue with the rest of the graph | libs/resolver/jsr.rs (in the deno_resolver crate) |
| LSP completions for JSR specifiers | cli/lsp/jsr.rs, cli/lsp/registries.rs |
| Lockfile entries for JSR | libs/lockfile/ |
deno publish |
cli/tools/publish/ |
Workflow
sequenceDiagram
participant User
participant CLI as deno CLI
participant Resolver as libs/resolver
participant Jsr as jsr.io
participant Lock as deno.lock
User->>CLI: deno add jsr:@std/path
CLI->>Jsr: GET /@std/path/meta.json
Jsr-->>CLI: { latest, versions[] }
CLI->>Lock: write @std/path entry
CLI->>User: edits deno.json `imports`
User->>CLI: deno run main.ts (which imports "@std/path")
CLI->>Resolver: resolve "@std/path"
Resolver->>Lock: pinned version?
Lock-->>Resolver: 1.0.0
Resolver->>Jsr: GET /@std/path/1.0.0_meta.json (export map)
Resolver->>Jsr: GET /@std/path/1.0.0/path.ts
Jsr-->>Resolver: source
Resolver-->>CLI: ModuleSourceSubsequent runs short-circuit through the lockfile + on-disk cache (DENO_DIR/deps/jsr.io/...).
Publishing (deno publish)
The deno publish subcommand:
- Reads
deno.jsonname/version/exports. - Validates the package: scope is owned, no slow types (TypeScript that can't be auto-typed), no unmapped imports.
- Builds a tarball.
- Uploads to JSR via OAuth-flow authentication (browser-based device flow).
The validation step is strict — JSR's value proposition includes auto-generated documentation and types, which require certain coding patterns. Errors are surfaced from deno_doc (a workspace dep) and from the publish-flow code.
Lockfile
JSR entries in deno.lock look similar to npm entries: package name, resolved version, integrity hash. Because JSR is immutable (a published version's contents never change) integrity violations are rare and indicate a tampered lockfile rather than a registry inconsistency.
LSP integration
cli/lsp/jsr.rs powers auto-completion of jsr:@ specifiers in the editor: typing import "jsr:@" → suggestion list of scopes you've used recently → expand to package suggestions → expand to version suggestions. Cached in cli/lsp/registries.rs` to avoid hammering the registry on every keystroke.
Workspace + JSR
A workspace deno.json can have multiple JSR-publishable packages. libs/config/workspace/mod.rs (6,815 lines) handles this — each workspace member can have its own name/version/exports, and deno publish can publish all of them in one go.
Entry points for modification
- Specifier parsing or registry endpoint shape —
cli/jsr.rs. - Resolution semantics —
libs/resolver/(look for the JSR-specific module). - Publish flow —
cli/tools/publish/. - LSP completions —
cli/lsp/jsr.rs+cli/lsp/registries.rs.
Key source files
| File | Purpose |
|---|---|
cli/jsr.rs |
JSR client used by the runtime/CLI module loader |
cli/lsp/jsr.rs |
LSP-specific JSR helpers |
cli/lsp/registries.rs |
npm + jsr metadata cache for editor completions |
cli/tools/publish/ |
deno publish implementation |
libs/resolver/ |
Includes JSR resolution as part of the unified resolver |
libs/lockfile/ |
Reads/writes JSR entries in deno.lock |
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.