Skip to content

Commit

Permalink
refactor: upgrade to deno_ast 0.31 and deno_graph 0.59 (denoland#20965)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Oct 24, 2023
1 parent a7bd0cf commit 59a5fe5
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"ext/websocket/autobahn/reports"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.88.2.wasm",
"https://plugins.dprint.dev/typescript-0.88.3.wasm",
"https://plugins.dprint.dev/json-0.19.0.wasm",
"https://plugins.dprint.dev/markdown-0.16.2.wasm",
"https://plugins.dprint.dev/toml-0.5.4.wasm",
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ license = "MIT"
repository = "https://github.com/denoland/deno"

[workspace.dependencies]
deno_ast = { version = "0.30.2", features = ["transpiling"] }
deno_ast = { version = "0.31.0", features = ["transpiling"] }
deno_core = { version = "0.222.0" }

deno_runtime = { version = "0.129.0", path = "./runtime" }
Expand Down
12 changes: 6 additions & 6 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.4.0"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = "=0.69.1"
deno_emit = "=0.31.0"
deno_graph = "=0.58.0"
deno_lint = { version = "=0.52.1", features = ["docs"] }
deno_doc = "=0.69.2"
deno_emit = "=0.31.1"
deno_graph = "=0.59.0"
deno_lint = { version = "=0.52.2", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm = "0.15.2"
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "exclude_runtime_main_js", "include_js_files_for_snapshotting"] }
deno_semver = "0.5.1"
deno_task_shell = "=0.13.2"
eszip = "=0.55.1"
eszip = "=0.55.2"
napi_sym.workspace = true

async-trait.workspace = true
Expand All @@ -78,7 +78,7 @@ data-url.workspace = true
dissimilar = "=1.0.4"
dprint-plugin-json = "=0.19.0"
dprint-plugin-markdown = "=0.16.2"
dprint-plugin-typescript = "=0.88.2"
dprint-plugin-typescript = "=0.88.3"
encoding_rs.workspace = true
env_logger = "=0.10.0"
fancy-regex = "=0.10.0"
Expand Down
1 change: 1 addition & 0 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub fn ts_config_to_emit_options(
jsx_factory: options.jsx_factory,
jsx_fragment_factory: options.jsx_fragment_factory,
jsx_import_source: options.jsx_import_source,
precompile_jsx: false,
transform_jsx,
var_decl_imports: false,
}
Expand Down
5 changes: 4 additions & 1 deletion cli/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ fn get_module_graph_error_class(err: &ModuleGraphError) -> &'static str {
| ModuleError::UnknownPackage { .. }
| ModuleError::UnknownPackageReq { .. } => "NotFound",
},
ModuleGraphError::ResolutionError(err) => get_resolution_error_class(err),
ModuleGraphError::ResolutionError(err)
| ModuleGraphError::TypesResolutionError(err) => {
get_resolution_error_class(err)
}
}
}

Expand Down
36 changes: 24 additions & 12 deletions cli/graph_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,23 @@ pub fn graph_valid(
.errors()
.flat_map(|error| {
let is_root = match &error {
ModuleGraphError::ResolutionError(_) => false,
ModuleGraphError::ResolutionError(_)
| ModuleGraphError::TypesResolutionError(_) => false,
ModuleGraphError::ModuleError(error) => {
roots.contains(error.specifier())
}
};
let mut message = if let ModuleGraphError::ResolutionError(err) = &error {
enhanced_resolution_error_message(err)
} else {
format!("{error}")
let mut message = match &error {
ModuleGraphError::ResolutionError(resolution_error) => {
enhanced_resolution_error_message(resolution_error)
}
ModuleGraphError::TypesResolutionError(resolution_error) => {
format!(
"Failed resolving types. {}",
enhanced_resolution_error_message(resolution_error,)
)
}
ModuleGraphError::ModuleError(_) => format!("{error}"),
};

if let Some(range) = error.maybe_range() {
Expand All @@ -125,14 +133,18 @@ pub fn graph_valid(
}

// ignore invalid downgrades and invalid local imports when vendoring
if let ModuleGraphError::ResolutionError(err) = &error {
if matches!(
err,
ResolutionError::InvalidDowngrade { .. }
| ResolutionError::InvalidLocalImport { .. }
) {
return None;
match &error {
ModuleGraphError::ResolutionError(err)
| ModuleGraphError::TypesResolutionError(err) => {
if matches!(
err,
ResolutionError::InvalidDowngrade { .. }
| ResolutionError::InvalidLocalImport { .. }
) {
return None;
}
}
ModuleGraphError::ModuleError(_) => {}
}
}

Expand Down
1 change: 1 addition & 0 deletions cli/lsp/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,7 @@ fn analyze_module(
) -> ModuleResult {
match parsed_source_result {
Ok(parsed_source) => Ok(deno_graph::parse_module_from_ast(
deno_graph::GraphKind::All,
specifier,
maybe_headers,
parsed_source,
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/testdata/run/error_type_definitions.ts.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[WILDCARD]error: Relative import path "baz" not prefixed with / or ./ or ../
[WILDCARD]error: Failed resolving types. Relative import path "baz" not prefixed with / or ./ or ../
at [WILDCARD]/type_definitions/bar.d.ts:[WILDCARD]
57 changes: 25 additions & 32 deletions cli/tools/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use deno_graph::GraphKind;
use deno_graph::Module;
use deno_graph::ModuleError;
use deno_graph::ModuleGraph;
use deno_graph::ModuleGraphError;
use deno_graph::Resolution;
use deno_npm::resolution::NpmResolutionSnapshot;
use deno_npm::NpmPackageId;
Expand Down Expand Up @@ -508,8 +507,7 @@ impl<'a> GraphDisplayContext<'a> {
Ok(())
}
Err(err) => {
if let ModuleGraphError::ModuleError(ModuleError::Missing(_, _)) = *err
{
if let ModuleError::Missing(_, _) = *err {
writeln!(
writer,
"{} module could not be found",
Expand Down Expand Up @@ -648,39 +646,34 @@ impl<'a> GraphDisplayContext<'a> {

fn build_error_info(
&mut self,
err: &ModuleGraphError,
err: &ModuleError,
specifier: &ModuleSpecifier,
) -> TreeNode {
self.seen.insert(specifier.to_string());
match err {
ModuleGraphError::ModuleError(err) => match err {
ModuleError::InvalidTypeAssertion { .. } => {
self.build_error_msg(specifier, "(invalid import attribute)")
}
ModuleError::LoadingErr(_, _, _) => {
self.build_error_msg(specifier, "(loading error)")
}
ModuleError::ParseErr(_, _) => {
self.build_error_msg(specifier, "(parsing error)")
}
ModuleError::UnsupportedImportAttributeType { .. } => {
self.build_error_msg(specifier, "(unsupported import attribute)")
}
ModuleError::UnsupportedMediaType { .. } => {
self.build_error_msg(specifier, "(unsupported)")
}
ModuleError::Missing(_, _) | ModuleError::MissingDynamic(_, _) => {
self.build_error_msg(specifier, "(missing)")
}
ModuleError::UnknownPackage { .. } => {
self.build_error_msg(specifier, "(unknown package)")
}
ModuleError::UnknownPackageReq { .. } => {
self.build_error_msg(specifier, "(unknown package constraint)")
}
},
ModuleGraphError::ResolutionError(_) => {
self.build_error_msg(specifier, "(resolution error)")
ModuleError::InvalidTypeAssertion { .. } => {
self.build_error_msg(specifier, "(invalid import attribute)")
}
ModuleError::LoadingErr(_, _, _) => {
self.build_error_msg(specifier, "(loading error)")
}
ModuleError::ParseErr(_, _) => {
self.build_error_msg(specifier, "(parsing error)")
}
ModuleError::UnsupportedImportAttributeType { .. } => {
self.build_error_msg(specifier, "(unsupported import attribute)")
}
ModuleError::UnsupportedMediaType { .. } => {
self.build_error_msg(specifier, "(unsupported)")
}
ModuleError::Missing(_, _) | ModuleError::MissingDynamic(_, _) => {
self.build_error_msg(specifier, "(missing)")
}
ModuleError::UnknownPackage { .. } => {
self.build_error_msg(specifier, "(unknown package)")
}
ModuleError::UnknownPackageReq { .. } => {
self.build_error_msg(specifier, "(unknown package constraint)")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions cli/tools/repl/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ impl ReplSession {
jsx_factory: "React.createElement".into(),
jsx_fragment_factory: "React.Fragment".into(),
jsx_import_source: None,
precompile_jsx: false,
var_decl_imports: true,
})?
.text;
Expand Down

0 comments on commit 59a5fe5

Please sign in to comment.