Skip to content

Commit a46b069

Browse files
bartlomiejuclaudethisisjofrank
authored
docs: compile --self-extracting, upgrade caching, jsr/overrides in package.json (#2954)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Jo Franchetti <jofranchetti@gmail.com>
1 parent 653451c commit a46b069

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

runtime/fundamentals/modules.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,45 @@ When using a `package.json` file, dev dependencies can be added to the separate
563563
}
564564
```
565565

566+
### JSR packages in package.json
567+
568+
You can depend on JSR packages directly from `package.json` using the `jsr:`
569+
scheme, without needing a separate `deno.json`:
570+
571+
```json title="package.json"
572+
{
573+
"dependencies": {
574+
"@std/path": "jsr:^1.0.9"
575+
}
576+
}
577+
```
578+
579+
This works with `deno install` and brings JSR packages to any project that uses
580+
`package.json` for dependency management.
581+
582+
### Dependency overrides
583+
584+
The `overrides` field in `package.json` lets you control transitive dependency
585+
versions throughout your dependency tree. This is useful for applying security
586+
patches, fixing version compatibility issues, or replacing packages:
587+
588+
```json title="package.json"
589+
{
590+
"dependencies": {
591+
"express": "^4.18.0"
592+
},
593+
"overrides": {
594+
"cookie": "0.7.0",
595+
"express": {
596+
"qs": "6.13.0"
597+
}
598+
}
599+
}
600+
```
601+
602+
In this example, `cookie` is pinned globally to `0.7.0`, while `qs` is
603+
overridden only when required by `express`.
604+
566605
### Why does Deno not have a `devImports` field?
567606

568607
To understand why Deno does not separate out dev dependencies in the package

runtime/reference/cli/compile.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,43 @@ import "./worker.ts";
136136
deno compile main.ts
137137
```
138138

139+
## Self-Extracting Executables
140+
141+
By default, compiled executables serve embedded files from an in-memory virtual
142+
file system. The `--self-extracting` flag changes this behavior so that the
143+
binary extracts all embedded files to disk on first run and uses real file
144+
system operations at runtime.
145+
146+
```shell
147+
deno compile --self-extracting main.ts
148+
```
149+
150+
This is useful for scenarios where code needs real files on disk, such as native
151+
addons or native code that reads relative files.
152+
153+
The extraction directory is chosen in order of preference:
154+
155+
1. `<exe_dir>/<exe_name>.fs/<hash>/` (next to the compiled binary)
156+
2. Platform data directory fallback:
157+
- Linux: `$XDG_DATA_HOME/<exe_name>/<hash>` or
158+
`~/.local/share/<exe_name>/<hash>`
159+
- macOS: `~/Library/Application Support/<exe_name>/<hash>`
160+
- Windows: `%LOCALAPPDATA%\<exe_name>\<hash>`
161+
162+
Files are only extracted once — subsequent runs reuse the extracted directory if
163+
it already exists and the hash matches.
164+
165+
### Trade-offs
166+
167+
Self-extracting mode enables broader compatibility, but comes with some
168+
trade-offs:
169+
170+
- **Initial startup cost**: The first run takes longer due to file extraction.
171+
- **Disk usage**: Extracted files take up additional space on disk.
172+
- **Memory usage**: Higher memory usage since embedded content can no longer be
173+
referenced as static data.
174+
- **Tamper risk**: Users or other code can modify the extracted files on disk.
175+
139176
## Code Signing
140177

141178
### macOS

runtime/reference/cli/upgrade.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ $ deno upgrade --quiet
6363
This is useful for scripting environments or when you want cleaner output in CI
6464
pipelines.
6565

66+
## Cached downloads
67+
68+
Downloaded Deno binaries are cached in `$DENO_DIR/dl/`. If you reinstall the
69+
same version later, the cached archive is reused instead of re-downloading. For
70+
canary builds, old entries are automatically removed, keeping only the 10 most
71+
recent versions.
72+
73+
## Checksum verification
74+
75+
Use the `--checksum` flag to verify a downloaded binary against a known SHA-256
76+
hash. This protects against tampering in CI environments and security-sensitive
77+
setups:
78+
79+
```shell
80+
$ deno upgrade --checksum=<sha256-hash> 2.7.0
81+
```
82+
83+
SHA-256 checksums are published as `.sha256sum` files alongside release archives
84+
on GitHub:
85+
86+
```shell
87+
$ curl -sL https://github.com/denoland/deno/releases/download/v2.7.0/deno-x86_64-unknown-linux-gnu.zip.sha256sum
88+
```
89+
6690
## Canary build
6791

6892
By default, Deno will upgrade from the official GitHub releases. You can specify

0 commit comments

Comments
 (0)