mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 04:52:26 -05:00
fix(regression): show bare-node-builtin hint when using an import map (#27632)
This commit is contained in:
parent
c27248a8f3
commit
f6dcc13537
6 changed files with 17 additions and 9 deletions
|
@ -36,7 +36,6 @@ use deno_runtime::deno_permissions::PermissionsContainer;
|
||||||
use deno_semver::jsr::JsrDepPackageReq;
|
use deno_semver::jsr::JsrDepPackageReq;
|
||||||
use deno_semver::package::PackageNv;
|
use deno_semver::package::PackageNv;
|
||||||
use deno_semver::SmallStackString;
|
use deno_semver::SmallStackString;
|
||||||
use import_map::ImportMapError;
|
|
||||||
use node_resolver::InNpmPackageChecker;
|
use node_resolver::InNpmPackageChecker;
|
||||||
|
|
||||||
use crate::args::config_to_deno_graph_workspace_member;
|
use crate::args::config_to_deno_graph_workspace_member;
|
||||||
|
@ -1024,14 +1023,11 @@ fn get_resolution_error_bare_specifier(
|
||||||
{
|
{
|
||||||
Some(specifier.as_str())
|
Some(specifier.as_str())
|
||||||
} else if let ResolutionError::ResolverError { error, .. } = error {
|
} else if let ResolutionError::ResolverError { error, .. } = error {
|
||||||
if let ResolveError::Other(error) = (*error).as_ref() {
|
if let ResolveError::ImportMap(error) = (*error).as_ref() {
|
||||||
if let Some(import_map::ImportMapErrorKind::UnmappedBareSpecifier(
|
if let import_map::ImportMapErrorKind::UnmappedBareSpecifier(
|
||||||
specifier,
|
specifier,
|
||||||
_,
|
_,
|
||||||
)) = error
|
) = error.as_kind()
|
||||||
.as_any()
|
|
||||||
.downcast_ref::<ImportMapError>()
|
|
||||||
.map(|e| &**e)
|
|
||||||
{
|
{
|
||||||
Some(specifier.as_str())
|
Some(specifier.as_str())
|
||||||
} else {
|
} else {
|
||||||
|
@ -1324,7 +1320,7 @@ mod test {
|
||||||
let specifier = ModuleSpecifier::parse("file:///file.ts").unwrap();
|
let specifier = ModuleSpecifier::parse("file:///file.ts").unwrap();
|
||||||
let err = import_map.resolve(input, &specifier).err().unwrap();
|
let err = import_map.resolve(input, &specifier).err().unwrap();
|
||||||
let err = ResolutionError::ResolverError {
|
let err = ResolutionError::ResolverError {
|
||||||
error: Arc::new(ResolveError::Other(JsErrorBox::from_err(err))),
|
error: Arc::new(ResolveError::ImportMap(err)),
|
||||||
specifier: input.to_string(),
|
specifier: input.to_string(),
|
||||||
range: Range {
|
range: Range {
|
||||||
specifier,
|
specifier,
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
"output": "main.ts.out",
|
"output": "main.ts.out",
|
||||||
"exitCode": 1
|
"exitCode": 1
|
||||||
},
|
},
|
||||||
|
"basic_no_config": {
|
||||||
|
"args": "run --quiet --no-config main.ts",
|
||||||
|
"output": "main_no_config.out",
|
||||||
|
"exitCode": 1
|
||||||
|
},
|
||||||
"unstable_bare_node_builtins_enabled": {
|
"unstable_bare_node_builtins_enabled": {
|
||||||
"args": "run --unstable-bare-node-builtins main.ts",
|
"args": "run --unstable-bare-node-builtins main.ts",
|
||||||
"output": "feature_enabled.out"
|
"output": "feature_enabled.out"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
|
"imports": {},
|
||||||
"unstable": ["bare-node-builtins"]
|
"unstable": ["bare-node-builtins"]
|
||||||
}
|
}
|
||||||
|
|
3
tests/specs/run/node_prefix_missing/deno.json
Normal file
3
tests/specs/run/node_prefix_missing/deno.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"imports": {}
|
||||||
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
error: Relative import path "fs" not prefixed with / or ./ or ../
|
error: Relative import path "fs" not prefixed with / or ./ or ../ and not in import map from "[WILDLINE]/main.ts"
|
||||||
hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").
|
hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").
|
||||||
at file:///[WILDCARD]/main.ts:1:16
|
at file:///[WILDCARD]/main.ts:1:16
|
||||||
|
|
3
tests/specs/run/node_prefix_missing/main_no_config.out
Normal file
3
tests/specs/run/node_prefix_missing/main_no_config.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
error: Relative import path "fs" not prefixed with / or ./ or ../
|
||||||
|
hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").
|
||||||
|
at file:///[WILDCARD]/main.ts:1:16
|
Loading…
Add table
Reference in a new issue