mirror of
https://github.com/swc-project/swc.git
synced 2025-01-01 01:56:06 +03:00
refactor(es/estree): Rename: babel
=> estree
(#2846)
swc_babel_ast: - Rename as `swc_estree_ast`. swc_babel_compat: - Rename as `swc_estree_compat`. swc_babel_visit: - Rename as `swc_estree_visit`.
This commit is contained in:
parent
e4216a2e6c
commit
790a262c07
9
.github/workflows/cargo.yml
vendored
9
.github/workflows/cargo.yml
vendored
@ -117,9 +117,6 @@ jobs:
|
||||
- string_enum
|
||||
- swc
|
||||
- swc_atoms
|
||||
- swc_babel_ast
|
||||
- swc_babel_compat
|
||||
- swc_babel_visit
|
||||
- swc_bundler
|
||||
- swc_common
|
||||
- swc_css
|
||||
@ -154,16 +151,22 @@ jobs:
|
||||
- swc_ecma_visit
|
||||
- swc_ecmascript
|
||||
- swc_eq_ignore_macros
|
||||
- swc_estree_ast
|
||||
- swc_estree_compat
|
||||
- swc_estree_macros
|
||||
- swc_estree_visit
|
||||
- swc_fast_graph
|
||||
- swc_graph_analyzer
|
||||
- swc_macros_common
|
||||
- swc_node_base
|
||||
- swc_node_bundler
|
||||
- swc_node_comments
|
||||
- swc_plugin
|
||||
- swc_plugin_api
|
||||
- swc_plugin_runner
|
||||
- swc_plugin_testing
|
||||
- swc_stylis
|
||||
- swc_timer
|
||||
- swc_visit
|
||||
- swc_visit_macros
|
||||
- testing
|
||||
|
102
Cargo.lock
generated
102
Cargo.lock
generated
@ -2491,54 +2491,6 @@ dependencies = [
|
||||
"string_cache_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_babel_ast"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms 0.2.9",
|
||||
"swc_common",
|
||||
"swc_node_base",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_babel_compat"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
"copyless",
|
||||
"pretty_assertions 0.7.2",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc",
|
||||
"swc_atoms 0.2.9",
|
||||
"swc_babel_ast",
|
||||
"swc_babel_visit",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
"swc_ecma_transforms",
|
||||
"swc_ecma_utils",
|
||||
"swc_ecma_visit",
|
||||
"swc_node_base",
|
||||
"swc_node_comments",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_babel_visit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms 0.2.9",
|
||||
"swc_babel_ast",
|
||||
"swc_visit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_bundler"
|
||||
version = "0.82.1"
|
||||
@ -3189,6 +3141,60 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_estree_ast"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms 0.2.9",
|
||||
"swc_common",
|
||||
"swc_estree_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_estree_compat"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
"copyless",
|
||||
"pretty_assertions 0.7.2",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc",
|
||||
"swc_atoms 0.2.9",
|
||||
"swc_common",
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_parser",
|
||||
"swc_ecma_transforms",
|
||||
"swc_ecma_utils",
|
||||
"swc_ecma_visit",
|
||||
"swc_estree_ast",
|
||||
"swc_estree_macros",
|
||||
"swc_estree_visit",
|
||||
"swc_node_base",
|
||||
"swc_node_comments",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_estree_macros"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "swc_estree_visit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swc_atoms 0.2.9",
|
||||
"swc_estree_ast",
|
||||
"swc_estree_macros",
|
||||
"swc_visit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swc_fast_graph"
|
||||
version = "0.1.0"
|
||||
|
@ -2,10 +2,10 @@
|
||||
members = [
|
||||
"crates/jsdoc",
|
||||
"crates/node",
|
||||
"crates/swc_babel_compat",
|
||||
"crates/swc_css",
|
||||
"crates/swc_ecmascript",
|
||||
"crates/swc_ecma_plugin_ast",
|
||||
"crates/swc_estree_compat",
|
||||
"crates/swc_plugin",
|
||||
"crates/swc_plugin_runner",
|
||||
"crates/swc_plugin_testing",
|
||||
|
@ -1,18 +0,0 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Daniel Woznicki <daniel.woznicki@gmail.com>"]
|
||||
description = "Visitor implementation for babel nodes"
|
||||
documentation = "https://rustdoc.swc.rs/swc_babel_visit/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_babel_visit"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = {version = "1", features = ["derive"]}
|
||||
serde_json = "1.0.62"
|
||||
swc_atoms = {version = "0.2", path = "../swc_atoms"}
|
||||
swc_babel_ast = {version = "0.1", path = "../swc_babel_ast"}
|
||||
swc_visit = {version = "0.2", path = "../swc_visit"}
|
@ -1,17 +1,23 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>", "Daniel Woznicki <daniel.woznicki@gmail.com>"]
|
||||
description = "Babel AST node definitions"
|
||||
documentation = "https://rustdoc.swc.rs/swc_babel_ast/"
|
||||
description = "ESTree AST node definitions"
|
||||
documentation = "https://rustdoc.swc.rs/swc_estree_ast/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_babel_ast"
|
||||
name = "swc_estree_ast"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.1.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
[features]
|
||||
flavor-acorn = []
|
||||
flavor-babel = []
|
||||
|
||||
[dependencies]
|
||||
serde = {version = "1", features = ["derive"]}
|
||||
serde_json = "1.0.62"
|
||||
swc_atoms = {version = "0.2", path = "../swc_atoms"}
|
||||
swc_common = {version = "0.14", path = "../swc_common"}
|
||||
swc_node_base = {version = "0.5", path = "../swc_node_base"}
|
||||
swc_estree_macros = {version = "0.1", path = "../swc_estree_macros/"}
|
@ -1,5 +1,16 @@
|
||||
/// Explicit extern crate to use global allocator.
|
||||
extern crate swc_node_base;
|
||||
pub use class::*;
|
||||
pub use comment::*;
|
||||
pub use common::*;
|
||||
pub use decl::*;
|
||||
pub use expr::*;
|
||||
pub use flow::*;
|
||||
pub use jsx::*;
|
||||
pub use lit::*;
|
||||
pub use module::*;
|
||||
pub use object::*;
|
||||
pub use pat::*;
|
||||
pub use stmt::*;
|
||||
pub use typescript::*;
|
||||
|
||||
mod class;
|
||||
mod comment;
|
||||
@ -14,17 +25,3 @@ mod object;
|
||||
mod pat;
|
||||
mod stmt;
|
||||
mod typescript;
|
||||
|
||||
pub use class::*;
|
||||
pub use comment::*;
|
||||
pub use common::*;
|
||||
pub use decl::*;
|
||||
pub use expr::*;
|
||||
pub use flow::*;
|
||||
pub use jsx::*;
|
||||
pub use lit::*;
|
||||
pub use module::*;
|
||||
pub use object::*;
|
||||
pub use pat::*;
|
||||
pub use stmt::*;
|
||||
pub use typescript::*;
|
@ -1,14 +1,25 @@
|
||||
[package]
|
||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "Compatibility layer between babel and swc"
|
||||
documentation = "https://rustdoc.swc.rs/swc_babel_compat/"
|
||||
description = "Compatibility layer between estree and swc"
|
||||
documentation = "https://rustdoc.swc.rs/swc_estree_compat/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_babel_compat"
|
||||
name = "swc_estree_compat"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.2.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
[features]
|
||||
flavor-acorn = [
|
||||
"swc_estree_ast/flavor-acorn",
|
||||
"swc_estree_visit/flavor-acorn",
|
||||
]
|
||||
flavor-babel = [
|
||||
"swc_estree_ast/flavor-babel",
|
||||
"swc_estree_visit/flavor-babel",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
ahash = {version = "0.7.0", features = ["compile-time-rng"]}
|
||||
@ -18,13 +29,14 @@ rayon = "1.5.0"
|
||||
serde = {version = "1", features = ["derive"]}
|
||||
serde_json = "1.0.62"
|
||||
swc_atoms = {version = "0.2", path = "../swc_atoms"}
|
||||
swc_babel_ast = {version = "0.1", path = "../swc_babel_ast"}
|
||||
swc_babel_visit = {version = "0.1", path = "../swc_babel_visit"}
|
||||
swc_common = {version = "0.14", path = "../swc_common", features = ["sourcemap", "tty-emitter"]}
|
||||
swc_common = {version = "0.14", path = "../swc_common", features = ["concurrent", "sourcemap", "tty-emitter"]}
|
||||
swc_ecma_ast = {version = "0.58", path = "../swc_ecma_ast"}
|
||||
swc_ecma_parser = {version = "0.78", path = "../swc_ecma_parser"}
|
||||
swc_ecma_utils = {version = "0.52.2", path = "../swc_ecma_utils"}
|
||||
swc_ecma_visit = {version = "0.44", path = "../swc_ecma_visit"}
|
||||
swc_estree_ast = {version = "0.1", path = "../swc_estree_ast"}
|
||||
swc_estree_macros = {version = "0.1", path = "../swc_estree_macros/"}
|
||||
swc_estree_visit = {version = "0.1", path = "../swc_estree_visit"}
|
||||
swc_node_comments = {version = "0.1", path = "../swc_node_comments/"}
|
||||
|
||||
[dev-dependencies]
|
@ -5,12 +5,12 @@ extern crate test;
|
||||
|
||||
use std::{hint::black_box, io::stderr, sync::Arc};
|
||||
use swc::config::IsModule;
|
||||
use swc_babel_compat::babelify::{Babelify, Context};
|
||||
use swc_common::{errors::Handler, FileName, FilePathMapping, SourceFile, SourceMap};
|
||||
use swc_ecma_ast::{EsVersion, Program};
|
||||
use swc_ecma_parser::Syntax;
|
||||
use swc_ecma_transforms::{compat::es2020, typescript};
|
||||
use swc_ecma_visit::FoldWith;
|
||||
use swc_estree_compat::babelify::{Babelify, Context};
|
||||
use test::Bencher;
|
||||
|
||||
static SOURCE: &str = include_str!("assets/AjaxObservable.ts");
|
@ -1,15 +1,15 @@
|
||||
use crate::babelify::{extract_class_body_span, Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use serde_json::value::Value;
|
||||
use swc_babel_ast::{
|
||||
ClassBody, ClassBodyEl, ClassExpression, ClassMethod as BabelClassMethod, ClassMethodKind,
|
||||
ClassPrivateMethod, ClassPrivateProperty, ClassProperty, Decorator as BabelDecorator,
|
||||
StaticBlock as BabelStaticBlock,
|
||||
};
|
||||
use swc_ecma_ast::{
|
||||
Class, ClassMember, ClassMethod, ClassProp, Constructor, Decorator, MethodKind, PrivateMethod,
|
||||
PrivateProp, StaticBlock,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
ClassBody, ClassBodyEl, ClassExpression, ClassMethod as BabelClassMethod, ClassMethodKind,
|
||||
ClassPrivateMethod, ClassPrivateProperty, ClassProperty, Decorator as BabelDecorator,
|
||||
StaticBlock as BabelStaticBlock,
|
||||
};
|
||||
|
||||
impl Babelify for Class {
|
||||
type Output = ClassExpression;
|
@ -1,6 +1,6 @@
|
||||
use crate::babelify::{extract_class_body_span, Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_babel_ast::{
|
||||
use swc_estree_ast::{
|
||||
ClassBody, ClassDeclaration, Declaration, FunctionDeclaration, VariableDeclaration,
|
||||
VariableDeclarationKind, VariableDeclarator,
|
||||
};
|
@ -1,7 +1,14 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_babel_ast::{
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::{
|
||||
ArrayLit, ArrowExpr, AssignExpr, AwaitExpr, BinExpr, BinaryOp, BlockStmtOrExpr, CallExpr,
|
||||
ClassExpr, CondExpr, Expr, ExprOrSpread, ExprOrSuper, FnExpr, Lit, MemberExpr, MetaPropExpr,
|
||||
NewExpr, ObjectLit, ParenExpr, PatOrExpr, PropOrSpread, SeqExpr, SpreadElement, Super,
|
||||
TaggedTpl, ThisExpr, Tpl, TplElement, UnaryExpr, UpdateExpr, YieldExpr,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
ArrayExprEl, ArrayExpression, ArrowFuncExprBody, ArrowFunctionExpression, AssignmentExpression,
|
||||
AwaitExpression, BinaryExprLeft, BinaryExpression, CallExpression, Callee, ClassExpression,
|
||||
ConditionalExpression, Expression, FunctionExpression, LVal, LogicalExpression, MemberExprProp,
|
||||
@ -11,13 +18,6 @@ use swc_babel_ast::{
|
||||
TaggedTemplateExpression, TemplateElVal, TemplateElement, TemplateLiteral, TemplateLiteralExpr,
|
||||
ThisExpression, UnaryExpression, UpdateExpression, YieldExpression,
|
||||
};
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::{
|
||||
ArrayLit, ArrowExpr, AssignExpr, AwaitExpr, BinExpr, BinaryOp, BlockStmtOrExpr, CallExpr,
|
||||
ClassExpr, CondExpr, Expr, ExprOrSpread, ExprOrSuper, FnExpr, Lit, MemberExpr, MetaPropExpr,
|
||||
NewExpr, ObjectLit, ParenExpr, PatOrExpr, PropOrSpread, SeqExpr, SpreadElement, Super,
|
||||
TaggedTpl, ThisExpr, Tpl, TplElement, UnaryExpr, UpdateExpr, YieldExpr,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ExprOutput {
|
@ -1,10 +1,10 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_babel_ast::{
|
||||
use swc_ecma_ast::{Function, Param, ParamOrTsParamProp, Pat};
|
||||
use swc_estree_ast::{
|
||||
ArrayPattern, AssignmentPattern, FunctionExpression, Identifier, ObjectPattern,
|
||||
Param as BabelParam, Pattern, RestElement,
|
||||
};
|
||||
use swc_ecma_ast::{Function, Param, ParamOrTsParamProp, Pat};
|
||||
|
||||
impl Babelify for Function {
|
||||
type Output = FunctionExpression;
|
@ -1,7 +1,7 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_babel_ast::{Identifier, PrivateName as BabelPrivateName};
|
||||
use swc_ecma_ast::{BindingIdent, Ident, PrivateName};
|
||||
use swc_estree_ast::{Identifier, PrivateName as BabelPrivateName};
|
||||
|
||||
impl Babelify for BindingIdent {
|
||||
type Output = Identifier;
|
@ -1,6 +1,13 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_babel_ast::{
|
||||
use swc_common::{BytePos, Span, Spanned};
|
||||
use swc_ecma_ast::{
|
||||
JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXAttrValue, JSXClosingElement, JSXClosingFragment,
|
||||
JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpr, JSXExpr, JSXExprContainer,
|
||||
JSXFragment, JSXMemberExpr, JSXNamespacedName, JSXObject, JSXOpeningElement,
|
||||
JSXOpeningFragment, JSXSpreadChild, JSXText, Lit,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
JSXAttrName as BabelJSXAttrName, JSXAttrVal, JSXAttribute,
|
||||
JSXClosingElement as BabelJSXClosingElement, JSXClosingFragment as BabelJSXClosingFragment,
|
||||
JSXElement as BabelJSXElement, JSXElementChild as BabelJSXElementChild,
|
||||
@ -10,13 +17,6 @@ use swc_babel_ast::{
|
||||
JSXOpeningElement as BabelJSXOpeningElement, JSXOpeningFragment as BabelJSXOpeningFragment,
|
||||
JSXSpreadAttribute, JSXSpreadChild as BabelJSXSpreadChild, JSXText as BabelJSXText,
|
||||
};
|
||||
use swc_common::{BytePos, Span, Spanned};
|
||||
use swc_ecma_ast::{
|
||||
JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXAttrValue, JSXClosingElement, JSXClosingFragment,
|
||||
JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpr, JSXExpr, JSXExprContainer,
|
||||
JSXFragment, JSXMemberExpr, JSXNamespacedName, JSXObject, JSXOpeningElement,
|
||||
JSXOpeningFragment, JSXSpreadChild, JSXText, Lit,
|
||||
};
|
||||
|
||||
impl Babelify for JSXObject {
|
||||
type Output = JSXMemberExprObject;
|
@ -1,5 +1,5 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use swc_babel_ast::{
|
||||
use swc_estree_ast::{
|
||||
BigIntLiteral, BooleanLiteral, JSXText as BabelJSXText, Literal, NullLiteral, NumericLiteral,
|
||||
RegExpLiteral, StringLiteral,
|
||||
};
|
@ -1,13 +1,13 @@
|
||||
use rayon::prelude::*;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use std::sync::Arc;
|
||||
use swc_babel_ast::{BaseComment, BaseNode, Comment, LineCol, Loc};
|
||||
use swc_common::{
|
||||
comments::{CommentKind, Comments},
|
||||
sync::Lrc,
|
||||
BytePos, SourceFile, SourceMap, Span,
|
||||
};
|
||||
use swc_ecma_ast::Class;
|
||||
use swc_estree_ast::{BaseComment, BaseNode, Comment, LineCol, Loc};
|
||||
use swc_node_comments::SwcComments;
|
||||
|
||||
mod class;
|
@ -1,12 +1,12 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_babel_ast::{
|
||||
BaseNode, File, InterpreterDirective, LineCol, Loc, ModuleDeclaration, Program as BabelProgram,
|
||||
SrcType, Statement,
|
||||
};
|
||||
use swc_common::{comments::Comment, Span};
|
||||
use swc_ecma_ast::{Invalid, Module, ModuleItem, Program, Script};
|
||||
use swc_ecma_visit::{Node, Visit, VisitWith};
|
||||
use swc_estree_ast::{
|
||||
BaseNode, File, InterpreterDirective, LineCol, Loc, ModuleDeclaration, Program as BabelProgram,
|
||||
SrcType, Statement,
|
||||
};
|
||||
use swc_node_comments::SwcComments;
|
||||
|
||||
impl Babelify for Program {
|
@ -1,7 +1,13 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_babel_ast::{
|
||||
use swc_ecma_ast::{
|
||||
DefaultDecl, ExportAll, ExportDecl, ExportDefaultDecl, ExportDefaultExpr,
|
||||
ExportDefaultSpecifier, ExportNamedSpecifier, ExportNamespaceSpecifier, ExportSpecifier, Expr,
|
||||
ImportDecl, ImportDefaultSpecifier, ImportNamedSpecifier, ImportSpecifier,
|
||||
ImportStarAsSpecifier, Lit, ModuleDecl, NamedExport, ObjectLit, Prop, PropName, PropOrSpread,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
ExportAllDeclaration, ExportDefaultDeclType, ExportDefaultDeclaration,
|
||||
ExportDefaultSpecifier as BabelExportDefaultSpecifier, ExportKind, ExportNamedDeclaration,
|
||||
ExportNamespaceSpecifier as BabelExportNamespaceSpecifier,
|
||||
@ -10,12 +16,6 @@ use swc_babel_ast::{
|
||||
ImportNamespaceSpecifier, ImportSpecifier as BabelImportSpecifier, ImportSpecifierType,
|
||||
ModuleDeclaration, TSExportAssignment, TSImportEqualsDeclaration, TSNamespaceExportDeclaration,
|
||||
};
|
||||
use swc_ecma_ast::{
|
||||
DefaultDecl, ExportAll, ExportDecl, ExportDefaultDecl, ExportDefaultExpr,
|
||||
ExportDefaultSpecifier, ExportNamedSpecifier, ExportNamespaceSpecifier, ExportSpecifier, Expr,
|
||||
ImportDecl, ImportDefaultSpecifier, ImportNamedSpecifier, ImportSpecifier,
|
||||
ImportStarAsSpecifier, Lit, ModuleDecl, NamedExport, ObjectLit, Prop, PropName, PropOrSpread,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ModuleDeclOutput {
|
@ -1,6 +1,6 @@
|
||||
use swc_atoms::js_word;
|
||||
use swc_babel_ast::*;
|
||||
use swc_babel_visit::{VisitMut, VisitMutWith};
|
||||
use swc_estree_ast::*;
|
||||
use swc_estree_visit::{VisitMut, VisitMutWith};
|
||||
|
||||
struct Normalizer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use swc_babel_ast::{BinaryExprOp, LogicalExprOp, UnaryExprOp, UpdateExprOp};
|
||||
use swc_estree_ast::{BinaryExprOp, LogicalExprOp, UnaryExprOp, UpdateExprOp};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_ecma_ast::{AssignOp, BinaryOp, UnaryOp, UpdateOp};
|
@ -1,15 +1,15 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_babel_ast::{
|
||||
ArrayPattern, AssignmentPattern, AssignmentPatternLeft, CatchClauseParam, Expression,
|
||||
Identifier, LVal, ObjectKey, ObjectPattern, ObjectPatternProp, ObjectPropVal, ObjectProperty,
|
||||
Param, Pattern, PatternLike, RestElement,
|
||||
};
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::{
|
||||
ArrayPat, AssignPat, AssignPatProp, KeyValuePatProp, ObjectPat, ObjectPatProp, Pat, RestPat,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
ArrayPattern, AssignmentPattern, AssignmentPatternLeft, CatchClauseParam, Expression,
|
||||
Identifier, LVal, ObjectKey, ObjectPattern, ObjectPatternProp, ObjectPropVal, ObjectProperty,
|
||||
Param, Pattern, PatternLike, RestElement,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum PatOutput {
|
@ -1,13 +1,13 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_babel_ast::{
|
||||
AssignmentPattern, AssignmentPatternLeft, Expression, FunctionExpression, ObjectKey,
|
||||
ObjectMember, ObjectMethod, ObjectMethodKind, ObjectPropVal, ObjectProperty,
|
||||
};
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::{
|
||||
AssignProp, ComputedPropName, GetterProp, KeyValueProp, MethodProp, Prop, PropName, SetterProp,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
AssignmentPattern, AssignmentPatternLeft, Expression, FunctionExpression, ObjectKey,
|
||||
ObjectMember, ObjectMethod, ObjectMethodKind, ObjectPropVal, ObjectProperty,
|
||||
};
|
||||
|
||||
impl Babelify for Prop {
|
||||
type Output = ObjectMember;
|
@ -1,17 +1,17 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_babel_ast::{
|
||||
use swc_ecma_ast::{
|
||||
BlockStmt, BreakStmt, CatchClause, ContinueStmt, DebuggerStmt, Decl, DoWhileStmt, EmptyStmt,
|
||||
ExprStmt, ForInStmt, ForOfStmt, ForStmt, IfStmt, LabeledStmt, ReturnStmt, Stmt, SwitchCase,
|
||||
SwitchStmt, ThrowStmt, TryStmt, VarDeclOrExpr, VarDeclOrPat, WhileStmt, WithStmt,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
BlockStatement, BreakStatement, CatchClause as BabelCatchClause, ContinueStatement,
|
||||
DebuggerStatement, DoWhileStatement, EmptyStatement, ExpressionStatement, ForInStatement,
|
||||
ForOfStatement, ForStatement, ForStmtInit, ForStmtLeft, IfStatement, LabeledStatement,
|
||||
ReturnStatement, Statement, SwitchCase as BabelSwitchCase, SwitchStatement, ThrowStatement,
|
||||
TryStatement, WhileStatement, WithStatement,
|
||||
};
|
||||
use swc_ecma_ast::{
|
||||
BlockStmt, BreakStmt, CatchClause, ContinueStmt, DebuggerStmt, Decl, DoWhileStmt, EmptyStmt,
|
||||
ExprStmt, ForInStmt, ForOfStmt, ForStmt, IfStmt, LabeledStmt, ReturnStmt, Stmt, SwitchCase,
|
||||
SwitchStmt, ThrowStmt, TryStmt, VarDeclOrExpr, VarDeclOrPat, WhileStmt, WithStmt,
|
||||
};
|
||||
|
||||
impl Babelify for BlockStmt {
|
||||
type Output = BlockStatement;
|
@ -1,7 +1,7 @@
|
||||
use crate::babelify::{Babelify, Context};
|
||||
use copyless::BoxHelper;
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_babel_ast::{
|
||||
use swc_estree_ast::{
|
||||
Access, ArrayPattern, IdOrRest, IdOrString, Identifier, ObjectPattern, RestElement,
|
||||
TSAnyKeyword, TSArrayType, TSAsExpression, TSBigIntKeyword, TSBooleanKeyword,
|
||||
TSCallSignatureDeclaration, TSConditionalType, TSConstructSignatureDeclaration,
|
@ -1,10 +1,10 @@
|
||||
use super::Context;
|
||||
use crate::swcify::Swcify;
|
||||
use swc_babel_ast::{
|
||||
ClassBody, ClassBodyEl, ClassImpl, ClassMethodKind, TSExpressionWithTypeArguments,
|
||||
};
|
||||
use swc_ecma_ast::{ClassMember, Function, MethodKind, ParamOrTsParamProp, TsExprWithTypeArgs};
|
||||
use swc_ecma_utils::prop_name_to_expr;
|
||||
use swc_estree_ast::{
|
||||
ClassBody, ClassBodyEl, ClassImpl, ClassMethodKind, TSExpressionWithTypeArguments,
|
||||
};
|
||||
|
||||
impl Swcify for ClassBody {
|
||||
type Output = Vec<ClassMember>;
|
||||
@ -30,7 +30,7 @@ impl Swcify for ClassBodyEl {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ClassMethod {
|
||||
impl Swcify for swc_estree_ast::ClassMethod {
|
||||
type Output = swc_ecma_ast::ClassMember;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -86,7 +86,7 @@ impl Swcify for swc_babel_ast::ClassMethod {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ClassPrivateMethod {
|
||||
impl Swcify for swc_estree_ast::ClassPrivateMethod {
|
||||
type Output = swc_ecma_ast::PrivateMethod;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -120,7 +120,7 @@ impl Swcify for swc_babel_ast::ClassPrivateMethod {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ClassProperty {
|
||||
impl Swcify for swc_estree_ast::ClassProperty {
|
||||
type Output = swc_ecma_ast::ClassProp;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -146,7 +146,7 @@ impl Swcify for swc_babel_ast::ClassProperty {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ClassPrivateProperty {
|
||||
impl Swcify for swc_estree_ast::ClassPrivateProperty {
|
||||
type Output = swc_ecma_ast::PrivateProp;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
use swc_babel_ast::{BaseNode, LineCol, Loc};
|
||||
use swc_common::{BytePos, FileName, SourceFile, SourceMap, Span, SyntaxContext, DUMMY_SP};
|
||||
use swc_estree_ast::{BaseNode, LineCol, Loc};
|
||||
use swc_node_comments::SwcComments;
|
||||
|
||||
pub struct Context {
|
@ -1,6 +1,16 @@
|
||||
use crate::swcify::Swcify;
|
||||
use swc_atoms::js_word;
|
||||
use swc_babel_ast::{
|
||||
use swc_common::{Spanned, DUMMY_SP};
|
||||
use swc_ecma_ast::{
|
||||
op, ArrayLit, ArrowExpr, AssignExpr, AwaitExpr, BinExpr, BinaryOp, BindingIdent,
|
||||
BlockStmtOrExpr, CallExpr, ClassExpr, ComputedPropName, CondExpr, Expr, ExprOrSpread,
|
||||
ExprOrSuper, FnExpr, Function, Ident, JSXAttr, JSXAttrOrSpread, JSXAttrValue, JSXEmptyExpr,
|
||||
JSXExpr, JSXExprContainer, JSXMemberExpr, JSXObject, KeyValueProp, Lit, MemberExpr,
|
||||
MetaPropExpr, MethodProp, NewExpr, ObjectLit, OptChainExpr, ParenExpr, PatOrExpr, Prop,
|
||||
PropName, PropOrSpread, SeqExpr, SpreadElement, TaggedTpl, ThisExpr, TsAsExpr, TsNonNullExpr,
|
||||
TsTypeAssertion, TsTypeParamInstantiation, UnaryExpr, UnaryOp, UpdateExpr, YieldExpr,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
Arg, ArrayExprEl, ArrayExpression, ArrowFuncExprBody, ArrowFunctionExpression,
|
||||
AssignmentExpression, AwaitExpression, BinaryExprLeft, BinaryExprOp, BinaryExpression,
|
||||
BindExpression, CallExpression, Callee, ClassExpression, ConditionalExpression, DoExpression,
|
||||
@ -16,16 +26,6 @@ use swc_babel_ast::{
|
||||
TypeCastExpression, UnaryExprOp, UnaryExpression, UpdateExprOp, UpdateExpression,
|
||||
YieldExpression,
|
||||
};
|
||||
use swc_common::{Spanned, DUMMY_SP};
|
||||
use swc_ecma_ast::{
|
||||
op, ArrayLit, ArrowExpr, AssignExpr, AwaitExpr, BinExpr, BinaryOp, BindingIdent,
|
||||
BlockStmtOrExpr, CallExpr, ClassExpr, ComputedPropName, CondExpr, Expr, ExprOrSpread,
|
||||
ExprOrSuper, FnExpr, Function, Ident, JSXAttr, JSXAttrOrSpread, JSXAttrValue, JSXEmptyExpr,
|
||||
JSXExpr, JSXExprContainer, JSXMemberExpr, JSXObject, KeyValueProp, Lit, MemberExpr,
|
||||
MetaPropExpr, MethodProp, NewExpr, ObjectLit, OptChainExpr, ParenExpr, PatOrExpr, Prop,
|
||||
PropName, PropOrSpread, SeqExpr, SpreadElement, TaggedTpl, ThisExpr, TsAsExpr, TsNonNullExpr,
|
||||
TsTypeAssertion, TsTypeParamInstantiation, UnaryExpr, UnaryOp, UpdateExpr, YieldExpr,
|
||||
};
|
||||
|
||||
use super::Context;
|
||||
|
||||
@ -122,7 +122,7 @@ impl Swcify for BinaryExpression {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::PrivateName {
|
||||
impl Swcify for swc_estree_ast::PrivateName {
|
||||
type Output = swc_ecma_ast::PrivateName;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -398,7 +398,7 @@ impl Swcify for NewExpression {
|
||||
self.arguments
|
||||
.swcify(ctx)
|
||||
.into_iter()
|
||||
.map(|v| v.expect("failed to swcify arguemnts"))
|
||||
.map(|v| v.expect("failed to swcify arguments"))
|
||||
.collect(),
|
||||
),
|
||||
type_args: self.type_parameters.swcify(ctx),
|
||||
@ -453,7 +453,7 @@ impl Swcify for ObjectMethod {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::Decorator {
|
||||
impl Swcify for swc_estree_ast::Decorator {
|
||||
type Output = swc_ecma_ast::Decorator;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -657,7 +657,7 @@ impl Swcify for MetaProperty {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::Super {
|
||||
impl Swcify for swc_estree_ast::Super {
|
||||
type Output = swc_ecma_ast::Super;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -783,7 +783,7 @@ impl Swcify for TypeCastExpression {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXElement {
|
||||
impl Swcify for swc_estree_ast::JSXElement {
|
||||
type Output = swc_ecma_ast::JSXElement;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -796,7 +796,7 @@ impl Swcify for swc_babel_ast::JSXElement {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXOpeningElement {
|
||||
impl Swcify for swc_estree_ast::JSXOpeningElement {
|
||||
type Output = swc_ecma_ast::JSXOpeningElement;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -810,18 +810,18 @@ impl Swcify for swc_babel_ast::JSXOpeningElement {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXElementName {
|
||||
impl Swcify for swc_estree_ast::JSXElementName {
|
||||
type Output = swc_ecma_ast::JSXElementName;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::JSXElementName::Id(v) => {
|
||||
swc_estree_ast::JSXElementName::Id(v) => {
|
||||
swc_ecma_ast::JSXElementName::Ident(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::JSXElementName::Expr(v) => {
|
||||
swc_estree_ast::JSXElementName::Expr(v) => {
|
||||
swc_ecma_ast::JSXElementName::JSXMemberExpr(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::JSXElementName::Name(v) => {
|
||||
swc_estree_ast::JSXElementName::Name(v) => {
|
||||
swc_ecma_ast::JSXElementName::JSXNamespacedName(v.swcify(ctx))
|
||||
}
|
||||
}
|
||||
@ -850,13 +850,13 @@ impl Swcify for JSXMemberExprObject {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXOpeningElAttr {
|
||||
impl Swcify for swc_estree_ast::JSXOpeningElAttr {
|
||||
type Output = JSXAttrOrSpread;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::JSXOpeningElAttr::Attr(v) => JSXAttrOrSpread::JSXAttr(v.swcify(ctx)),
|
||||
swc_babel_ast::JSXOpeningElAttr::Spread(v) => {
|
||||
swc_estree_ast::JSXOpeningElAttr::Attr(v) => JSXAttrOrSpread::JSXAttr(v.swcify(ctx)),
|
||||
swc_estree_ast::JSXOpeningElAttr::Spread(v) => {
|
||||
JSXAttrOrSpread::SpreadElement(v.swcify(ctx))
|
||||
}
|
||||
}
|
||||
@ -875,13 +875,13 @@ impl Swcify for JSXAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXAttrName {
|
||||
impl Swcify for swc_estree_ast::JSXAttrName {
|
||||
type Output = swc_ecma_ast::JSXAttrName;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::JSXAttrName::Id(v) => swc_ecma_ast::JSXAttrName::Ident(v.swcify(ctx)),
|
||||
swc_babel_ast::JSXAttrName::Name(v) => {
|
||||
swc_estree_ast::JSXAttrName::Id(v) => swc_ecma_ast::JSXAttrName::Ident(v.swcify(ctx)),
|
||||
swc_estree_ast::JSXAttrName::Name(v) => {
|
||||
swc_ecma_ast::JSXAttrName::JSXNamespacedName(v.swcify(ctx))
|
||||
}
|
||||
}
|
||||
@ -944,31 +944,31 @@ impl Swcify for JSXSpreadAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXElementChild {
|
||||
impl Swcify for swc_estree_ast::JSXElementChild {
|
||||
type Output = swc_ecma_ast::JSXElementChild;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::JSXElementChild::Text(v) => {
|
||||
swc_estree_ast::JSXElementChild::Text(v) => {
|
||||
swc_ecma_ast::JSXElementChild::JSXText(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::JSXElementChild::Expr(v) => {
|
||||
swc_estree_ast::JSXElementChild::Expr(v) => {
|
||||
swc_ecma_ast::JSXElementChild::from(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::JSXElementChild::Spread(v) => {
|
||||
swc_estree_ast::JSXElementChild::Spread(v) => {
|
||||
swc_ecma_ast::JSXElementChild::from(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::JSXElementChild::Element(v) => {
|
||||
swc_estree_ast::JSXElementChild::Element(v) => {
|
||||
swc_ecma_ast::JSXElementChild::from(Box::new(v.swcify(ctx)))
|
||||
}
|
||||
swc_babel_ast::JSXElementChild::Fragment(v) => {
|
||||
swc_estree_ast::JSXElementChild::Fragment(v) => {
|
||||
swc_ecma_ast::JSXElementChild::from(v.swcify(ctx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXText {
|
||||
impl Swcify for swc_estree_ast::JSXText {
|
||||
type Output = swc_ecma_ast::JSXText;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -980,7 +980,7 @@ impl Swcify for swc_babel_ast::JSXText {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXSpreadChild {
|
||||
impl Swcify for swc_estree_ast::JSXSpreadChild {
|
||||
type Output = swc_ecma_ast::JSXSpreadChild;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -991,7 +991,7 @@ impl Swcify for swc_babel_ast::JSXSpreadChild {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXClosingElement {
|
||||
impl Swcify for swc_estree_ast::JSXClosingElement {
|
||||
type Output = swc_ecma_ast::JSXClosingElement;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -1002,7 +1002,7 @@ impl Swcify for swc_babel_ast::JSXClosingElement {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXFragment {
|
||||
impl Swcify for swc_estree_ast::JSXFragment {
|
||||
type Output = swc_ecma_ast::JSXFragment;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -1015,7 +1015,7 @@ impl Swcify for swc_babel_ast::JSXFragment {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXOpeningFragment {
|
||||
impl Swcify for swc_estree_ast::JSXOpeningFragment {
|
||||
type Output = swc_ecma_ast::JSXOpeningFragment;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -1025,7 +1025,7 @@ impl Swcify for swc_babel_ast::JSXOpeningFragment {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXClosingFragment {
|
||||
impl Swcify for swc_estree_ast::JSXClosingFragment {
|
||||
type Output = swc_ecma_ast::JSXClosingFragment;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
@ -1,7 +1,7 @@
|
||||
use crate::swcify::{Context, Swcify};
|
||||
use swc_ecma_ast::Ident;
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXNamespacedName {
|
||||
impl Swcify for swc_estree_ast::JSXNamespacedName {
|
||||
type Output = swc_ecma_ast::JSXNamespacedName;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -12,7 +12,7 @@ impl Swcify for swc_babel_ast::JSXNamespacedName {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::JSXIdentifier {
|
||||
impl Swcify for swc_estree_ast::JSXIdentifier {
|
||||
type Output = Ident;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
@ -1,12 +1,12 @@
|
||||
use super::Context;
|
||||
use crate::swcify::Swcify;
|
||||
use swc_babel_ast::{
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_ecma_ast::{BigInt, Bool, Expr, Lit, Null, Number, Regex, Str, Tpl, TplElement};
|
||||
use swc_estree_ast::{
|
||||
BigIntLiteral, BooleanLiteral, DecimalLiteral, Literal, NullLiteral, NumberLiteral,
|
||||
NumericLiteral, RegExpLiteral, StringLiteral, TemplateElement, TemplateLiteral,
|
||||
TemplateLiteralExpr,
|
||||
};
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_ecma_ast::{BigInt, Bool, Expr, Lit, Null, Number, Regex, Str, Tpl, TplElement};
|
||||
|
||||
impl Swcify for Literal {
|
||||
type Output = Lit;
|
@ -1,10 +1,10 @@
|
||||
use crate::swcify::{Context, Swcify};
|
||||
use swc_babel_ast::{
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::*;
|
||||
use swc_estree_ast::{
|
||||
ArrayPattern, AssignmentPattern, AssignmentPatternLeft, LVal, ObjectPattern, ObjectPatternProp,
|
||||
PatternLike, RestElement,
|
||||
};
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::*;
|
||||
|
||||
impl Swcify for LVal {
|
||||
type Output = Pat;
|
||||
@ -119,41 +119,43 @@ impl Swcify for ObjectPatternProp {
|
||||
}
|
||||
|
||||
match prop.value {
|
||||
swc_babel_ast::ObjectPropVal::Pattern(v) => {
|
||||
swc_estree_ast::ObjectPropVal::Pattern(v) => {
|
||||
ObjectPatProp::KeyValue(KeyValuePatProp {
|
||||
key: prop.key.swcify(ctx),
|
||||
value: Box::new(v.swcify(ctx)),
|
||||
})
|
||||
}
|
||||
swc_babel_ast::ObjectPropVal::Expr(v) => ObjectPatProp::Assign(AssignPatProp {
|
||||
span: ctx.span(&prop.base),
|
||||
key: prop.key.swcify(ctx).expect_ident(),
|
||||
value: Some(v.swcify(ctx)),
|
||||
}),
|
||||
swc_estree_ast::ObjectPropVal::Expr(v) => {
|
||||
ObjectPatProp::Assign(AssignPatProp {
|
||||
span: ctx.span(&prop.base),
|
||||
key: prop.key.swcify(ctx).expect_ident(),
|
||||
value: Some(v.swcify(ctx)),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::Pattern {
|
||||
impl Swcify for swc_estree_ast::Pattern {
|
||||
type Output = Pat;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::Pattern::Assignment(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_babel_ast::Pattern::Array(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_babel_ast::Pattern::Object(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_estree_ast::Pattern::Assignment(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_estree_ast::Pattern::Array(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_estree_ast::Pattern::Object(v) => Pat::from(v.swcify(ctx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::Param {
|
||||
impl Swcify for swc_estree_ast::Param {
|
||||
type Output = swc_ecma_ast::Param;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::Param::Id(v) => {
|
||||
swc_estree_ast::Param::Id(v) => {
|
||||
let pat = v.swcify(ctx);
|
||||
|
||||
swc_ecma_ast::Param {
|
||||
@ -162,7 +164,7 @@ impl Swcify for swc_babel_ast::Param {
|
||||
pat: pat.into(),
|
||||
}
|
||||
}
|
||||
swc_babel_ast::Param::Pat(v) => {
|
||||
swc_estree_ast::Param::Pat(v) => {
|
||||
let pat = v.swcify(ctx);
|
||||
|
||||
swc_ecma_ast::Param {
|
||||
@ -171,12 +173,12 @@ impl Swcify for swc_babel_ast::Param {
|
||||
pat,
|
||||
}
|
||||
}
|
||||
swc_babel_ast::Param::Rest(v) => swc_ecma_ast::Param {
|
||||
swc_estree_ast::Param::Rest(v) => swc_ecma_ast::Param {
|
||||
span: ctx.span(&v.base),
|
||||
decorators: v.decorators.swcify(ctx).unwrap_or_default(),
|
||||
pat: Pat::from(v.argument.swcify(ctx)),
|
||||
},
|
||||
swc_babel_ast::Param::TSProp(..) => todo!(),
|
||||
swc_estree_ast::Param::TSProp(..) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,5 @@
|
||||
use super::Context;
|
||||
use crate::swcify::Swcify;
|
||||
use swc_babel_ast::{
|
||||
BlockStatement, BreakStatement, ClassDeclaration, ContinueStatement, DebuggerStatement,
|
||||
DeclareClass, DeclareExportAllDeclaration, DeclareExportDeclaration, DeclareFunction,
|
||||
DeclareInterface, DeclareModule, DeclareModuleExports, DeclareTypeAlias, DeclareVariable,
|
||||
DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDefaultDeclType,
|
||||
ExportDefaultDeclaration, ExportKind, ExportNamedDeclaration, ExpressionStatement,
|
||||
ForInStatement, ForOfStatement, ForStatement, ForStmtInit, ForStmtLeft, FunctionDeclaration,
|
||||
IdOrString, IfStatement, ImportAttribute, ImportDeclaration, ImportKind,
|
||||
ImportNamespaceSpecifier, ImportSpecifierType, LabeledStatement, ReturnStatement, Statement,
|
||||
SwitchStatement, ThrowStatement, TryStatement, VariableDeclaration, VariableDeclarationKind,
|
||||
VariableDeclarator, WhileStatement, WithStatement,
|
||||
};
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_ecma_ast::{
|
||||
BlockStmt, BreakStmt, ClassDecl, ClassExpr, ContinueStmt, DebuggerStmt, Decl, DefaultDecl,
|
||||
@ -23,6 +11,18 @@ use swc_ecma_ast::{
|
||||
TsInterfaceDecl, TsModuleDecl, TsTypeAliasDecl, VarDecl, VarDeclKind, VarDeclOrExpr,
|
||||
VarDeclOrPat, VarDeclarator, WhileStmt, WithStmt,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
BlockStatement, BreakStatement, ClassDeclaration, ContinueStatement, DebuggerStatement,
|
||||
DeclareClass, DeclareExportAllDeclaration, DeclareExportDeclaration, DeclareFunction,
|
||||
DeclareInterface, DeclareModule, DeclareModuleExports, DeclareTypeAlias, DeclareVariable,
|
||||
DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDefaultDeclType,
|
||||
ExportDefaultDeclaration, ExportKind, ExportNamedDeclaration, ExpressionStatement,
|
||||
ForInStatement, ForOfStatement, ForStatement, ForStmtInit, ForStmtLeft, FunctionDeclaration,
|
||||
IdOrString, IfStatement, ImportAttribute, ImportDeclaration, ImportKind,
|
||||
ImportNamespaceSpecifier, ImportSpecifierType, LabeledStatement, ReturnStatement, Statement,
|
||||
SwitchStatement, ThrowStatement, TryStatement, VariableDeclaration, VariableDeclarationKind,
|
||||
VariableDeclarator, WhileStatement, WithStatement,
|
||||
};
|
||||
|
||||
impl Swcify for BlockStatement {
|
||||
type Output = BlockStmt;
|
||||
@ -287,7 +287,7 @@ impl Swcify for SwitchStatement {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::SwitchCase {
|
||||
impl Swcify for swc_estree_ast::SwitchCase {
|
||||
type Output = swc_ecma_ast::SwitchCase;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -328,7 +328,7 @@ impl Swcify for TryStatement {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::CatchClause {
|
||||
impl Swcify for swc_estree_ast::CatchClause {
|
||||
type Output = swc_ecma_ast::CatchClause;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -340,14 +340,14 @@ impl Swcify for swc_babel_ast::CatchClause {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::CatchClauseParam {
|
||||
impl Swcify for swc_estree_ast::CatchClauseParam {
|
||||
type Output = Pat;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::CatchClauseParam::Id(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_babel_ast::CatchClauseParam::Array(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_babel_ast::CatchClauseParam::Object(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_estree_ast::CatchClauseParam::Id(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_estree_ast::CatchClauseParam::Array(v) => Pat::from(v.swcify(ctx)),
|
||||
swc_estree_ast::CatchClauseParam::Object(v) => Pat::from(v.swcify(ctx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -542,25 +542,25 @@ impl Swcify for ExportNamedDeclaration {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ExportSpecifierType {
|
||||
impl Swcify for swc_estree_ast::ExportSpecifierType {
|
||||
type Output = swc_ecma_ast::ExportSpecifier;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
match self {
|
||||
swc_babel_ast::ExportSpecifierType::Export(v) => {
|
||||
swc_estree_ast::ExportSpecifierType::Export(v) => {
|
||||
swc_ecma_ast::ExportSpecifier::from(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::ExportSpecifierType::Default(v) => {
|
||||
swc_estree_ast::ExportSpecifierType::Default(v) => {
|
||||
swc_ecma_ast::ExportSpecifier::from(v.swcify(ctx))
|
||||
}
|
||||
swc_babel_ast::ExportSpecifierType::Namespace(v) => {
|
||||
swc_estree_ast::ExportSpecifierType::Namespace(v) => {
|
||||
swc_ecma_ast::ExportSpecifier::from(v.swcify(ctx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ExportSpecifier {
|
||||
impl Swcify for swc_estree_ast::ExportSpecifier {
|
||||
type Output = ExportNamedSpecifier;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -573,7 +573,7 @@ impl Swcify for swc_babel_ast::ExportSpecifier {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ExportDefaultSpecifier {
|
||||
impl Swcify for swc_estree_ast::ExportDefaultSpecifier {
|
||||
type Output = swc_ecma_ast::ExportDefaultSpecifier;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -583,7 +583,7 @@ impl Swcify for swc_babel_ast::ExportDefaultSpecifier {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ExportNamespaceSpecifier {
|
||||
impl Swcify for swc_estree_ast::ExportNamespaceSpecifier {
|
||||
type Output = swc_ecma_ast::ExportNamespaceSpecifier;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -648,7 +648,7 @@ impl Swcify for ImportSpecifierType {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ImportSpecifier {
|
||||
impl Swcify for swc_estree_ast::ImportSpecifier {
|
||||
type Output = ImportNamedSpecifier;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
||||
@ -661,7 +661,7 @@ impl Swcify for swc_babel_ast::ImportSpecifier {
|
||||
}
|
||||
}
|
||||
|
||||
impl Swcify for swc_babel_ast::ImportDefaultSpecifier {
|
||||
impl Swcify for swc_estree_ast::ImportDefaultSpecifier {
|
||||
type Output = swc_ecma_ast::ImportDefaultSpecifier;
|
||||
|
||||
fn swcify(self, ctx: &Context) -> Self::Output {
|
@ -1,14 +1,14 @@
|
||||
use super::Context;
|
||||
use crate::swcify::Swcify;
|
||||
use swc_babel_ast::{
|
||||
Access, FlowType, SuperTypeParams, TSEntityName, TSQualifiedName, TSType, TSTypeAnnotation,
|
||||
TSTypeParameter, TSTypeParameterDeclaration, TSTypeParameterInstantiation, TypeAnnotOrNoop,
|
||||
TypeParamDeclOrNoop,
|
||||
};
|
||||
use swc_ecma_ast::{
|
||||
Accessibility, Ident, TsEntityName, TsQualifiedName, TsType, TsTypeAnn, TsTypeParam,
|
||||
TsTypeParamDecl, TsTypeParamInstantiation,
|
||||
};
|
||||
use swc_estree_ast::{
|
||||
Access, FlowType, SuperTypeParams, TSEntityName, TSQualifiedName, TSType, TSTypeAnnotation,
|
||||
TSTypeParameter, TSTypeParameterDeclaration, TSTypeParameterInstantiation, TypeAnnotOrNoop,
|
||||
TypeParamDeclOrNoop,
|
||||
};
|
||||
|
||||
impl Swcify for TSTypeParameterInstantiation {
|
||||
type Output = TsTypeParamInstantiation;
|
@ -10,13 +10,13 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
use swc::{config::IsModule, Compiler};
|
||||
use swc_babel_ast::File;
|
||||
use swc_babel_compat::babelify::{normalize::normalize, Babelify, Context};
|
||||
use swc_common::{
|
||||
errors::{ColorConfig, Handler},
|
||||
FileName, FilePathMapping, SourceMap,
|
||||
};
|
||||
use swc_ecma_parser::{EsConfig, Syntax};
|
||||
use swc_estree_ast::File;
|
||||
use swc_estree_compat::babelify::{normalize::normalize, Babelify, Context};
|
||||
use test::{test_main, DynTestFn, ShouldPanic, TestDesc, TestDescAndFn, TestName, TestType};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
@ -148,7 +148,7 @@ fn run_test(src: String, expected: String, syntax: Syntax, is_module: bool) {
|
||||
};
|
||||
let mut ast = swc_ast.babelify(&ctx);
|
||||
normalize(&mut ast);
|
||||
println!("Actaul: {:?}", ast);
|
||||
println!("Actual: {:?}", ast);
|
||||
|
||||
let mut expected_ast: File = serde_json::from_str(&expected).unwrap();
|
||||
normalize(&mut expected_ast);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user