1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00

fix(info): error instead of panic for npm specifiers when using byonm (#25947)

This commit is contained in:
David Sherret 2024-09-30 15:46:43 -04:00 committed by GitHub
parent c5c1869992
commit d7b787792c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 30 additions and 4 deletions

View file

@ -1144,10 +1144,6 @@ impl CliOptions {
DenoSubcommand::Run(run_flags) => {
if run_flags.is_stdin() {
resolve_url_or_path("./$deno$stdin.ts", self.initial_cwd())?
} else if NpmPackageReqReference::from_str(&run_flags.script)
.is_ok()
{
ModuleSpecifier::parse(&run_flags.script)?
} else {
resolve_url_or_path(&run_flags.script, self.initial_cwd())?
}

View file

@ -21,6 +21,7 @@ use crate::tools::check::TypeChecker;
use crate::util::file_watcher::WatcherCommunicator;
use crate::util::fs::canonicalize_path;
use deno_config::workspace::JsrPackageConfig;
use deno_core::anyhow::bail;
use deno_graph::source::LoaderChecksum;
use deno_graph::FillFromLockfileOptions;
use deno_graph::JsrLoadError;
@ -593,6 +594,12 @@ impl ModuleGraphBuilder {
let initial_package_deps_len = graph.packages.package_deps_sum();
let initial_package_mappings_len = graph.packages.mappings().len();
if roots.iter().any(|r| r.scheme() == "npm")
&& self.npm_resolver.as_byonm().is_some()
{
bail!("Resolving npm specifier entrypoints this way is currently not supported with \"nodeModules\": \"manual\". In the meantime, try with --node-modules-dir=auto instead");
}
graph.build(roots, loader, options).await;
let has_redirects_changed = graph.redirects.len() != initial_redirects_len;

View file

@ -0,0 +1,11 @@
{
"tempDir": true,
"steps": [{
"args": "install",
"output": "[WILDCARD]"
}, {
"args": "info npm:@denotest/add",
"output": "info.out",
"exitCode": 1
}]
}

View file

@ -0,0 +1,6 @@
{
"nodeModulesDir": "manual",
"imports": {
"chalk": "npm:@denotest/add"
}
}

View file

@ -0,0 +1 @@
error: Resolving npm specifier entrypoints this way is currently not supported with "nodeModules": "manual". In the meantime, try with --node-modules-dir=auto instead

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/add": "*"
}
}