Commit graph

349 commits

Author SHA1 Message Date
David Sherret ad6b00a2bf
chore: enable clippy unused_async rule (#22834) 2024-03-11 23:48:00 -04:00
Nayeem Rahman 01bc2f530e
feat(unstable/pm): support npm packages in 'deno add' (#22715) 2024-03-06 13:24:15 +00:00
David Sherret 3eaf174bfc
fix(node): improve cjs tracking (#22673)
We were missing saying that a file is CJS when some Deno code imported
from the node_modules directory at runtime.
2024-03-06 00:23:51 +00:00
Nayeem Rahman 625a9319f6
feat(lsp): include registry url in jsr import hover text (#22676) 2024-03-04 15:48:23 +00:00
David Sherret 942b2aaca5
fix(lsp): output more information on error (#22665) 2024-03-01 21:25:38 -05:00
David Sherret 0973e8e859
fix(lsp): regression - caching in lsp broken when config with imports has comments (#22666)
Caused by https://github.com/denoland/deno/pull/22553

Closes #22664
2024-03-01 21:13:04 -05:00
Nayeem Rahman 3a43568481
feat(lsp): jsr specifier completions (#22612) 2024-02-29 03:54:16 +00:00
Bartek Iwańczuk f1a691274e
feat(publish): discover jsr.json and jsr.jsonc files (#22587)
Closes https://github.com/denoland/deno/issues/22491
2024-02-27 08:27:21 +00:00
David Sherret 6567dc94a9
fix(lsp): import map expansion (#22553) 2024-02-24 00:21:09 -05:00
David Sherret f90889e5ee
perf(jsr): fast check cache and lazy fast check graph (#22485) 2024-02-20 21:29:57 +00:00
Nayeem Rahman 1ad754b412
feat(lsp): jsr support with cache probing (#22418) 2024-02-14 22:48:39 +00:00
Nayeem Rahman 49d82e609f
feat(lsp): jsr support first pass (#22382)
This implementation heavily depends on there being a lockfile, meaning
JSR specifiers will always diagnose as uncached unless it's there. In
practice this affects cases where a `deno.json` isn't being used. Our
NPM specifier support isn't subject to this.

The reason for this is that the version constraint solving code is
currently buried in `deno_graph` and not usable from the LSP, so the
only way to reuse that logic is the solved-version map in the lockfile's
`packages.specifiers`.
2024-02-12 22:12:49 +00:00
Nayeem Rahman d730956f49
fix(lsp): don't normalize urls in cache command params (#22182) 2024-01-30 17:17:34 +00:00
Nayeem Rahman aed5e4997d
chore(lsp): rename client-side command invocations (#22140) 2024-01-28 21:56:45 +00:00
Bartek Iwańczuk 2fd26de396
fix(lsp): disable experimentalDecorators by default (#22101)
Follow up to https://github.com/denoland/deno/pull/22040.

By mistake I forgot to disable "experimental decorators" in the LSP.
2024-01-25 14:39:21 +00:00
Nayeem Rahman ec97c7dd4b
feat(lsp): include scope uri in "deno/didChangeDenoConfiguration" (#22002) 2024-01-23 06:12:41 +00:00
David Sherret 35c1652f56
fix(lsp): regression - formatting was broken on windows (#21972)
~~Waiting on: https://github.com/denoland/deno_config/pull/31~~

Closes #21971
Closes https://github.com/denoland/vscode_deno/issues/1029
2024-01-18 15:57:30 -05:00
Nayeem Rahman 2141543105
feat(lsp): send "deno/didChangeDenoConfiguration" on init (#21965) 2024-01-17 20:22:28 +00:00
Bartek Iwańczuk 0d51c1f90e
feat: remove conditional unstable type-checking (#21825)
This commit removes conditional type-checking of unstable APIs.

Before this commit `deno check` (or any other type-checking command and
the LSP) would error out if there was an unstable API in the code, but not
`--unstable` flag provided.

This situation hinders DX and makes it harder to configure Deno. Failing
during runtime unless `--unstable` flag is provided is enough in this case.
2024-01-14 18:29:17 +01:00
Nayeem Rahman d8f86c8b9c
refactor(lsp): store project version on documents (#21892) 2024-01-11 17:07:44 +00:00
David Sherret e212e1fc35
perf: skip expanding exclude globs (#21817)
We were calling `expand_glob` on our excludes, which is very expensive
and unnecessary because we can pattern match while traversing instead.

1. Doesn't expand "exclude" globs. Instead pattern matches while walking
the directory.
2. Splits up the "include" into base paths and applicable file patterns.
This causes less pattern matching to occur because we're only pattern
matching on patterns that might match and not ones in completely
unrelated directories.
2024-01-08 17:18:42 +00:00
Nayeem Rahman 261f32ef65
feat(lsp): cache jsxImportSource automatically (#21687) 2024-01-02 23:48:34 +00:00
David Sherret 7e72f3af61
chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
Nayeem Rahman 48dae2441c
perf(lsp): use LanguageServiceHost::getProjectVersion() (#21719) 2023-12-28 00:13:57 +00:00
Bartek Iwańczuk cdbf902499
feat(lsp): allow to connect V8 inspector (#21482)
This commit adds a way to connect to the TS compiler host that is run
as part of the "deno lsp" subcommand. This can be done by specifying 
"DENO_LSP_INSPECTOR" variable.

---------

Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2023-12-22 02:04:02 +01:00
Bartek Iwańczuk 49a6daaa83
perf(lsp): collect counts and durations of all requests (#21540)
In addition to collecting details per-request metrics of the last 3000
request this commit adds aggregate metrics for all requests.
2023-12-12 08:18:10 +01:00
Bartek Iwańczuk 88566cee72
perf(lsp): instrument all ops with performance marks (#21536)
Adds performance measurements for all ops used by the LSP. Also changes
output of "Language server status" page to include more precise
information.

Current suspicion is that computing "script version" takes a long time
for some users.
2023-12-11 17:33:56 +01:00
Nayeem Rahman 123d9ea047
feat(lsp): debug log file (#21500) 2023-12-08 17:04:56 +00:00
David Sherret ddfbe71ced
feat(lsp): provide quick fixes for specifiers that could be resolved sloppily (#21506) 2023-12-08 09:57:06 -05:00
David Sherret 78566753c8
feat: add suggestions to module not found error messages for file urls (#21498) 2023-12-07 15:59:13 -05:00
David Sherret 890780a9e9
feat(unstable): ability to resolve specifiers with no extension, specifiers for a directory, and TS files from JS extensions (#21464)
Adds an `--unstable-sloppy-imports` flag which supports the
following for `file:` specifiers:

* Allows writing `./mod` in a specifier to do extension probing.
- ex. `import { Example } from "./example"` instead of `import { Example
} from "./example.ts"`
* Allows writing `./routes` to do directory extension probing for files
like `./routes/index.ts`
* Allows writing `./mod.js` for *mod.ts* files.

This functionality is **NOT RECOMMENDED** for general use with Deno:

1. It's not as optimal for perf:
https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-2/
1. It makes tooling in the ecosystem more complex in order to have to
understand this.
1. The "Deno way" is to be explicit about what you're doing. It's better
in the long run.
1. It doesn't work if published to the Deno registry because doing stuff
like extension probing with remote specifiers would be incredibly slow.

This is instead only recommended to help with migrating existing
projects to Deno. For example, it's very useful for getting CJS projects
written with import/export declaration working in Deno without modifying
module specifiers and for supporting TS ESM projects written with
`./mod.js` specifiers.

This feature will output warnings to guide the user towards correcting
their specifiers. Additionally, quick fixes are provided in the LSP to
update these specifiers:
2023-12-07 00:03:18 +00:00
Bartek Iwańczuk fe90ba650d
refactor(lsp): log names (#21413)
This commit changes LSP log names by prefixing them, we now have these
prefixes:
- `lsp.*` - requests coming from the client
- `tsc.request.*` - requests coming from clients that are routed to TSC
- `tsc.op.*` - ops called by the TS host
- `tsc.host.*` - requests that call JavaScript runtime that runs
TypeScript compiler host

Additionall `Performance::mark` was split into `Performance::mark` and 
`Performance::mark_with_args` to reduce verbosity of code and logs.
2023-12-01 03:54:59 +01:00
Nayeem Rahman 91626bac49
perf(lsp): avoid redundant getNavigationTree() calls (#21396) 2023-11-30 16:23:47 +00:00
Nayeem Rahman 64997cce6a
fix(lsp): force shutdown after a timeout (#21251) 2023-11-22 04:08:48 +00:00
David Sherret f46802cb1e
refactor(upgrade): add unit tests for lsp upgrade check (#21244) 2023-11-17 16:40:12 -05:00
Nayeem Rahman 4913274a65
feat(lsp): upgrade check on init and notification (#21105) 2023-11-14 22:10:51 +00:00
Nayeem Rahman 55e0483626
fix(lsp): update tsconfig after refreshing settings on init (#21170) 2023-11-12 22:30:04 +00:00
David Sherret e4c947dd2b
fix(node): use closest package.json to resolve package.json imports (#21075) 2023-11-04 16:41:51 +00:00
David Sherret be97170a19
feat(unstable): ability to npm install then deno run main.ts (#20967)
This PR adds a new unstable "bring your own node_modules" (BYONM)
functionality currently behind a `--unstable-byonm` flag (`"unstable":
["byonm"]` in a deno.json).

This enables users to run a separate install command (ex. `npm install`,
`pnpm install`) then run `deno run main.ts` and Deno will respect the
layout of the node_modules directory as setup by the separate install
command. It also works with npm/yarn/pnpm workspaces.

For this PR, the behaviour is opted into by specifying
`--unstable-byonm`/`"unstable": ["byonm"]`, but in the future we may
make this the default behaviour as outlined in
https://github.com/denoland/deno/issues/18967#issuecomment-1761248941

This is an extremely rough initial implementation. Errors are
terrible in this and the LSP requires frequent restarts. Improvements
will be done in follow up PRs.
2023-10-25 14:39:00 -04:00
Nayeem Rahman a7bd0cf7a8
perf(lsp): cleanup workspace settings scopes (#20937) 2023-10-24 21:27:27 +01:00
Nayeem Rahman 659cd90758
feat(lsp): respect "typescript.preferences.quoteStyle" when deno.json is absent (#20891) 2023-10-17 02:51:42 +01:00
Nayeem Rahman 5dd010a4fb
feat(lsp): send "deno/didChangeDenoConfiguration" notifications (#20827) 2023-10-12 16:07:27 +01:00
Nayeem Rahman eaeb10cee1
perf(lsp): fix redundant file reads (#20802) 2023-10-12 15:37:56 +01:00
Nayeem Rahman 6bbccb72d7
refactor(lsp): add "deno.reloadImportRegistries" as a command (#20823) 2023-10-10 05:53:41 +01:00
Nayeem Rahman 84c9300aff
fix(lsp): allow formatting vendor files (#20844) 2023-10-09 23:43:32 +01:00
Nayeem Rahman 35f028daf2
perf(lsp): optimize formatting minified files (#20829) 2023-10-09 04:39:52 +01:00
David Sherret 148694eb35
refactor(npm): make NpmCache, CliNpmRegistryApi, and NpmResolution internal to npm::managed (#20764) 2023-10-02 17:53:55 -04:00
David Sherret 8d24be1a59
refactor(npm): create cli::npm::managed module (#20740)
Creates the `cli::npm::managed` module and starts moving more
functionality into it.
2023-09-30 12:06:38 -04:00
David Sherret 5edd102f3f
refactor(cli): make CliNpmResolver a trait (#20732)
This makes `CliNpmResolver` a trait. The terminology used is:

- **managed** - Deno manages the node_modules folder and does an
auto-install (ex. `ManagedCliNpmResolver`)
- **byonm** - "Bring your own node_modules" (ex. `ByonmCliNpmResolver`,
which is in this PR, but unimplemented at the moment)

Part of #18967
2023-09-29 09:26:25 -04:00
David Sherret d43e48c4e9
refactor(ext/node): remove dependency on deno_npm and deno_semver (#20718)
This is required from BYONM (bring your own node_modules).

Part of #18967
2023-09-28 22:43:45 +02:00