1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
Commit graph

97 commits

Author SHA1 Message Date
David Sherret
44b0d4cb11
fix(npm): show a progress bar when initializing the node_modules folder (#18136)
Creating the node_modules folder when the packages are already
downloaded can take a bit of time and not knowing what is going on can
be confusing. It's better to show a progress bar.
2023-03-13 18:18:29 +00:00
David Sherret
11f225ef7d
fix: ensure no node_modules directory is created when a package.json exists and no npm dependencies are used (#18134)
Closes #18133
Closes #18038
2023-03-13 14:03:19 +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
23e1ba7e2d
fix(npm): improve peer dependency resolution with circular dependencies (#18069)
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-08 12:22:08 -05:00
David Sherret
88b5fd9088
fix: attempt to only allow one deno process to update the node_modules folder at a time (#18058)
This is implemented in such a way that it should still allow processes
to go through when a file lock wasn't properly cleaned up and the OS
hasn't released it yet (but with a 200ms-ish delay).

Closes #18039
2023-03-08 15:13:13 +00:00
David Sherret
2f7222da8a
refactor: remove Semaphore::new(1) and use TaskQueue (#18014) 2023-03-04 20:07:11 -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
b15f9e60a0
feat(task): support scripts in package.json (#17887)
This is a super basic initial implementation. We don't create a
`node_modules/.bin` folder at the moment and add it to the PATH like we
should which is necessary to make command name resolution in the
subprocess work properly (ex. you run a script that launches another
script that then tries to launch an "npx command"... this won't work
atm).

Closes #17492
2023-02-22 22:45:35 -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
9b8992d4b4
feat: start caching npm package version's "bin" entry from npm registry (#17881) 2023-02-22 13:16:40 -05:00
David Sherret
5becfd6381
fix(npm): filter out duplicate packages names in resolution (#17857) 2023-02-21 15:19:09 -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
610b8cc2bf
refactor: add NpmPackageId back from deno_graph as NpmPackageNodeId (#17804)
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-17 09:12:22 -05:00
David Sherret
c4b9a91e27
refactor: use deno_graph's semver and npm structs (#17791) 2023-02-15 13:20:40 -05:00
David Sherret
b3e88e0681
refactor: deno_graph 0.43 upgrade (#17692) 2023-02-09 22:00:23 -05:00
David Sherret
600fff79cd
refactor(semver): generalize semver related structs (#17605)
- 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-31 21:27:40 -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
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
Bartek Iwańczuk
bf237c6241
refactor: Move lockfile to a separate crate (#17503)
Moves the lockfile implementation to a separate crate so other projects
like Deploy can use it as well.
2023-01-23 23:41:02 +01:00
David Sherret
40527526e5
refactor(npm): avoid cloning snapshot for lockfile (#17451) 2023-01-16 19:46:30 +00:00
Yiyu Lin
fd85f840cd
refactor: clean up unwrap and clone (#17282)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-01-15 09:36:46 +05:30
David Sherret
7cd249db10
fix(npm): handle an npm package that has itself as a dependency (#17425)
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-14 15:10:07 -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
7db729a42d
fix(npm): support old packages and registries with no integrity, but with a sha1sum (#17289)
Closes #17281
2023-01-06 11:36:12 -05:00
David Sherret
3e72241fda
fix(npm): reduce copy packages when resolving optional peer dependencies (#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-06 09:13:21 -05:00
David Sherret
c9b0d2709b
fix(npm): panic resolving some dependencies with dist tags (#17278)
This would only occur if a dist tag for a package was resolved more than
once.

Closes #17275
2023-01-06 08:48:56 -05:00
Yiyu Lin
896dd56b7a
refactor(cli,core,ext,rt): remove some unnecessary clone or malloc (#17274) 2023-01-05 14:29:50 -05: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
Ikko Ashimine
1a3665b612
chore(npm): fix typo in local.rs (#17186) 2022-12-26 17:24:25 +09:00
David Sherret
a06f59981b
fix(npm): resolve npm specifiers when root redirected (#17144)
Closes #17136
2022-12-20 11:40:26 -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
David Sherret
878590b773
fix(npm): support loose node semver ranges like >= ^x.x.x (#17037) 2022-12-13 13:01:42 -05:00
Bartek Iwańczuk
8c026dab92
feat: improve download progress bar (#16984)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-12-12 20:52:10 -05:00
David Sherret
f8bcf6be28
feat(npm): add support for NPM_CONFIG_REGISTRY (#16980) 2022-12-07 16:10:50 -05:00
David Sherret
c03e0f3853
refactor: remove deno_graph::Locker usage (#16877)
This is just a straight refactor and doesn't make any improvements to
the code that could now be made.

Closes #16493
2022-12-06 14:12:51 -05: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
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
David Sherret
fb04e87387
fix(npm): ensure npm package downloaded once per run when using --reload (#16842) 2022-11-27 13:25:08 -05:00
David Sherret
0c0af67f89
refactor: DenoDir - move to cache folder and make root_dir private (#16823) 2022-11-26 00:04:30 +00:00
David Sherret
0cc90d9246
refactor: move lockfile.rs to args module (#16818)
This should be in the `args` folder as it's similar to `config_file`.
2022-11-25 17:00:28 -05:00
Bartek Iwańczuk
b70f520ebc
fix: Make npm packages works with import maps (#16754)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-11-22 20:09:30 +01:00
David Sherret
763d492ed6
fix(npm): use an http client with connection pool (#16705)
Should make downloading npm packages faster and more reliable.
2022-11-18 17:28:14 -05:00
David Sherret
1e512d10b3
fix(npm): ancestor that resolves peer dependency should not include self in id (#16693)
Closes #16683
2022-11-18 09:41:06 -05:00