Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto-discover package.json for npm dependencies #17272

Merged
merged 88 commits into from
Feb 20, 2023

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Jan 5, 2023

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.

bartlomieju and others added 30 commits January 4, 2023 13:24
…n lsp... wee need to somehow tell typescript to load this package's type declarations so it will get the ambient modules
…e a revert because it's going to get too complex.
…ns before a revert because it's going to get too complex."

This reverts commit b631b0a.
cli/args/package_json.rs Outdated Show resolved Hide resolved
@bartlomieju bartlomieju changed the title [WIP] feat: auto-discover package.json for npm dependencies feat: auto-discover package.json for npm dependencies Feb 18, 2023
@@ -258,6 +267,7 @@ impl ProcState {
lockfile.as_ref().cloned(),
)
.await?;
npm_resolver.add_package_reqs(package_json_reqs).await?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unconditionally downloads all "dependencies" and "devDependencies" from package.json. I think we should be smarter about the latter, but maybe that's fine for the first pass.

@bartlomieju bartlomieju requested a review from dsherret February 20, 2023 01:18
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

cli/args/mod.rs Show resolved Hide resolved
cli/args/mod.rs Outdated Show resolved Hide resolved
cli/args/mod.rs Show resolved Hide resolved
cli/npm/resolvers/mod.rs Show resolved Hide resolved
@bartlomieju bartlomieju merged commit 4d1a14c into denoland:main Feb 20, 2023
@bartlomieju bartlomieju deleted the bare_specifier_package_json branch February 20, 2023 18:14
@ry
Copy link
Member

ry commented Feb 20, 2023

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants