Commit graph

849 commits

Author SHA1 Message Date
Leo Kettmeir
b77871e0c8
fix(publish): support virtual: and cloudflare: schemes (#28922)
For https://github.com/jsr-io/jsr/pull/1035
2025-04-22 01:41:32 -07:00
Nathan Whitaker
713bf3266b
fix(npm): only print deprecation warnings on first install (#28990)
Fixes https://github.com/denoland/deno/issues/28933.

This was a regression from the packument refactor.
2025-04-21 20:18:38 +00:00
Leo Kettmeir
79e36b0ccd
feat(doc): add darkmode for HTML output (#28989) 2025-04-21 13:02:50 -07:00
Nathan Whitaker
dbb5373eab
fix(lockfile): re-fetch packuments if version not found, properly pass patch packages (#28964)
Fixes two issues:
- If a cached packument was out of date and missing a version from the
lockfile, we would fail. Instead we should try again with a forced
re-fetch
- We weren't threading through the workspace patch packages correctly
2025-04-18 23:08:15 +00:00
Nathan Whitaker
6ce1e9b7f7
fix(install): error gracefully if user passes --no-config to deno install <package> (#28965)
Fixes #28090. Fixes #28961.
2025-04-18 22:13:20 +00:00
Bartek Iwańczuk
33b4d3a6eb
test: temporarily ignore specs::install::package_extra_nmd test (#28954)
These tests are failing randomly on Windows at the moment. The PR that
added them was released in Deno v2.2.10 and users haven't reported any
problems so far. So temporarily ignoring these tests to unblock another
patch release.
2025-04-18 12:48:30 +02:00
Yoshiya Hinosawa
83f15ece09
feat(test): create coverage reports when --coverage specified in deno test (#28260)
This PR updates the behavior of `deno test --coverage` option. Now if
`--coverage` option is specified, `deno test` command automatically
shows summary report in the terminal, and generates the lcov report in
`$coverage_dir/lcov.info` and html report in `$coverage_dir/html/`

This change also adds `--coverage-raw-data-only` flag, which prevents
the above reports generated, instead only generates the raw json
coverage data (which is the same as current behavior)
2025-04-18 18:56:14 +09:00
Nathan Whitaker
f411ccd692
feat(lockfile): default to lockfile v5 (#28950)
Closes #28916
2025-04-17 13:27:37 -07:00
David Sherret
16d305449d
feat(compile): support for ffi and node native addons (#28934)
This extracts out the shared libraries and `.node` native modules to a
temp file and opens them from there. **This means that this
implementation will not work in every scenario.** For example, a library
could require other files that only exist in the in-memory file system.
To solve that, we'll introduce
https://github.com/denoland/deno/issues/28918 later or adapt this
solution to solve more issues.

Additionally, this will not work when run on readonly file systems.
2025-04-17 16:01:12 -04:00
Luca Casonato
c12709196c
fix: support vsock in DENO_SERVE_ADDRESS (#28941) 2025-04-17 13:49:47 +02:00
Yoshiya Hinosawa
016b02d374
fix(ext/node): add assert property to test context object (#28904) 2025-04-17 14:32:48 +09:00
Yoshiya Hinosawa
202f5f3910
feat(test): support DENO_COVERAGE_DIR env var (#28291)
This PR adds support of `DENO_COVERAGE_DIR` for controlling coverage
output.
2025-04-16 12:47:28 -04:00
MujahedSafaa
302a5dd12a
fix: resolve shebang parse error in deno doc --test (#26079)
The bug has been fixed by updating the regex to ensure that the shebang
characters (#!) are no longer excluded. This allows the shebang to be
retained and parsed correctly.

---------

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2025-04-16 00:56:04 -04:00
David Sherret
3071aa2759
feat(compile): ability to exclude embedded files (#28805)
For now, just simple path excluding (no glob support).

```
> deno compile --include folder --exclude folder/sub_folder main.ts
```
2025-04-15 19:10:37 +00:00
David Sherret
a5d39b085d
feat(fmt/lint): add --permit-no-files (#28753)
Closes https://github.com/denoland/deno/issues/28728
2025-04-15 17:57:34 +00:00
Ben Heidemann
f465961964
feat(coverage): add coverage ignore comments (#26590) 2025-04-15 17:56:55 +00:00
David Sherret
ef431b2336
feat(runtime): add Deno.build.standalone for telling if running in self-contained executable (#28750) 2025-04-15 17:44:28 +00:00
Nathan Whitaker
914549292e
fix(install): read extra package info from node_modules and fallback to registry (#28893)
Fixes #28891

We were checking if the node_modules entry for the package was present,
but then reading from the global cache.

Instead, read from the package.json in node_modules. As a fallback(which
in theory should only really happen if the node_modules dir is somehow
messed up), take the more expensive (but likely to work) path of reading
from the registry.json.
2025-04-14 19:32:27 +00:00
Divy Srivastava
01b6da9d9b
fix(ext/node): upgrade node:stream (#28855)
Ref https://github.com/denoland/deno/issues/28836

This PR replaces the _stream.mjs bundle with a file-by-file port instead. A codemod transpiles Node.js internals to ESM. The codemod performs three tasks: translating CJS to ESM, remapping internal dependencies, and hoisting lazy requires as imports.

The process is fully automated through the `update_node_stream.ts` script, simplifying future internal updates. The script checks out Node.js from a specific tag defined in the `tests/node_compat/runner`.

Additionally, the update enables new tests in our Node test runner and adds features (like compose()) that were missing from the outdated bundle.

## Performance

There is a 140KB+ binary size increase on aarch64-apple-darwin and nop startup time stays the same.
2025-04-14 21:35:34 +05:30
Yoshiya Hinosawa
1dfd444901
fix(ext/node): add basic support of suite/describe in node:test (#28847) 2025-04-14 15:44:03 +09:00
Yoshiya Hinosawa
372705a4d7
fix(ext/node): export test as property of default export (#28881) 2025-04-14 14:19:22 +09:00
Nathan Whitaker
ce5b9da11b
fix(install): handle when bin entry info isn't present in package.json but is in registry (#28822)
Apparently things like the `bin` field can appear in the version info
from the registry, but not the package's `package.json`. I'm still not
sure how you actually achieve this, but it's the case for
`esbuild-wasm`. This fixes the following panic:

```
❯ deno i --node-modules-dir npm:esbuild-wasm
Add npm:esbuild-wasm@0.25.2
Initialize ⣯ [00:00]
 - esbuild-wasm@0.25.2



============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 2.2.8+58c6c0b
Args: ["deno", "i", "--node-modules-dir", "npm:esbuild-wasm"]

View stack trace at:
https://panic.deno.com/v2.2.8+58c6c0bc9c1b4ee08645be936ff9268f17028f0f/aarch64-apple-darwin/g4h6Jo393pB4k4kqBo-3kqBg6klqBogtyLg13yLw_t0Lw549Hgj8-Hgw__H428-F4yv_HgjkpKww7gIon4gIw54rKwi5MorzMw5y7G42g7Iw---I40s-I4vu4Jw2rEw8z7Dwnr6J4tp7Bo_vvK

thread 'main' panicked at cli/npm/installer/common/bin_entries.rs:108:30:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
2025-04-10 09:36:26 -07:00
Divy Srivastava
561097dd63
fix(ext/node): implement process.loadEnvFile (#28824)
Fixes https://github.com/denoland/deno/issues/28017
2025-04-10 07:43:29 +00:00
Bartek Iwańczuk
c8291e6926
feat: enable explicit resource management for JavaScript (#28119)
This commit enabled [explicit resource management]
(https://github.com/tc39/proposal-explicit-resource-management)
proposal for JavaScript code.

This is done by upgrading `deno_ast` to a version that no longer
transpiles TS files with `using` keyword, and instead enables
a V8 flag that provides native support.

Closes https://github.com/denoland/deno/issues/20821

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2025-04-08 15:12:10 -07:00
Nathan Whitaker
780b741555
perf(npm): load npm resolution snapshot directly from lockfile (#28647)
Fixes #27264. Fixes https://github.com/denoland/deno/issues/28161.

Currently the new lockfile version is gated behind an unstable flag
(`--unstable-lockfile-v5`) until the next minor release, where it will
become the default.

The main motivation here is that it improves startup performance when
using the global cache or `--node-modules-dir=auto`.

In a create-next-app project, running an empty file:
```
❯ hyperfine --warmup 25 -N --setup "rm -f deno.lock" "deno run --node-modules-dir=auto -A empty.js" "deno-this-pr run --node-modules-dir=auto -A empty.js" "deno-this-pr run --node-modules-dir=auto --unstable-lockfile-v5 empty.js" "deno run --node-modules-dir=manual -A empty.js" "deno-this-pr run --node-modules-dir=manual -A empty.js"
Benchmark 1: deno run --node-modules-dir=auto -A empty.js
  Time (mean ± σ):     247.6 ms ±   1.7 ms    [User: 228.7 ms, System: 19.0 ms]
  Range (min … max):   245.5 ms … 251.5 ms    12 runs

Benchmark 2: deno-this-pr run --node-modules-dir=auto -A empty.js
  Time (mean ± σ):     169.8 ms ±   1.0 ms    [User: 152.9 ms, System: 17.9 ms]
  Range (min … max):   168.9 ms … 172.5 ms    17 runs

Benchmark 3: deno-this-pr run --node-modules-dir=auto --unstable-lockfile-v5 empty.js
  Time (mean ± σ):      16.2 ms ±   0.7 ms    [User: 12.3 ms, System: 5.7 ms]
  Range (min … max):    15.2 ms …  19.2 ms    185 runs

Benchmark 4: deno run --node-modules-dir=manual -A empty.js
  Time (mean ± σ):      16.2 ms ±   0.8 ms    [User: 11.6 ms, System: 5.5 ms]
  Range (min … max):    14.9 ms …  19.7 ms    187 runs

Benchmark 5: deno-this-pr run --node-modules-dir=manual -A empty.js
  Time (mean ± σ):      16.0 ms ±   0.9 ms    [User: 12.0 ms, System: 5.5 ms]
  Range (min … max):    14.8 ms …  22.3 ms    190 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Summary
  deno-this-pr run --node-modules-dir=manual -A empty.js ran
    1.01 ± 0.08 times faster than deno run --node-modules-dir=manual -A empty.js
    1.01 ± 0.07 times faster than deno-this-pr run --node-modules-dir=auto --unstable-lockfile-v5 empty.js
   10.64 ± 0.60 times faster than deno-this-pr run --node-modules-dir=auto -A empty.js
   15.51 ± 0.88 times faster than deno run --node-modules-dir=auto -A empty.js
```

When using the new lockfile version, this leads to a 15.5x faster
startup time compared to the current deno version.

Install times benefit as well, though to a lesser degree.

`deno install` on a create-next-app project, with everything cached
(just setting up node_modules from scratch):

```
❯ hyperfine --warmup 5 -N --prepare "rm -rf node_modules" --setup "rm -rf deno.lock" "deno i" "deno-this-pr i" "deno-this-pr i --unstable-lockfile-v5"
Benchmark 1: deno i
  Time (mean ± σ):     464.4 ms ±   8.8 ms    [User: 227.7 ms, System: 217.3 ms]
  Range (min … max):   452.6 ms … 478.3 ms    10 runs

Benchmark 2: deno-this-pr i
  Time (mean ± σ):     368.8 ms ±  22.0 ms    [User: 150.8 ms, System: 198.1 ms]
  Range (min … max):   344.8 ms … 397.6 ms    10 runs

Benchmark 3: deno-this-pr i --unstable-lockfile-v5
  Time (mean ± σ):     211.9 ms ±  17.1 ms    [User: 7.1 ms, System: 177.2 ms]
  Range (min … max):   191.3 ms … 233.4 ms    10 runs

Summary
  deno-this-pr i --unstable-lockfile-v5 ran
    1.74 ± 0.17 times faster than deno-this-pr i
    2.19 ± 0.18 times faster than deno i
```

With lockfile v5, a 2.19x faster install time compared to the current
deno.
2025-04-08 02:06:17 +00:00
David Sherret
874f4fc5ae
chore: skip explicit_start_and_end_low_precision test on ci (#28789)
It's gotten too flaky.
2025-04-07 17:55:18 -07:00
David Sherret
96b06c64a5
fix(compile): do not panic including node_modules directory (#28782)
Closes https://github.com/denoland/deno/issues/28773
2025-04-07 16:43:34 -07:00
Nayeem Rahman
757ef462f7
fix(lint): resolve plugin paths from proper config specifier (#28752) 2025-04-04 19:30:27 +00:00
David Sherret
becf24c8c2
fix(compile): ensure atime/birthtime/mtime/ctime is set in vfs (#28731)
Co-authored-by: XYCode <xycode-xyc@outlook.com>
2025-04-04 09:50:44 -04:00
WWRS
dca9f7c0c3
fix(fmt): use non-zero exit code when formatting fails (#28523) 2025-04-04 14:48:47 +01:00
snek
ebc4f82eca
feat: v8js metrics (#28592)
Implement
https://opentelemetry.io/docs/specs/semconv/runtime/v8js-metrics/
2025-04-03 15:18:54 +02:00
David Sherret
3b52f1afd8
chore: fix flaky tests checking for ms (#28718) 2025-04-03 09:49:05 +05:30
Divy Srivastava
e10101347c
perf: remote symbolicate stack traces (#28470)
Fixes #28136 
Closes #28415

Publish symcache to GCS and generate trace URL during panic.

```
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: windows x86_64
Version: 2.2.5
Args: ["C:\Users\divy\.deno\bin\deno.exe"]

View stack trace at:
https://panic.deno.com/v2.2.5/aarch64-apple-darwin/gszD49_B4utrqB4vrrqBozirqB49prqBwjkwqBw_jBg31Cw5tCg5sDoo3pqB41sDgkkB
```

## Design

<img
src=https://github.com/user-attachments/assets/396d53cd-1fe7-4d88-9ecd-ea7b74a9a1ed
height=500>

Example:
`https://panic.deno.com/v2.2.3/aarch64-apple-darwin/g4couawkboxb4tbg9oHwqbw6a`

Stack walking and symbolicate code is at
https://github.com/denoland/panic/
2025-04-02 08:42:28 +05:30
Nathan Whitaker
5e20982a30
feat(add/install): --npm and --jsr flags for deno add/install (#28666)
Flags to set the default registry for "bare" package names (no `npm:` or
`jsr:` prefix)
```
deno add --npm chalk react @types/react jsr:@std/fs
deno add --jsr @std/fs @std/async @std/fmt npm:chalk
```
2025-04-01 19:12:48 +00:00
David Sherret
1e65d21071
fix: show referrer for Wasm module dependency errors (#28653) 2025-03-28 09:13:39 -04:00
Nathan Whitaker
863ab45436
fix(npm): set up bin entries for package even if it's already downloaded (#28626)
Fixes #28617
2025-03-25 22:32:15 +00:00
David Sherret
31f6c05c9c
feat(unstable/run): ability to lazily load statically analyzable dynamic imports (#28593)
This allows lazily loading statically analyzable dynamic imports when
not type checking.
2025-03-25 11:38:45 -04:00
David Sherret
c239d37d20
fix(npm): resolve non-version matching peer deps and warn instead (#28616)
This improves peer dependency resolution to be more relaxed and resolve
non-version matching ancestors similar to pnpm rather than introducing
duplicate dependencies. Deno will warn when this occurs. In the future,
we should look into introducing an option to have Deno error in this
scenario.
2025-03-25 11:10:13 -04:00
snek
27363d389d
refactor: internal logging utility (#28567)
`import.meta.log` enables basic log filtering through
`env_logger`/`DENO_LOG`. Log levels are supported, and filenames can
also be used. for example: `DENO_LOG=ext:deno_http::00_serve.ts=warn`
2025-03-21 12:17:50 +01:00
David Sherret
94c9681385
feat(unstable): support using a local copy of npm packages (#28512)
This adds support for using a local copy of an npm package.

```js
// deno.json
{
  "patch": [
    "../path/to/local_npm_package"
  ],
  // required until Deno 2.3, but it will still be considered unstable
  "unstable": ["npm-patch"]
}
```

1. Requires using a node_modules folder.
2. When using `"nodeModulesDir": "auto"`, it recreates the folder in the
node_modules directory on each run which will slightly increase startup
time.
3. When using the default with a package.json (`"nodeModulesDir":
"manual"`), updating the package requires running `deno install`. This
is to get the package into the node_modules directory of the current
workspace. This is necessary instead of linking because packages can
have multiple "copy packages" due to peer dep resolution.

Caveat: Specifying a local copy of an npm package or making changes to
its dependencies will purge npm packages from the lockfile. This might
cause npm resolution to resolve differently and it may end up not using
the local copy of the npm package. It's very difficult to only
invalidate resolution midway through the graph and then only rebuild
that part of the resolution, so this is just a first pass that can be
improved in the future. In practice, this probably won't be an issue for
most people.

Another limitation is this also requires the npm package name to exist
in the registry at the moment.
2025-03-21 03:09:57 +00:00
snek
d4ee94962f
feat: upgrade deno_core and V8 (#28562)
includes V8 upgrade to 135
2025-03-21 00:19:44 +01:00
Lach
7ac8130854
feat(otel): basic event recording (#28552) 2025-03-20 13:58:08 -07:00
letianpailove
aee38ab6e3
docs: fix a typo in specs README.md (#28524) 2025-03-17 17:46:22 +09:00
Leo Kettmeir
28e5c388b4
feat(otel): span context propagators (#28460)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2025-03-13 16:32:45 +01:00
Yoshiya Hinosawa
dcfaba0f3a
fix(otel/unstable): trace error cases of fetch (#28480) 2025-03-13 17:47:00 +09:00
Yoshiya Hinosawa
c9930c591a
feat(unstable/otel): add otel tracing to node:http.request (#28463) 2025-03-13 17:43:37 +09:00
David Sherret
348900b8b7
fix(check): support typesVersions in npm dependencies (#28468) 2025-03-11 11:23:30 -04:00
Yoshiya Hinosawa
6ddf0f2f5f
test(otel): add test of otel integration of node http server (#28461) 2025-03-11 23:11:19 +09:00
David Sherret
9ea4f82643
fix(check): support types@ export conditions (#28450) 2025-03-10 13:20:48 -04:00
Bartek Iwańczuk
e6637ab6f1
chore(internal): reland eszip changes (#28294)
Co-authored-by: David Sherret <dsherret@gmail.com>
2025-03-05 22:25:56 +00:00