summaryrefslogtreecommitdiff
path: root/cli/npm/resolution
AgeCommit message (Collapse)Author
2023-04-06refactor(npm): use deno_npm and deno_semver (#18602)David Sherret
2023-03-21feat: TypeScript 5.0.2 (except decorators) (#18294)David Sherret
This upgrades TypeScript to 5.0.2, but does not have ES decorator support because swc does not support that yet.
2023-03-13fix: ensure no node_modules directory is created when a package.json exists ↵David Sherret
and no npm dependencies are used (#18134) Closes #18133 Closes #18038
2023-03-12refactor(npm): push npm struct creation to a higher level (#18139)David Sherret
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-08fix(npm): improve peer dependency resolution with circular dependencies (#18069)David Sherret
This improves peer dependency resolution yet again. We did not handle scenarios like the following: ``` // a -> b -> c -> d -> c -> b (peer) ``` ...which would maybe work ok the first time its run in some cases, but then lead to a lockfile that would error on load. This now keeps track of circular dependencies and updates nodes accordingly. That said, there is still a lurking bug in this code somewhere that I've added a comment for (there is a mitigation on the tail end that seems to work well). The current state is much better than before and I can look into it later. I think it's something small that's incorrect.
2023-03-04refactor: remove `Semaphore::new(1)` and use `TaskQueue` (#18014)David Sherret
2023-02-24fix(npm): lazily install package.json dependencies only when necessary (#17931)David Sherret
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-23feat(npm): support bare specifiers from package.json in more subcommands and ↵David Sherret
language server (#17891)
2023-02-22refactor: use deno_graph for npm specifiers (#17858)David Sherret
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-21fix(npm): filter out duplicate packages names in resolution (#17857)David Sherret
2023-02-21fix(npm): improve peer dependency resolution (#17835)David Sherret
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-20feat: auto-discover package.json for npm dependencies (#17272)Bartek Iwańczuk
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-17refactor: add `NpmPackageId` back from deno_graph as `NpmPackageNodeId` (#17804)David Sherret
The `NpmPackageId` struct is being renamed to `NpmPackageNodeId`. In a future PR it will be moved down into only npm dependency resolution and a `NpmPackageId` struct will be introduced in `deno_graph` that only has the name and version of the package (no peer dependency identifier information). So a `NpmPackageReq` will map to an `NpmPackageId`, which will map to an `NpmPackageNodeId` in the npm resolution.
2023-02-15refactor: use deno_graph's semver and npm structs (#17791)David Sherret
2023-02-09refactor: deno_graph 0.43 upgrade (#17692)David Sherret
2023-01-31refactor(semver): generalize semver related structs (#17605)David Sherret
- Generalizes the npm version code (ex. `NpmVersion` -> `Version`, `NpmVersionReq` -> `VersionReq`). This is a slow refactor towards extracting out this code for deno specifiers and better usage in deno_graph. - Removes `SpecifierVersionReq`. Consolidates `NpmVersionReq` and `SpecifierVersionReq` to just `VersionReq` - Removes `NpmVersionMatcher`. This now just looks at `VersionReq`. - Paves the way to allow us to create `NpmPackageReference`'s from a package.json's dependencies/dev dependencies (`VersionReq::parse_from_npm`).
2023-01-27chore: upgrade to Rust 1.67 (#17548)David Sherret
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-24feat: support node built-in module imports (#17264)Bartek Iwańczuk
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-24refactor(deno_graph): remove unused Resolved::Ok#kind usage (#17504)David Sherret
See https://github.com/denoland/deno_graph/pull/205 for more details.
2023-01-23refactor: Move lockfile to a separate crate (#17503)Bartek Iwańczuk
Moves the lockfile implementation to a separate crate so other projects like Deploy can use it as well.
2023-01-16refactor(npm): avoid cloning snapshot for lockfile (#17451)David Sherret
2023-01-15refactor: clean up `unwrap` and `clone` (#17282)Yiyu Lin
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-01-14fix(npm): handle an npm package that has itself as a dependency (#17425)David Sherret
I'm not sure this properly handles scenarios where an npm package uses an alias that resolves to itself, we can fix that if we find a package that actually depends on that behavior. Closes #17420
2023-01-06fix(npm): support old packages and registries with no integrity, but with a ↵David Sherret
sha1sum (#17289) Closes #17281
2023-01-06fix(npm): reduce copy packages when resolving optional peer dependencies ↵David Sherret
(#17280) If an optional peer dependency entry previously wasn't resolved and it's now being resolved, then it will add it as if it were a dependency of the previously resolved package instead of creating a new "copy package" (seems to be what npm and pnpm does). Closes #17240
2023-01-06fix(npm): panic resolving some dependencies with dist tags (#17278)David Sherret
This would only occur if a dist tag for a package was resolved more than once. Closes #17275
2023-01-05refactor(cli,core,ext,rt): remove some unnecessary `clone` or `malloc` (#17274)Yiyu Lin
2023-01-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-12-20fix(npm): resolve npm specifiers when root redirected (#17144)David Sherret
Closes #17136
2022-12-06refactor: remove `deno_graph::Locker` usage (#16877)David Sherret
This is just a straight refactor and doesn't make any improvements to the code that could now be made. Closes #16493
2022-11-25refactor: move lockfile.rs to args module (#16818)David Sherret
This should be in the `args` folder as it's similar to `config_file`.
2022-11-22fix: Make npm packages works with import maps (#16754)Bartek Iwańczuk
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-11-18fix(npm): ancestor that resolves peer dependency should not include self in ↵David Sherret
id (#16693) Closes #16683
2022-11-17perf(npm): make dependency resolution faster (#16694)David Sherret
2022-11-18chore: use Rust 1.65.0 (#16688)Aaron O'Mullan
2022-11-15fix(npm): support dist tags specified in npm package dependencies (#16652)David Sherret
Closes #16321
2022-11-14fix(npm): handle peer dep being resolved without resolved dep higher in tree ↵David Sherret
and then with (#16640) Peer dependency resolution wasn't handling a peer dependency being resolved without a dep higher in the tree and then with one being found higher in the tree.
2022-11-13feat(npm): require --unstable for npm specifiers in remote modules (#16612)David Sherret
2022-11-12fix(npm): specifier resolution - handle data urls and modules at a directory ↵David Sherret
(#16611)
2022-11-11feat(unstable/npm): module graph derived npm specifier resolution order (#16602)David Sherret
2022-11-11perf: more efficient `deno cache` and npm package info usage (#16592)David Sherret
1. There was a lot of cloning going on with `NpmPackageInfo`. This is now stored in an `Arc<NpmPackageInfo>` and cloning only happens on the individual version. 2. The package cache is now cleared from memory after resolution. 3. This surfaced a bug in `deno cache` and I noticed it can be more efficient if we have multiple root specifiers if we provide all the specifiers as roots.
2022-11-08feat(unstable/npm): support peer dependencies (#16561)David Sherret
This adds support for peer dependencies in npm packages. 1. If not found higher in the tree (ancestor and ancestor siblings), peer dependencies are resolved like a dependency similar to npm 7. 2. Optional peer dependencies are only resolved if found higher in the tree. 3. This creates "copy packages" or duplicates of a package when a package has different resolution due to peer dependency resolution—see https://pnpm.io/how-peers-are-resolved. Unlike pnpm though, duplicates of packages will have `_1`, `_2`, etc. added to the end of the package version in the directory in order to minimize the chance of hitting the max file path limit on Windows. This is done for both the local "node_modules" directory and also the global npm cache. The files are hard linked in this case to reduce hard drive space. This is a first pass and the code is definitely more inefficient than it could be. Closes #15823