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(cli): allow bare specifier for builtin node module #20728

Merged
merged 25 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
db03ccf
feat(cli): allow bare specifier for builtin node module
kt3k Sep 28, 2023
fccf6ae
refactor: use log::warn!
kt3k Sep 29, 2023
04961d8
show line and column numbers
kt3k Sep 30, 2023
6d37f6a
test: update lsp diagnostics expectation
kt3k Sep 30, 2023
100953b
show warning on bare node specifier via lsp
kt3k Sep 30, 2023
78063b9
remove dead code
kt3k Sep 30, 2023
a4308bb
Merge branch 'main' into allow-bare-specifier-for-builtin-node-modules
kt3k Sep 30, 2023
91aaf73
allow bare node specifier when import map is present
kt3k Sep 30, 2023
27de632
do not show diagnostics when bare node specifiers are explicitly mapp…
kt3k Sep 30, 2023
7c3a80a
test: update import map error expectations
kt3k Oct 1, 2023
f706dec
Merge branch 'main' into allow-bare-specifier-for-builtin-node-modules
kt3k Oct 2, 2023
ee7261e
use deno_graph 0.56.2, keep error from MappedSpecifierResolver
kt3k Oct 2, 2023
9380156
Merge branch 'main' into allow-bare-specifier-for-builtin-node-modules
kt3k Oct 4, 2023
91ff3ac
Merge branch 'main' into allow-bare-specifier-for-builtin-node-modules
kt3k Oct 5, 2023
2cbd685
add feature flag
kt3k Oct 5, 2023
517ec83
fix lsp test case
kt3k Oct 5, 2023
cab2bba
restore --quiet option in test
kt3k Oct 5, 2023
c8c5334
enable feature by config
kt3k Oct 5, 2023
bb26d6c
test lsp diagnostics with bare-node-builtins enabled by unstable fiel…
kt3k Oct 5, 2023
3b76e13
fix lint
kt3k Oct 5, 2023
8de32f5
Merge branch 'main' into allow-bare-specifier-for-builtin-node-modules
kt3k Oct 13, 2023
680b489
use feature_checker, implement CliOption#unstable_bare_node_builtins
kt3k Oct 13, 2023
accc12f
refactor: use map_or
kt3k Oct 13, 2023
54b6341
use self.options.unstable_bare_node_builtlins() directly in resolver …
kt3k Oct 13, 2023
9568be2
use map().unwrap_or() instead of map_or()
kt3k Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra
deno_cache_dir = "=0.6.0"
deno_config = "=0.3.1"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = "=0.67.0"
deno_emit = "=0.28.0"
deno_graph = "=0.55.0"
deno_doc = "=0.68.0"
deno_emit = "=0.29.0"
deno_graph = "=0.56.1"
deno_lint = { version = "=0.51.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm.workspace = true
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "exclude_runtime_main_js", "include_js_files_for_snapshotting"] }
deno_semver.workspace = true
deno_task_shell = "=0.13.2"
eszip = "=0.53.0"
eszip = "=0.54.0"
napi_sym.workspace = true

async-trait.workspace = true
Expand Down
7 changes: 6 additions & 1 deletion cli/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use deno_ast::Diagnostic;
use deno_core::error::AnyError;
use deno_graph::source::ResolveError;
use deno_graph::ModuleError;
use deno_graph::ModuleGraphError;
use deno_graph::ResolutionError;
Expand Down Expand Up @@ -44,7 +45,11 @@ fn get_module_graph_error_class(err: &ModuleGraphError) -> &'static str {
fn get_resolution_error_class(err: &ResolutionError) -> &'static str {
match err {
ResolutionError::ResolverError { error, .. } => {
get_error_class_name(error.as_ref())
use ResolveError::*;
match error.as_ref() {
Specifier(_) => "TypeError",
Other(e) => get_error_class_name(e),
}
}
_ => "TypeError",
}
Expand Down
16 changes: 11 additions & 5 deletions cli/graph_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use deno_core::parking_lot::Mutex;
use deno_core::parking_lot::RwLock;
use deno_core::ModuleSpecifier;
use deno_graph::source::Loader;
use deno_graph::source::ResolveError;
use deno_graph::GraphKind;
use deno_graph::Module;
use deno_graph::ModuleError;
Expand Down Expand Up @@ -484,10 +485,14 @@ fn get_resolution_error_bare_specifier(
{
Some(specifier.as_str())
} else if let ResolutionError::ResolverError { error, .. } = error {
if let Some(ImportMapError::UnmappedBareSpecifier(specifier, _)) =
error.downcast_ref::<ImportMapError>()
{
Some(specifier.as_str())
if let ResolveError::Other(error) = error.as_ref() {
if let Some(ImportMapError::UnmappedBareSpecifier(specifier, _)) =
error.downcast_ref::<ImportMapError>()
{
Some(specifier.as_str())
} else {
None
}
} else {
None
}
Expand Down Expand Up @@ -673,6 +678,7 @@ mod test {
use std::sync::Arc;

use deno_ast::ModuleSpecifier;
use deno_graph::source::ResolveError;
use deno_graph::Position;
use deno_graph::Range;
use deno_graph::ResolutionError;
Expand All @@ -690,7 +696,7 @@ mod test {
let specifier = ModuleSpecifier::parse("file:///file.ts").unwrap();
let err = import_map.resolve(input, &specifier).err().unwrap();
let err = ResolutionError::ResolverError {
error: Arc::new(err.into()),
error: Arc::new(ResolveError::Other(err.into())),
specifier: input.to_string(),
range: Range {
specifier,
Expand Down
Loading