Commit graph

186 commits

Author SHA1 Message Date
David Sherret fb021d7cef
refactor: remove usages of map_or / map_or_else (#18212)
These methods are confusing because the arguments are backwards. I feel
like they should have never been added to `Option<T>` and that clippy
should suggest rewriting to
`map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)`

https://github.com/rust-lang/rfcs/issues/1025
2023-03-15 17:46:36 -04:00
David Sherret 7070b8ed50
fix(lsp): avoid calling client while holding lock (#18197) 2023-03-15 14:34:23 +00:00
David Sherret bcb6ee9d08
refactor(npm): push npm struct creation to a higher level (#18139)
This has been bothering me for a while and it became more painful while
working on #18136 because injecting the shared progress bar became very
verbose. Basically we should move the creation of all these npm structs
up to a higher level.

This is a stepping stone for a future refactor where we can improve how
we create all our structs.
2023-03-12 23:32:59 -04:00
David Sherret 8db853514c
fix(check): regression where config "types" entries caused type checking errors (#18124)
Closes #18117
Closes #18121 (this is just over 10ms faster in a directory one up from
the root folder)

cc @nayeemrmn
2023-03-11 11:43:45 -05:00
David Sherret 84bafd11d5
fix: lazily surface errors in package.json deps parsing (#17974)
Closes #17941
2023-03-03 18:27:05 -04:00
David Sherret 033b70af19
fix(npm): lazily install package.json dependencies only when necessary (#17931)
This lazily does an "npm install" when any package name matches what's
found in the package.json or when running a script from package.json
with deno task.

Part of #17916

Closes #17928
2023-02-24 19:35:43 -05:00
David Sherret 6233c0aff0
fix(npm): support bare specifiers in package.json having a path (#17903)
For example `import * as test from "package/path.js"`
2023-02-23 17:33:23 +00:00
David Sherret 344317ec50
feat(npm): support bare specifiers from package.json in more subcommands and language server (#17891) 2023-02-23 10:58:10 -05:00
David Sherret a6ca4d0d61
refactor: use deno_graph for npm specifiers (#17858)
This changes npm specifiers to be handled by deno_graph and resolved to
an npm package name and version when the specifier is encountered. It
also slightly changes how npm specifier resolution occurs—previously it
would collect all the npm specifiers and resolve them all at once, but
now it resolves them on the fly as they are encountered in the module
graph.

https://github.com/denoland/deno_graph/pull/232

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-22 14:15:25 -05:00
David Sherret 3479bc7661
fix(npm): improve peer dependency resolution (#17835)
This PR fixes peer dependency resolution to only resolve peers based on
the current graph traversal path. Previously, it would resolve a peers
by looking at a graph node's ancestors, which is not correct because
graph nodes are shared by different resolutions.

It also stores more information about peer dependency resolution in the
lockfile.
2023-02-21 12:03:48 -05:00
Bartek Iwańczuk 4d1a14ca7f
feat: auto-discover package.json for npm dependencies (#17272)
This commits adds auto-discovery of "package.json" file when running
"deno run" and "deno task" subcommands. In case of "deno run" the
"package.json" is being looked up starting from the directory of the
script that is being run, stopping early if "deno.json(c)" file is found
(ie. FS tree won't be traversed "up" from "deno.json").

When "package.json" is discovered the "--node-modules-dir" flag is
implied, leading to creation of local "node_modules/" directory - we
did that, because most tools relying on "package.json" will expect
"node_modules/" directory to be present (eg. Vite). Additionally 
"dependencies" and "devDependencies" specified in the "package.json"
are downloaded on startup. 

This is a stepping stone to supporting bare specifier imports, but
the actual integration will be done in a follow up commit.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-20 19:14:06 +01:00
David Sherret c4b9a91e27
refactor: use deno_graph's semver and npm structs (#17791) 2023-02-15 13:20:40 -05:00
David Sherret b34e751a5b
refactor: make resolver required (#17783)
Makes the resolver required and prints a warning when vendoring and a
dynamic import can't be resolved.

Closes #16522
2023-02-15 11:30:54 -05:00
David Sherret b3e88e0681
refactor: deno_graph 0.43 upgrade (#17692) 2023-02-09 22:00:23 -05:00
David Sherret b16a958c4f
fix(lsp): prevent crash analyzing module (#17642)
Closes #17640
2023-02-03 14:10:51 -05:00
David Sherret fe11df09b1
fix(lsp): update document dependencies on configuration change (#17556) 2023-01-28 10:18:32 -05:00
David Sherret f5840bdcd3
chore: upgrade to Rust 1.67 (#17548)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-27 10:43:16 -05:00
Geert-Jan Zwiers 7f38f30a5c
refactor(lsp): fewer clones (#17551) 2023-01-26 23:24:03 +01:00
Bartek Iwańczuk fc2e00152b
feat: support node built-in module imports (#17264)
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-24 09:05:54 -05:00
David Sherret 654e177c91
refactor(deno_graph): remove unused Resolved::Ok#kind usage (#17504)
See https://github.com/denoland/deno_graph/pull/205 for more details.
2023-01-24 08:23:19 -05:00
Geert-Jan Zwiers e023a6e3f0
refactor(cli): fewer clones (#17450) 2023-01-16 15:27:41 -05:00
Bartek Iwańczuk 636352e0ca
fix(npm): allow to read package.json if permissions are granted (#17209)
This commit changes signature of "deno_core::ModuleLoader::resolve" to pass
an enum indicating whether or not we're resolving a specifier for dynamic import.

Additionally "CliModuleLoader" was changes to store both "parent permissions" (or
"root permissions") as well as "dynamic permissions" that allow to check for permissions
in top-level module load an dynamic imports.

Then all code paths that have anything to do with Node/npm compat are now checking
for permissions which are passed from module loader instance associated with given
worker.
2023-01-10 14:35:44 +01:00
David Sherret 10e4b2e140
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00
David Sherret 423474caa8
fix(lsp/format): language formatter used should be based on language id (#17148)
Closes #11897
2022-12-20 15:19:35 -05:00
David Sherret 54d40e008a
perf(lsp): concurrent reads and exclusive writes (#17135) 2022-12-19 20:22:17 -05:00
linbingquan f46df3e359
chore: update to Rust 1.66.0 (#17078) 2022-12-17 23:20:15 +01:00
Bartek Iwańczuk 435948e470
feat(repl): support npm packages (#16770)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-12-13 13:53:32 +01:00
David Sherret 3973ceb634
fix(npm): dependency types were sometimes not being resolved when package had no types entry (#16958)
Closes #16957
2022-12-05 20:09:31 -05:00
David Sherret b1e29d1bd0
fix(npm): improve package.json exports support for types (#16880) 2022-11-30 23:07:32 +00:00
David Sherret 623dbe7a57
chore: remove unnecessary lifetimes (#16878)
It seems we don't really need to allow these clippy rules.
2022-11-30 19:19:32 +00:00
David Sherret e2655c992e
fix(lsp): analyze fs dependencies of dependencies to find npm package requirements (#16866)
Closes #16867
2022-11-30 00:32:18 +00:00
David Sherret 2d4c46c975
refactor: create util folder, move nap_sym to napi/sym, move http_cache to cache folder (#16857) 2022-11-28 17:28:54 -05:00
Bartek Iwańczuk 630abb58b0
refactor: Combine ImportMapResolver and JsxResolver (#16508)
These resolvers are used in `deno_graph` APIs. Combining them removes a
lot of code and
unblocks me on https://github.com/denoland/deno/pull/16157
2022-11-02 15:47:02 +01:00
David Sherret bcfe279fba
feat(unstable/npm): initial type checking of npm specifiers (#16332) 2022-10-21 15:20:18 +00:00
David Sherret da906de184
fix(lsp): allow caching deps in non-saved files (#16353) 2022-10-20 13:23:21 -04:00
David Sherret 9e6917426a
fix: upgrade deno_ast to 0.19 (#15808) 2022-09-07 15:06:18 -04:00
Luca Casonato 33c4d45328
fix: resolve jsxImportSource relative to module (#15561)
Previously `jsxImportSource` was resolved relative to the config file
during graph building, and relative to the emitted module during
runtime.

This is now fixed so that the JSX import source is resolved relative to
the module both during graph building and at runtime.
2022-08-24 19:36:05 +02:00
David Sherret 7a1a082876
perf: cache swc dependency analysis and don't hold onto ParsedSources in memory (#15502) 2022-08-22 12:14:59 -04:00
Kitson Kelly 1c2ec1f48f
fix: update deno_graph to fix importing config as JSON module (#15388)
Ref: denoland/deno_graph#166
2022-08-10 07:27:22 +10:00
David Sherret e1c90963fb
refactor: create args folder (#14982) 2022-06-27 16:54:09 -04:00
David Sherret 1fcecb6789
refactor: upgrade to deno_ast 0.15 (#14680) 2022-05-20 16:40:55 -04:00
David Sherret eb5ffab1cb
fix(lsp): correct positions in some scenarios (#14359) 2022-05-15 14:41:37 -04:00
Jason a6e4b4297d
refactor(lsp): migrate from lspower back to tower-lsp (#14163) 2022-04-03 14:17:30 +10:00
David Sherret 1c37ac3352
chore(tests): use custom temp dir creation for the tests (#14153) 2022-04-01 11:15:37 -04:00
David Sherret 53dac7451b
chore: remove all pub(crate)s from the cli crate (#14083) 2022-03-23 09:54:22 -04:00
David Sherret e8c47755bb
chore(lsp): log more for "unexpected positions" lsp error (#13815)
Ref #13657
2022-03-03 08:06:38 +11:00
David Sherret 3b12afd072
chore: upgrade to Rust 1.59 (#13767) 2022-02-24 20:03:12 -05:00
Kitson Kelly 973fe6dd3a
refactor: remove dead code from lsp (#13743) 2022-02-24 08:01:20 +11:00
Kitson Kelly 26f5c223df
fix(lsp): properly display x-deno-warning with redirects (#13554)
Fixes: #13472
2022-02-02 13:04:26 +11:00
Kitson Kelly 7d356250e8
refactor: integrate deno_graph breaking changes (#13495)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-02-01 09:33:57 +11:00
David Sherret 0e12acc6ff
refactor(lsp): Documents - combine duplicate exists methods (#13479) 2022-01-25 09:21:59 -05:00
Kitson Kelly 1a3983a538
perf(lsp): improve some tsc op hot paths (#13473) 2022-01-24 19:01:33 +11:00
David Sherret ad224f53c7
chore: upgrade to rust 1.58 (#13377) 2022-01-15 07:10:12 +01:00
Ryan Dahl 1fb5858009
chore: update copyright to 2022 (#13306)
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-07 22:09:52 -05:00
Kitson Kelly 57bfa87b2c
feat(lsp): provide registry details on hover if present (#13294)
Closes: #13272
2022-01-07 11:27:13 +11:00
Divy Srivastava 6de53b631f
refactor: use once_cell instead of lazy_static (#13135) 2021-12-18 16:14:42 -05:00
Kitson Kelly e8d7b430ce
chore: updates to support deno_graph API changes (#13080) 2021-12-15 07:39:20 +11:00
Kitson Kelly 345f0fbe5c
feat(cli): update to TypeScript 4.5 (#12410)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-12-10 09:12:21 +11:00
David Sherret 51e3db956a
fix(cli): config file should resolve paths relative to the config file (#12867)
* Add `specifier_to_file_path` to support converting a ModuleSpecifier with a unix-style path to a PathBuf on Windows.
2021-11-23 10:38:11 -05:00
David Sherret c82ce74133
refactor(lsp): remove Documents mutex and require Documents to be mutated to change it (#12747) 2021-11-18 13:50:24 -05:00
Kitson Kelly cc38580106
fix(lsp): retain module dependencies when parse is invalid (#12782)
Fixes #12753
2021-11-17 09:23:25 +11:00
David Sherret 28dbb4a95e
refactor(lsp): prefer using document instead of documents collection (#12720) 2021-11-12 11:42:04 -05:00
Kitson Kelly f5eb177f50
feat(cli): support React 17 JSX transforms (#12631)
Closes #8440
2021-11-09 12:26:39 +11:00
Kitson Kelly 182de1452b
fix(lsp): display module types only dependencies on hover (#12683)
Fixes: #12675
2021-11-08 11:50:48 +11:00
David Sherret 0ec151b8cb
chore: upgrade deno_ast to 0.5.0 (#12595) 2021-11-01 16:22:27 -04:00
Kitson Kelly 34a9ddff09
refactor(lsp): use deno_graph and single document struct (#12535)
Closes #12473
2021-10-29 10:56:01 +11:00
David Sherret 2c2e3ec1ca
refactor(lsp): use deno_ast and cache swc ASTs (#11780) 2021-09-07 10:39:32 -04:00
Kitson Kelly 0d83afd939
fix(lsp): better handling of languageId (#11755)
Fixes #11521
Fixes #11742
2021-08-19 13:19:12 +10:00
Yusuke Tanaka 8f00b5542c
chore: upgrade Rust to 1.54.0 (#11554) 2021-07-30 15:03:41 +02:00
Kitson Kelly 72ac9c3ae0
fix(lsp): handle importmaps properly (#11496)
Fixes: #11146
Fixes: #11456
Fixes: #10439
2021-07-25 15:33:42 +10:00
Kitson Kelly 9e51766f3e
feat(lsp): dependency hover information (#11090) 2021-06-25 09:06:51 +10:00
Satya Rohith 952caa79b3
feat(lsp): quick fix actions to ignore lint errors (#10627)
Closes #10122
2021-06-21 16:43:35 +10:00
Kitson Kelly e8be116ab6
fix(lsp): refactor, fix issues and add benchmark for code lens (#10841) 2021-06-05 07:31:44 +10:00
Kitson Kelly 844a1317ec
fix(#10775): diagnostics update on dependency changes (#10817)
Fixes #10775
2021-06-03 21:13:53 +10:00
Kitson Kelly 473713c621
fix(#10815): lsp only responds to formatting for md, json, jsonc (#10816)
Fixes #10815
2021-06-02 20:29:58 +10:00
Kitson Kelly fe8057105e
fix(#10125): remove documents when closed in the lsp (#10254)
Fixes #10125
2021-04-20 07:11:23 +10:00
Kitson Kelly 65f7a021f0
feat(lsp): improve diagnostic status page (#10253) 2021-04-20 07:10:43 +10:00
Yusuke Tanaka e7954413e1
upgrade: Rust 1.51.0 (#9895) 2021-03-25 19:17:37 +01:00
Kitson Kelly 5ebb401703
feat(lsp): add import completions (#9821) 2021-03-25 11:13:37 +11:00
Ryan Dahl c7dabc99ee
Make ModuleSpecifier a type alias, not wrapper struct (#9531) 2021-02-17 13:47:18 -05:00
Kitson Kelly 79916226b7
fix(lsp): properly handle static assets (#9476) 2021-02-12 22:49:42 +11:00
Kitson Kelly 6752be05cd
fix(lsp): handle type deps properly (#9436)
Fixes #9425
2021-02-10 09:46:12 +11:00
Kitson Kelly d95666cae0
fix(lsp): handle code lenses for non-documents (#9454) 2021-02-09 20:48:53 +11:00
Kitson Kelly 534531e4dd
feat(lsp): add references code lens (#9316) 2021-02-01 14:30:41 +11:00
hvithrafn 013b8fe606
Update lspower dependency (#9179) 2021-01-29 14:34:33 -05:00
Kitson Kelly 1a9209d1e3
fix(lsp): handle mbc documents properly (#9151)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2021-01-22 21:03:16 +11:00