0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-21 04:42:51 -05:00
Commit graph

7134 commits

Author SHA1 Message Date
Yoshiya Hinosawa
3ff9ca2533
docs(cli): update description of readFile and readFileSync (#28079) 2025-02-12 17:56:12 +09:00
Bartek Iwańczuk
795ecfdca6
refactor(lsp): make TS host use CLI snapshot (#28062)
This commit changes the TS host implementation
in the LSP to use the same snapshot as the runtime worker
and web worker use.

This is due to upcoming V8 upgrade that might require
that all isolates in the same process use the exact same
snapshot.
2025-02-11 18:33:04 +01:00
Marvin Hagemeister
a2afae46b6
fix(unstable): add missing rule context types (#28014) 2025-02-11 16:35:16 +01:00
Bartek Iwańczuk
23540c2825
refactor: remove tsc snapshot (#28056)
This reverts commit acdc7dcdcf
and relands 174e496847.

Closes https://github.com/denoland/deno/issues/28047
Closes https://github.com/denoland/deno/issues/28044
2025-02-11 15:36:07 +01:00
Jo Franchetti
07410d19cf
docs: adding examples and a see link to Websockets jdocs (#27957)
adding examples to websockets interfaces and a see link

---------

Co-authored-by: Phil Hawksworth <phil@deno.com>
2025-02-11 15:35:15 +01:00
Marvin Hagemeister
aead459fb2
feat(unstable): support multiple fixes from lint plugins (#28040)
This PR supports returning multiple changes from a lint fix. It works
the same way as eslint, see
https://eslint.org/docs/latest/extend/custom-rules#applying-fixes .

- Return a single fix
- Return an array of fixes
- Return a generator function with fixes
2025-02-11 15:24:28 +01:00
Bartek Iwańczuk
acdc7dcdcf
Revert "refactor: remove tsc snapshot (#27987)" (#28052)
This reverts commit 174e496847.

That commit caused panic on startup like
https://github.com/denoland/deno/issues/28047
or https://github.com/denoland/deno/issues/28044.

Reverting for now, until we figure out what's going wrong.
2025-02-11 11:18:32 +00:00
Nathan Whitaker
174e496847
refactor: remove tsc snapshot (#27987)
Removes the TSC snapshot to unblock the V8 upgrade (which enables shared
RO heap, and is incompatible with multiple snapshots).


this compresses the sources and declaration files as well, which leads
to a roughly 4.2MB reduction in binary size.

this currently adds about 80ms to deno check times, but code cache isn't
wired up for the extension code (namely `00_typescript.js`) yet

```
❯ hyperfine --warmup 5 -p "rm -rf ~/Library/Caches/deno/check_cache_v2" "../../deno/target/release-lite/deno check main.ts" "deno check main.ts"
Benchmark 1: ../../deno/target/release-lite/deno check main.ts
  Time (mean ± σ):     184.2 ms ±   2.2 ms    [User: 378.3 ms, System: 48.2 ms]
  Range (min … max):   181.5 ms … 189.9 ms    15 runs

Benchmark 2: deno check main.ts
  Time (mean ± σ):     107.4 ms ±   1.2 ms    [User: 155.3 ms, System: 23.9 ms]
  Range (min … max):   105.3 ms … 109.6 ms    26 runs

Summary
  deno check main.ts ran
    1.72 ± 0.03 times faster than ../../deno/target/release-lite/deno check main.ts
```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-02-10 16:39:18 +00:00
Bartek Iwańczuk
7bd210f9e8
fix(lint): don't show docs URLs for plugins (#28033)
This commit removes the docs URL for diagnostics coming
from JS plugins. Before, we mistakenly printed
URLs pointing to `docs.deno.com`, even though they did not
exist.

An ability to actually specify a custom URL for plugin rules,
will be added in a follow up PR.
2025-02-10 17:32:31 +01:00
Bartek Iwańczuk
ad9429afbd
fix(lint): disable incremental caching if JS plugins are used (#28026)
Ref https://github.com/denoland/deno/issues/28025
2025-02-10 15:40:10 +01:00
Bartek Iwańczuk
d29d367e17
refactor(lint): remove dead documentation (#28027)
These docs have already been moved to `deno-docs` repo.
2025-02-10 15:38:11 +01:00
Bartek Iwańczuk
94a28f783d
fix(lint): out of order diagnostics for plugins (#28029)
This commit fixes racy condition in lint plugins
that could have caused diagnostics for another
file to be printed for completely unrelated file.

With this change, a oneshot channel is used
to receive diagnostics for a file, which ensures
that the caller will receive diagnostics for itself.
2025-02-10 13:22:57 +00:00
Nayeem Rahman
7d139ddd60
perf(lsp): cancellation checks in blocking code (#27997) 2025-02-10 11:52:31 +01:00
David Sherret
e94581d272
fix(lint): clear plugin diagnostics on each lint file run (#28011)
This clears the diagnostics whenever a file is about to run. For
example, what could previously occur is an error and the diagnostics
would be leftover from the previous run.
2025-02-07 17:47:28 +00:00
Marvin Hagemeister
615bf8a4b0
feat(unstable): type lint plugin visitor (#28005)
This PR strongly types the JS plugin visitor.

```ts
export default {
  name: "foo",
  rules: {
    bar: {
      create(ctx) {
        return {
          // Plain ast node visitor
          Identifier(node) {},

          // Exit visitor
          "Identifier:exit"(node) {},

          // Custom selectors, `node` needs to be typed manually
          "FunctionDeclaration > Identifier"(node: Deno.lint.Identifier) {}
        }
      }
    }
  }
}

```

Follow up to https://github.com/denoland/deno/pull/27977
2025-02-07 13:01:33 +01:00
Marvin Hagemeister
703fdd8607
fix: panic with js lint plugins and invalid js syntax (#28006)
Noticed that the LSP might panic during serialization when working on a
file with a syntax error.

This PR changes the serialization so that invalid nodes are simply
serialized to the invalid node `0`. The plugin code treats the node with
id `0` as an invalid node and will ignore it during visiting.

I'm not sure how to write a test for the LSP.
2025-02-07 12:35:44 +01:00
David Sherret
a82326d029
perf(compile): use bytes already in memory after downloading executable (#28000)
Not sure if this will help https://github.com/denoland/deno/issues/27988
but it's better anyway.
2025-02-06 23:24:06 -05:00
HasanAlrimawi
a0c5ef8ba8
fix(compile): never include the specified output executable in itself (#27877) 2025-02-06 23:23:10 +00:00
Marvin Hagemeister
dd1ee5821b
feat(unstable): align lint ast with TSEStree (#27996)
This PR fixes deviations in our AST format compared to TSEStree. They
are mostly a leftover for when I first started working on it and based
it off of babel instead.

One of the key changes why the changeset is a bit bigger is that
TSEStree uses `undefined` instead of `null` as the empty value for type
nodes. This is likely influenced by `tsc` which use `undefined`
everywhere. The rest of the nodes use `null` though. It's a little
weird, but for now it might be better to align.

(extracted from https://github.com/denoland/deno/pull/27977)
2025-02-06 21:45:56 +01:00
Marvin Hagemeister
89b1969f02
feat(unstable): add lint plugin ast types (#27977)
Add type definition for all TSEstree AST nodes in the JS lint plugin
system
2025-02-06 21:45:45 +01:00
Marvin Hagemeister
df02af27fd
feat(unstable): add lint.plugins to config schema (#27982)
Not sure what our handling of unstable properties in `deno.json` is.
This PR adds it to the config schema.

---------

Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-02-06 08:00:23 +00:00
Nayeem Rahman
bc8554878e
fix(check): support sloppy imports with "compilerOptions.rootDirs" (#27973) 2025-02-05 23:08:10 +00:00
Bartek Iwańczuk
f08ca6414b
feat(lint): add JavaScript plugin support (#27203)
This commit adds an unstable lint plugin API.

Plugins are specified in the `deno.json` file under
`lint.plugins` option like so:

```
{
  "lint": {
    "plugins": [
      "./plugins/my-plugin.ts",
      "jsr:@deno/lint-plugin1",
      "npm:@deno/lint-plugin2"
    ]
  }
}
```

The API is considered unstable and might be subject
to changes in the future.

Plugin API was modelled after ESLint API for the 
most part, but there are no guarantees for compatibility.
The AST format exposed to plugins is closely modelled
after the AST that `typescript-eslint` uses.

Lint plugins use the visitor pattern and can add
diagnostics like so:

```
export default {
  name: "lint-plugin",
  rules: {
    "plugin-rule": {
      create(context) {
        return {
          Identifier(node) {
            if (node.name === "a") {
              context.report({
                node,
                message: "should be b",
                fix(fixer) {
                  return fixer.replaceText(node, "_b");
                },
              });
            }
          },
        };
      },
    },
  },
} satisfies Deno.lint.Plugin;
```

Besides reporting errors (diagnostics) plugins can provide
automatic fixes that use text replacement to apply changes.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2025-02-05 16:59:24 +01:00
Nathan Whitaker
b440d2d4f7
feat(outdated): interactive update (#27812)
interactively select which packages to upgrade. a future improvement
could be to add a way to select the version as well, though not sure how
valuable that would be.
2025-02-04 15:41:56 -08:00
David Sherret
61faa32920
perf: node resolution cache (#27838)
This adds a cache for node resolution, which makes repeat lookups about
15x faster.
2025-02-03 20:25:10 -05:00
David Sherret
073caf5fe9
refactor: extract out utf16 map from lsp to cli::util module (#27950) 2025-02-03 20:24:26 -05:00
Nathan Whitaker
108b6a8bfb
fix(lsp): ignore a few more diagnostics for ambient modules (#27949)
Missed a few resolution errors
2025-02-03 16:13:14 -08:00
David Sherret
e46860a2fd
feat(compile): support sloppy imports (#27944)
Closes https://github.com/denoland/deno/issues/26102
2025-02-03 13:08:08 -05:00
Alvaro Parker
41fa8df197
feat(bench): add --permit-no-files (#27048)
This PR adds the `--permit-no-files` cli options to the `bench`
subcommand. This will cause `deno bench --permit-no-files` to not return
an error when no bench files where found.
2025-02-03 16:18:09 +00:00
Bartek Iwańczuk
8bdcbec5d7
fix(publish): correct coloring in --help (#27939) 2025-02-03 01:41:09 +00:00
Nayeem Rahman
9da6a20e57
Revert "fix(lsp): silence debug error for 'move to a new file' action (#27780)" (#27903) 2025-02-01 02:53:24 +00:00
David Sherret
8971064546
feat: TypeScript 5.7 (#27857)
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
2025-01-31 16:07:42 -05:00
Timothy
8d824182be
docs: Temporal plaintime docs link (#27879) 2025-01-31 12:23:38 -08:00
Divy Srivastava
b8a878cfc2
fix(cli): Fix panic in load_native_certs (#27863)
Fixes https://github.com/denoland/deno/issues/27528

Can't really trigger the panic myself hence no test.
2025-01-31 18:29:37 +05:30
denobot
d9db0b35e0
chore: forward v2.1.9 release commit to main (#27888)
This is the release commit being forwarded back to main for 2.1.9

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-31 03:02:00 +01:00
denobot
1b7719c5d6
chore: forward v2.1.8 release commit to main (#27882)
This is the release commit being forwarded back to main for 2.1.8

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-30 21:09:06 +01:00
Marvin Hagemeister
c44b05cab5
feat(task): add support for task wildcards (#27007)
This PR adds support for passing wildcard tasks. All matched tasks are
sorted in case they have dependencies. Tasks already in the dependency
tree will be pruned so that every task only runs once.

```json
{
  "tasks": {
    "foo-1": "echo 'foo-1'",
    "foo-2": "echo 'foo-2'"
  }
}
```

```sh
$ deno task "foo-*"
Task foo-1 echo 'foo-1'
foo-1
Task foo-2 echo 'foo-2'
foo-2
```

The changes in the PR look a little bigger than they really are due to
formatting. For the most part, I've only needed to hoist up the task
matching logic.

Closes https://github.com/denoland/deno/issues/26944
Closes https://github.com/denoland/deno/issues/21530

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-30 14:37:10 +01:00
Nathan Whitaker
b7456fed70
fix(lsp): ignore errors on ambient module imports (#27855)
This makes it so imports of ambient modules (e.g. `$app/environment` in
svelte, any virtual module in vite, or other module provided by a
bundler) don't error in the LSP.

The way this works is that when we request diagnostics from TSC, we also
respond with the list of ambient modules. Then, in the diagnostics code,
we save diagnostics (produced by deno) that may be invalidated as an
ambient module and wait to publish the diagnostics until we've received
the ambient modules from TSC.

The actual ambient modules you get from TSC can contain globs, e.g.
`*.css`. So when we get new ambient modules, we compile them all into a
regex and check erroring imports against that regex. Ambient modules
should change rarely, so in most cases we should be using a pre-compiled
regex, which executes in linear time (wrt the specifier length).

TODO:
- Ideally we should only publish once, right now we publish with the
filtered specifiers and then the TSC ones
- deno check (#27633)
2025-01-30 00:25:32 +00:00
Nayeem Rahman
0dd334b512
feat(check/lsp): support "compilerOptions.rootDirs" (#27844) 2025-01-30 00:20:25 +00:00
David Sherret
b39ae6f0d3
fix(init): correct dev task for --lib (#27860) 2025-01-29 16:53:13 +00:00
David Sherret
4648fc4570
fix(check): compiler options from workspace members (#27785)
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2025-01-28 10:49:58 -05:00
Divy Srivastava
aeac5a6338
feat(ext/node): implement node:sqlite (#27308)
Depends on:
- https://github.com/denoland/deno_core/pull/994
- https://github.com/denoland/deno_core/pull/993
- https://github.com/denoland/deno_core/issues/999
- https://github.com/denoland/deno_core/pull/1000
- https://github.com/denoland/deno_core/pull/1001

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


![image](https://github.com/user-attachments/assets/396fc8b7-30cb-411c-82bc-2e9e3e6bbb18)

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2025-01-28 19:30:03 +05:30
David Sherret
679902a108
perf(node_resolver): reduce url to/from path conversions (#27839)
Extracted out of https://github.com/denoland/deno/pull/27838/files

Reduces some allocations by accepting either a pathbuf or url for the
referrer for resolution and returning either a pathbuf or url at the
end, which the caller can then convert into to their preferred state.

This is about 4% faster when still converting the final result to a url
and 6% faster when keeping the result as a path in a benchmark I ran.
2025-01-27 15:23:20 -05:00
David Sherret
92dce12af7
fix(install/global): warn about not including auto-discovered config file (#27745)
Closes #17855
2025-01-27 14:18:27 -05:00
Marvin Hagemeister
21e8260cc9
fix(lint): update jsx/react related rules and names (#27836)
This PR updates `deno_lint` which contains a couple of bug fixes for
JSX/React related rules. The react rules now have all a `react-*` prefix
in the name as well.
2025-01-27 16:54:35 +00:00
Divy Srivastava
8ccc05e503
fix(core): handle dyn imports exceeding call stack size (#27825)
Fixes https://github.com/denoland/deno/issues/27736
2025-01-27 09:10:12 +05:30
Bartek Iwańczuk
23adf99e83
perf(lsp): cache completion item resolution during request (#27831)
This commit adds a simple HashMap cache to completion requests.

On a test project the time to compute completions went from 1200ms
to 75ms and the cache contained ~300 entries when 8000 completion
items were produced by the TSC.

This is a short-lived cache and is discarded once the completion
request is finished. In a follow up commits we could make it persist
between requests.
2025-01-26 22:40:53 +01:00
David Sherret
769f748dd9
fix(node): align type stripping in node_modules error message with Node (#27809) 2025-01-24 13:05:04 -05:00
Kenta Moriuchi
6880608452
fix(types): Deno.readDirSync's type returns an IteratorObject (#27805) 2025-01-24 11:25:55 -05:00
David Sherret
e475749935
refactor: make PackageJsonCache injectable (#27800)
This used to be complicated to do, but is now trivial.
2025-01-24 09:50:25 -05:00