Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to swc_ecmascript 0.95.0 #39

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install rust
uses: hecrj/[email protected]
with:
rust-version: 1.55.0
rust-version: 1.57.0

- name: Install clippy and rustfmt
run: |
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_ast"
version = "0.5.0"
version = "0.6.0"
authors = ["the Deno authors"]
documentation = "https://docs.rs/deno_ast"
edition = "2018"
Expand All @@ -27,14 +27,14 @@ visit = ["swc_ecmascript/visit"]
utils = ["swc_ecmascript/utils"]

[dependencies]
data-url = { version = "0.1.0", optional = true }
dprint-swc-ecma-ast-view = { version = "0.42.0", optional = true }
data-url = { version = "0.1.1", optional = true }
dprint-swc-ecma-ast-view = { version = "0.45.0", optional = true }
serde = { version = "1.0.130", features = ["derive"] }
swc_atoms = "0.2.9"
swc_bundler = { version = "0.75.0", optional = true }
swc_common = "0.14.1"
swc_ecmascript = { version = "0.80.0", features = ["parser"] }
text_lines = { version = "0.3.0", features = ["serialization"] }
swc_bundler = { version = "0.89.0", optional = true }
swc_common = "0.15.0"
swc_ecmascript = { version = "0.95.0", features = ["parser"] }
text_lines = { version = "0.4.1", features = ["serialization"] }
url = { version = "2.2.2", features = ["serde"], optional = true }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/lexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::swc::common::Span;
use crate::swc::parser::lexer::Lexer;
use crate::swc::parser::token::Token;
use crate::MediaType;
use crate::TARGET;
use crate::ES_VERSION;

#[derive(Debug)]
pub enum TokenOrComment {
Expand All @@ -34,7 +34,7 @@ pub fn lex(source: &str, media_type: MediaType) -> Vec<LexedItem> {
let comments = SingleThreadedComments::default();
let lexer = Lexer::new(
get_syntax(media_type),
TARGET,
ES_VERSION,
StringInput::new(source, BytePos(0), BytePos(source.len() as u32)),
Some(&comments),
);
Expand Down
18 changes: 3 additions & 15 deletions src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::sync::Arc;

use crate::comments::MultiThreadedComments;
use crate::swc::ast::EsVersion;
use crate::swc::ast::Module;
use crate::swc::ast::Program;
use crate::swc::ast::Script;
Expand All @@ -12,7 +13,6 @@ use crate::swc::parser::error::Error as SwcError;
use crate::swc::parser::lexer::Lexer;
use crate::swc::parser::token::TokenAndSpan;
use crate::swc::parser::EsConfig;
use crate::swc::parser::JscTarget;
use crate::swc::parser::Syntax;
use crate::swc::parser::TsConfig;
use crate::Diagnostic;
Expand All @@ -21,7 +21,7 @@ use crate::ParsedSource;
use crate::SourceTextInfo;

/// Ecmascript version used for lexing and parsing.
pub const TARGET: JscTarget = JscTarget::Es2021;
pub const ES_VERSION: EsVersion = EsVersion::Es2021;

/// Parameters for parsing.
pub struct ParseParams {
Expand Down Expand Up @@ -191,7 +191,7 @@ fn parse_string_input(
SwcError,
> {
let comments = SingleThreadedComments::default();
let lexer = Lexer::new(syntax, TARGET, input, Some(&comments));
let lexer = Lexer::new(syntax, ES_VERSION, input, Some(&comments));

if capture_tokens {
let lexer = swc_ecmascript::parser::Capturing::new(lexer);
Expand Down Expand Up @@ -239,18 +239,8 @@ pub fn get_syntax(media_type: MediaType) -> Syntax {
/// Gets the default `EsConfig` used by `deno_ast` for the provided options.
pub fn get_es_config(jsx: bool) -> EsConfig {
EsConfig {
class_private_methods: true,
class_private_props: true,
class_props: true,
dynamic_import: true,
export_default_from: true,
export_namespace_from: true,
import_meta: true,
jsx,
nullish_coalescing: true,
num_sep: true,
optional_chaining: true,
top_level_await: true,
decorators: false,
decorators_before_export: false,
fn_bind: false,
Expand All @@ -265,9 +255,7 @@ pub fn get_ts_config(tsx: bool, dts: bool) -> TsConfig {
TsConfig {
decorators: true,
dts,
dynamic_import: true,
tsx,
import_assertions: true,
no_early_errors: false,
}
}
Expand Down