1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

refactor: upgrade to deno_ast 0.31 and deno_graph 0.59 (#20965)

This commit is contained in:
David Sherret 2023-10-24 17:43:19 -04:00 committed by GitHub
parent a7bd0cf7a8
commit 59a5fe530f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 79 additions and 68 deletions

View file

@ -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",

28
Cargo.lock generated
View file

@ -1089,9 +1089,9 @@ dependencies = [
[[package]]
name = "deno_ast"
version = "0.30.2"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52171349bf71cf79c91264d56ff097574ff9ddfdf665ce3c6cc737b51c416b58"
checksum = "8e2cfd8ef0fe8a32192505c480e19456df1a2a057857243e1e65b8a877a26fb7"
dependencies = [
"anyhow",
"base64 0.13.1",
@ -1265,9 +1265,9 @@ dependencies = [
[[package]]
name = "deno_doc"
version = "0.69.1"
version = "0.69.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1e756efaa9a9c6c0a952281f6f94bbab4ce0acb5641fd9aa4a49f491b7a049c"
checksum = "6932fbb8bcd9154b8b3b6453dadd812999808aeaa5bfe01a2c63d075b8ad3866"
dependencies = [
"cfg-if 1.0.0",
"deno_ast",
@ -1283,9 +1283,9 @@ dependencies = [
[[package]]
name = "deno_emit"
version = "0.31.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd52f6f700236a5a9e653538969210016f8ff5563f93dfd053e97640acc7a2f4"
checksum = "0bad504e08884056bc559364364db9bc7308bd8cfda3679819656821eb7a5ce8"
dependencies = [
"anyhow",
"base64 0.13.1",
@ -1350,9 +1350,9 @@ dependencies = [
[[package]]
name = "deno_graph"
version = "0.58.0"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95542a83b6c071b2966f7b35a5ec90d56353ced1c2aaba4831377745db40935b"
checksum = "8863c48f0d7c03beef9a64173557d5ba8e32a4a3f1b8830420c6ec47668fa4c6"
dependencies = [
"anyhow",
"async-trait",
@ -1451,9 +1451,9 @@ dependencies = [
[[package]]
name = "deno_lint"
version = "0.52.1"
version = "0.52.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f6e83a85385555c43884f18a25a6b7d73ad491155e0efd8c1cee73036bbde2"
checksum = "d3f51b48abcf1d7946d1a099ac8d58fe3e84023c37820fbb409eccfd30406f56"
dependencies = [
"anyhow",
"deno_ast",
@ -1960,9 +1960,9 @@ dependencies = [
[[package]]
name = "dprint-plugin-typescript"
version = "0.88.2"
version = "0.88.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "726e373a4d4af8a42544206d8585f464f31b2f9837d6b4c8a04b07d51b8e0e2d"
checksum = "1c51dda57191fcc97f1da77927a29ecb6f5ec7133f705dcc7134533f3090681c"
dependencies = [
"anyhow",
"deno_ast",
@ -2229,9 +2229,9 @@ dependencies = [
[[package]]
name = "eszip"
version = "0.55.1"
version = "0.55.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ba11bdb068e55f2e0830b1d5c7d4829c98ab8fc1ce3513bf32d976852743069"
checksum = "1039ee8563878c6578b7595b6020590e66fecc69c66150535f83dede4ce96d5e"
dependencies = [
"anyhow",
"base64 0.21.4",

View file

@ -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" }

View file

@ -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
@ -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"

View file

@ -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,
}

View file

@ -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)
}
}
}

View file

@ -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() {
@ -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(_) => {}
}
}

View file

@ -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,

View file

@ -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]

View file

@ -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;
@ -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",
@ -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)")
}
}
}

View file

@ -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;