Skip to content

Commit 2271ba2

Browse files
committed
use swc_ecmascript crate, remove reexports
1 parent e3034bd commit 2271ba2

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

Cargo.lock

Lines changed: 11 additions & 2 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ panic = "abort"
2323
[dependencies]
2424
dprint-core = "0.24.1"
2525
swc_common = "=0.8.0"
26-
swc_ecma_ast = "=0.27.0"
27-
swc_ecma_parser = "=0.32.0"
26+
swc_ecmascript = { version = "=0.1.0", features = ["parser"] }
2827
serde = { version = "1.0.88", features = ["derive"] }
2928
serde_json = "1.0"
3029

src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,3 @@ pub use formatter::Formatter;
1212

1313
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
1414
pub use wasm_plugin::*;
15-
16-
// Re-export swc for use in Deno
17-
#[doc(hidden)]
18-
pub use swc_common;
19-
#[doc(hidden)]
20-
pub use swc_ecma_ast;
21-
#[doc(hidden)]
22-
pub use swc_ecma_parser;

src/parsing/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22
use super::*;
33
use swc_common::{BytePos, comments::{Comment}};
4-
use swc_ecma_parser::{token::{Token, TokenAndSpan}};
4+
use swc_ecmascript::parser::{token::{Token, TokenAndSpan}};
55

66
pub struct CommentCollection<'a> {
77
leading: &'a HashMap<BytePos, Vec<Comment>>,

src/parsing/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::rc::Rc;
22
use dprint_core::*;
33
use dprint_core::{parser_helpers::*,condition_resolvers, conditions::*};
4-
use swc_ecma_ast::*;
4+
use swc_ecmascript::ast::*;
55
use swc_common::{comments::{Comment, CommentKind}, BytePos, Span, Spanned};
6-
use swc_ecma_parser::{token::{TokenAndSpan}};
6+
use swc_ecmascript::parser::{token::{TokenAndSpan}};
77

88
use super::*;
99
use super::swc::*;
@@ -6115,7 +6115,7 @@ fn parse_jsx_children<'a>(opts: ParseJsxChildrenOptions<'a>, context: &mut Conte
61156115

61166116
fn should_use_space(child: &Node, context: &mut Context) -> bool {
61176117
let past_token = context.token_finder.get_previous_token(child);
6118-
if let Some(TokenAndSpan { token: swc_ecma_parser::token::Token::JSXText { .. }, span, had_line_break }) = past_token {
6118+
if let Some(TokenAndSpan { token: swc_ecmascript::parser::token::Token::JSXText { .. }, span, had_line_break }) = past_token {
61196119
let text = span.text(context);
61206120
if !had_line_break && text.ends_with(" ") {
61216121
return true;

src/parsing/parser_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::str;
22
use std::collections::{HashSet, HashMap};
33
use dprint_core::{Info, ConditionReference};
44
use swc_common::{BytePos, comments::{Comment, CommentKind}, SourceFile, Spanned, Span};
5-
use swc_ecma_ast::*;
6-
use swc_ecma_parser::{token::TokenAndSpan};
5+
use swc_ecmascript::ast::*;
6+
use swc_ecmascript::parser::{token::TokenAndSpan};
77
use super::*;
88
use super::super::configuration::*;
99
use super::super::utils::Stack;

src/parsing/swc/extensions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use swc_ecma_ast::BinaryOp;
1+
use swc_ecmascript::ast::BinaryOp;
22

33
pub trait BinaryOpExtensions {
44
fn is_add_sub(&self) -> bool;

src/parsing/swc/flatten_binary_expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use swc_ecma_ast::*;
2-
use swc_ecma_parser::{token::{TokenAndSpan}};
1+
use swc_ecmascript::ast::*;
2+
use swc_ecmascript::parser::{token::{TokenAndSpan}};
33

44
use super::*;
55
use super::super::*;

src/parsing/tokens.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::str;
22
use super::*;
33
use swc_common::{BytePos, Span};
4-
use swc_ecma_parser::{token::{Token, TokenAndSpan}};
4+
use swc_ecmascript::parser::{token::{Token, TokenAndSpan}};
55
use dprint_core::tokens::{TokenFinder as CoreTokenFinder, TokenCollection};
66

77
pub struct TokenFinder<'a> {

src/swc/parse_swc_ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use swc_common::{
55
errors::{Handler, Emitter, DiagnosticBuilder},
66
FileName, comments::{Comment, SingleThreadedComments, SingleThreadedCommentsMap}, SourceFile, BytePos
77
};
8-
use swc_ecma_ast::{Module};
9-
use swc_ecma_parser::{Parser, StringInput, Syntax, lexer::Lexer, Capturing, JscTarget, token::{TokenAndSpan}};
8+
use swc_ecmascript::ast::{Module};
9+
use swc_ecmascript::parser::{Parser, StringInput, Syntax, lexer::Lexer, Capturing, JscTarget, token::{TokenAndSpan}};
1010

1111
pub struct ParsedSourceFile<'a> {
1212
pub module: Module,
@@ -49,7 +49,7 @@ fn parse_inner<'a>(file_path: &PathBuf, file_text: &'a str) -> Result<ParsedSour
4949

5050
let comments: SingleThreadedComments = Default::default();
5151
let (module, tokens) = {
52-
let mut ts_config: swc_ecma_parser::TsConfig = Default::default();
52+
let mut ts_config: swc_ecmascript::parser::TsConfig = Default::default();
5353
ts_config.tsx = should_parse_as_jsx(file_path);
5454
ts_config.dynamic_import = true;
5555
ts_config.decorators = true;

0 commit comments

Comments
 (0)