From e49973d96d6817378c71bf1875b03b77d083f1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 23 Jan 2024 11:25:44 +0100 Subject: [PATCH] chore: update deno_ast and deno_graph (#22033) This upgrade unblocks support for ES decorator proposal. Co-authored-by: crowlkats --- Cargo.lock | 52 +++++++++---------- Cargo.toml | 2 +- cli/Cargo.toml | 12 ++--- cli/args/mod.rs | 4 ++ cli/tests/testdata/doc/lint_success_json.out | 6 ++- .../testdata/publish/invalid_fast_check.out | 4 +- cli/tools/doc.rs | 41 ++++++--------- cli/tools/registry/graph.rs | 2 +- cli/tools/repl/session.rs | 4 ++ 9 files changed, 65 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49168feb82..a83b513870 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1047,9 +1047,9 @@ dependencies = [ [[package]] name = "deno_ast" -version = "1.0.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87c67f73e749f78096f517cbb57967d98a8c713b39cf88b1f0b8750a84aa29" +checksum = "6fa239d4d69bb6c61bd73e0fc23e3688c7e87e1f47f2f37f4cff7a0080017299" dependencies = [ "anyhow", "base64", @@ -1250,9 +1250,9 @@ dependencies = [ [[package]] name = "deno_doc" -version = "0.93.0" +version = "0.94.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4e7c393786c7a7e99dfb720b1b0fe0a9128072f2cf40edf8dac78c8f6bc93f" +checksum = "b325fd3ab5731c22b00979389065669617530c4976cb7fe533831a7adbbdf7a6" dependencies = [ "anyhow", "cfg-if", @@ -1282,9 +1282,9 @@ dependencies = [ [[package]] name = "deno_emit" -version = "0.33.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "480cde74f7e7937e74e43f71c0fa9af7c629387b3847eb4697505741842f0d02" +checksum = "b568ac3d8f6fba012d7cb0d9fc792bfd7ee0ed70e1dfc0784030aeada0a8b31d" dependencies = [ "anyhow", "base64", @@ -1352,9 +1352,9 @@ dependencies = [ [[package]] name = "deno_graph" -version = "0.63.4" +version = "0.63.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be751db3da720bcd35d42f9c0967a04cafd52d554d79262426d1c00179b0c085" +checksum = "81e4dafc06b0025d3a2920977a1e2ef87d8521d774ad9a167f5049cb31b76ccc" dependencies = [ "anyhow", "async-trait", @@ -1461,9 +1461,9 @@ dependencies = [ [[package]] name = "deno_lint" -version = "0.53.0" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c91f26393905a81d960cf9473729660e5b5b889fa2712ba5405ac5a7598014" +checksum = "b328d3abd54ff84f99f016a378effd02056365e0734db5c5ac142f6dc9ad47ea" dependencies = [ "anyhow", "deno_ast", @@ -2124,9 +2124,9 @@ dependencies = [ [[package]] name = "dprint-plugin-typescript" -version = "0.88.8" +version = "0.88.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b16993dd982116fc2c429a1cce62e927fd4856708666c9cbd86cdbefd79dd97" +checksum = "ff4df63bcc9131ef68094ed468bf7b252e5771ed120545ea42983e99e411d467" dependencies = [ "anyhow", "deno_ast", @@ -2349,9 +2349,9 @@ dependencies = [ [[package]] name = "eszip" -version = "0.58.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214f3a524473bb2c76385c02fdada6c2791ba5e07e9ac72a6c1e373d665b1680" +checksum = "c44cb502967cc1602a5a7ed1ae7022fc371f83ae709e95bfb9b510eb25d71a5a" dependencies = [ "anyhow", "base64", @@ -5649,9 +5649,9 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "0.223.15" +version = "0.223.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e912d8387fc8592465c081b2e6b8df89443117ae4ca5160f21e08d47d7d58d7a" +checksum = "4d7530df85b1a56f6a879ca102dc59718db4bcd6bfff55fb8bb379fbeab6c88c" dependencies = [ "anyhow", "crc", @@ -5874,9 +5874,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.196.14" +version = "0.196.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eefef9f5a80afdbd4b517401dc053825d1ac0d95bb63f3ae92d2b335d8d7d4f8" +checksum = "fec185cf4d18e90b7c8b18b0d1f04a5707e6f4c7b57c1bfd5086392cd07b75a9" dependencies = [ "dashmap", "indexmap", @@ -5898,9 +5898,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_proposal" -version = "0.169.14" +version = "0.169.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86de99757fc31d8977f47c02a26e5c9a243cb63b03fe8aa8b36d79924b8fa29c" +checksum = "ed89d6ff74f60de490fb56e1cc505b057905e36c13d405d7d61dd5c9f6ee8fc9" dependencies = [ "either", "rustc-hash", @@ -5918,9 +5918,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_react" -version = "0.181.15" +version = "0.181.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9918e22caf1ea4a71085f5d818d6c0bf5c19d669cfb9d38f9fdc3da0496abdc7" +checksum = "e31a2f879fd21d18080b6c42e633e0ae8c6f3d54b83c1de876767d82b458c999" dependencies = [ "base64", "dashmap", @@ -5942,9 +5942,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "0.186.14" +version = "0.186.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d1495c969ffdc224384f1fb73646b9c1b170779f20fdb984518deb054aa522" +checksum = "3e4263372cc7cd1a3b4570ccf7438f3c1e1575f134fd05cdf074edb322480a5b" dependencies = [ "ryu-js", "serde", @@ -7051,7 +7051,7 @@ dependencies = [ "codespan-reporting", "log", "naga", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "profiling", "raw-window-handle", "ron", @@ -7092,7 +7092,7 @@ dependencies = [ "naga", "objc", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "profiling", "range-alloc", "raw-window-handle", diff --git a/Cargo.toml b/Cargo.toml index c2030b89fa..7486370898 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ license = "MIT" repository = "https://github.com/denoland/deno" [workspace.dependencies] -deno_ast = { version = "1.0.1", features = ["transpiling"] } +deno_ast = { version = "0.32.0", features = ["transpiling"] } deno_core = { version = "0.248.0" } deno_runtime = { version = "0.140.0", path = "./runtime" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fc715f8fba..6fdf7c51a2 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -57,16 +57,16 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra deno_cache_dir = "=0.6.1" deno_config = "=0.8.1" deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } -deno_doc = { version = "=0.93.0", features = ["html"] } -deno_emit = "=0.33.0" -deno_graph = "=0.63.4" -deno_lint = { version = "=0.53.0", features = ["docs"] } +deno_doc = { version = "=0.94.1", features = ["html"] } +deno_emit = "=0.34.0" +deno_graph = "=0.63.5" +deno_lint = { version = "=0.54.0", features = ["docs"] } deno_lockfile.workspace = true deno_npm = "=0.16.0" deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_semver = "=0.5.4" deno_task_shell = "=0.14.3" -eszip = "=0.58.0" +eszip = "=0.59.0" napi_sym.workspace = true async-trait.workspace = true @@ -88,7 +88,7 @@ dotenvy = "0.15.7" dprint-plugin-json = "=0.19.1" dprint-plugin-jupyter = "=0.1.2" dprint-plugin-markdown = "=0.16.3" -dprint-plugin-typescript = "=0.88.8" +dprint-plugin-typescript = "=0.88.10" encoding_rs.workspace = true env_logger = "=0.10.0" fancy-regex = "=0.10.0" diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 6cf051dca3..34448e6337 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -158,6 +158,10 @@ pub fn ts_config_to_emit_options( _ => (false, false, false, false), }; deno_ast::EmitOptions { + // TODO(bartlomieju): change it to default to `false` and only enable + // if tsconfig.json enabled experimental decorators + use_ts_decorators: true, + use_decorators_proposal: false, emit_metadata: options.emit_decorator_metadata, imports_not_used_as_values, inline_source_map: options.inline_source_map, diff --git a/cli/tests/testdata/doc/lint_success_json.out b/cli/tests/testdata/doc/lint_success_json.out index bf06a15cd2..050b2540c8 100644 --- a/cli/tests/testdata/doc/lint_success_json.out +++ b/cli/tests/testdata/doc/lint_success_json.out @@ -5,7 +5,8 @@ "location": { "filename": "file:///[WILDCARD]/lint_success.ts", "line": 2, - "col": 0 + "col": 0, + "byteIndex": 22 }, "declarationKind": "export", "jsDoc": { @@ -33,7 +34,8 @@ "location": { "filename": "file:///[WILDCARD]/lint_success.ts", "line": 4, - "col": 2 + "col": 2, + "byteIndex": 66 } } ], diff --git a/cli/tests/testdata/publish/invalid_fast_check.out b/cli/tests/testdata/publish/invalid_fast_check.out index ed731c1d19..e34cfecdf6 100644 --- a/cli/tests/testdata/publish/invalid_fast_check.out +++ b/cli/tests/testdata/publish/invalid_fast_check.out @@ -1,7 +1,7 @@ Checking fast check type graph for errors... -Missing explicit return type in the public API. - at file:///[WILDCARD]/publish/invalid_fast_check/mod.ts:2:17 +missing explicit return type in the public API + at file:///[WILDCARD]/publish/invalid_fast_check/mod.ts@68 Fixing these fast check errors is required to make the code fast check compatible which enables type checking your package's TypeScript code with the same performance as if you had distributed declaration files. Do any of these errors seem too restrictive or incorrect? Please open an issue if so to help us improve: https://github.com/denoland/deno/issues diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 4321b3ce7f..4a59ec986b 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -146,12 +146,9 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> { .await?; let (_, deno_ns) = deno_ns.first().unwrap(); - let deno_ns_symbols = - deno_doc::html::compute_namespaced_symbols(deno_ns, &[]); - - Some(deno_ns_symbols) + deno_doc::html::compute_namespaced_symbols(deno_ns, &[]) } else { - None + Default::default() }; generate_docs_directory(&doc_nodes_by_url, html_options, deno_ns) @@ -178,15 +175,21 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> { } } -struct DocResolver {} +struct DocResolver { + deno_ns: std::collections::HashSet>, +} impl deno_doc::html::HrefResolver for DocResolver { - fn resolve_global_symbol(&self, symbol: &[String], _context: &str) -> String { - format!( - "https://deno.land/api@{}?s={}", - env!("CARGO_PKG_VERSION"), - symbol.join(".") - ) + fn resolve_global_symbol(&self, symbol: &[String]) -> Option { + if self.deno_ns.contains(symbol) { + Some(format!( + "https://deno.land/api@{}?s={}", + env!("CARGO_PKG_VERSION"), + symbol.join(".") + )) + } else { + None + } } fn resolve_import_href( @@ -220,7 +223,7 @@ impl deno_doc::html::HrefResolver for DocResolver { async fn generate_docs_directory( doc_nodes_by_url: &IndexMap>, html_options: &DocHtmlFlag, - deno_ns: Option>>, + deno_ns: std::collections::HashSet>, ) -> Result<(), AnyError> { let cwd = std::env::current_dir().context("Failed to get CWD")?; let output_dir_resolved = cwd.join(&html_options.output); @@ -228,19 +231,9 @@ async fn generate_docs_directory( let options = deno_doc::html::GenerateOptions { package_name: Some(html_options.name.to_owned()), main_entrypoint: None, - global_symbols: deno_doc::html::NamespacedGlobalSymbols::new( - deno_ns - .map(|deno_ns| { - deno_ns - .into_iter() - .map(|symbol| (symbol, "deno".to_string())) - .collect() - }) - .unwrap_or_default(), - ), rewrite_map: None, hide_module_doc_title: false, - href_resolver: Rc::new(DocResolver {}), + href_resolver: Rc::new(DocResolver { deno_ns }), sidebar_flatten_namespaces: false, }; diff --git a/cli/tools/registry/graph.rs b/cli/tools/registry/graph.rs index 04b37508c4..b64350887c 100644 --- a/cli/tools/registry/graph.rs +++ b/cli/tools/registry/graph.rs @@ -103,7 +103,7 @@ pub fn surface_fast_check_type_graph_errors( ); break 'analyze_package; // no need to keep analyzing this package } else { - let message = diagnostic.message_with_range(); + let message = diagnostic.message_with_range_for_test(); if !seen_diagnostics.insert(message.clone()) { continue; } diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs index 696f5c0653..3da862e7d7 100644 --- a/cli/tools/repl/session.rs +++ b/cli/tools/repl/session.rs @@ -596,6 +596,10 @@ impl ReplSession { let transpiled_src = parsed_source .transpile(&deno_ast::EmitOptions { + // TODO(bartlomieju): change it to default to `false` and only enable + // if tsconfig.json enabled experimental decorators + use_ts_decorators: true, + use_decorators_proposal: false, emit_metadata: false, source_map: false, inline_source_map: false,