Skip to content

Commit 215f100

Browse files
authored
feat(BREAKING): drop the deno_ast dependency (#810)
This crate only used `deno_ast` for parsing and its parse diagnostics — everything else it needed already came from dprint-swc-ext, which `deno_ast` re-exports. It now parses with swc directly and owns its diagnostics, dropping 17 crates from the dependency graph. A `deno_ast` user can still hand over an already parsed AST with its comments via dprint-swc-ext's `ProgramInfoProvider` trait, so nothing has to be parsed twice. Breaking changes: - `format_parsed_source` takes `FormatParsedSourceOptions` and is generic over `ProgramInfoProvider`, so it accepts a parsed source from any crate. It no longer checks the parse diagnostics, since it can't for a source it didn't parse — `parse_program` does that instead, and `is_unsupported_syntax_error` is public for callers that parse elsewhere. - The formatting entrypoints take the swc `Syntax` the file was parsed with rather than a media type. - `format_text` takes the file text as an `Arc<str>`. Diagnostic messages are unchanged.
1 parent 0f42b28 commit 215f100

27 files changed

Lines changed: 1750 additions & 609 deletions

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Prefer using `SourcePos` from deno_ast because it abstracts
1+
# Prefer using `SourcePos` from dprint-swc-ext because it abstracts
22
# away swc's non-zero-indexed based positioning
33
disallowed-methods = [
44
"swc_common::Spanned::span",

Cargo.lock

Lines changed: 4 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ harness = false
3131

3232
[dependencies]
3333
capacity_builder = "0.5.0"
34-
deno_ast = { version = "0.53.0", features = ["view"] }
3534
dprint-core = { version = "0.69.1", features = ["formatting"] }
3635
dprint-core-macros = "0.1.0"
36+
dprint-swc-ext = { version = "0.26.1", features = ["view"] }
3737
percent-encoding = "2.3.1"
3838
rustc-hash = "2.1.1"
3939
serde = { version = "1.0.144", features = ["derive"] }

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use deno_ast::ParseDiagnostic;
2-
use deno_ast::ParseDiagnosticsError;
1+
use crate::parsing::ParseDiagnostic;
2+
use crate::parsing::ParseDiagnosticsError;
33

44
/// An error that occurred while formatting a file.
55
#[derive(Debug, thiserror::Error)]

0 commit comments

Comments
 (0)