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

fix(repl): improve package.json support #18497

Merged
merged 3 commits into from
Mar 30, 2023

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Mar 29, 2023

  1. Fixes a cosmetic issue in the repl where it would display lsp warning messages.
  2. Lazily loads dependencies from the package.json on use.
  3. Supports using bare specifiers from package.json in the REPL.

Closes #17929
Closes #18494

@ry
Copy link
Member

ry commented Mar 29, 2023

Thanks for the quick fix!

Does this mean that REPL will still look for package.json even before there's an import? Why does it need to do that?

@dsherret
Copy link
Member Author

dsherret commented Mar 29, 2023

Does this mean that REPL will still look for package.json even before there's an import? Why does it need to do that?

Yes, it will still do that. It's because the repl internally uses the lsp and the lsp eagerly loads it. The lsp eagerly loads it in order to have consistent/deterministic npm resolution regardless of what files are currently open or loaded.

@dsherret
Copy link
Member Author

dsherret commented Mar 29, 2023

Thinking about it more, we could maybe only use the lockfile as a source of truth for deterministic resolution. I will look into changing this.

Edit: This is now resolved.

@dsherret dsherret changed the title fix(repl): disable lsp warning logs fix(repl): improve package.json support Mar 29, 2023
@@ -106,7 +106,7 @@ pub fn result_to_evaluation_output(
match r {
Ok(value) => value,
Err(err) => {
EvaluationOutput::Error(format!("{} {}", colors::red("error:"), err))
EvaluationOutput::Error(format!("{} {:#}", colors::red("error:"), err))
Copy link
Member Author

Choose a reason for hiding this comment

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

Outputs the error with context.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, good fix!

super::logging::set_lsp_log_level(log::Level::Debug);
super::logging::set_lsp_warn_level(log::Level::Debug);
Copy link
Member

Choose a reason for hiding this comment

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

Elegant solution 👍

@dsherret dsherret merged commit e0429e2 into denoland:main Mar 30, 2023
@dsherret dsherret deleted the repl_lsp_warning_logs branch March 30, 2023 14:43
mmastrac pushed a commit that referenced this pull request Mar 31, 2023
1. Fixes a cosmetic issue in the repl where it would display lsp warning
messages.
2. Lazily loads dependencies from the package.json on use.
3. Supports using bare specifiers from package.json in the REPL.

Closes #17929
Closes #18494
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.

Disable package.json in deno.json Deno 1.31.0 REPL errors when launched in a Node project
3 participants