fix(bundler): Prepare renaming of bundler (#2066)

- Rename `spack` crate to `swc_node_bundler`. (#1113)
This commit is contained in:
강동윤 2021-08-13 19:03:04 +09:00 committed by GitHub
parent fe2a063525
commit 883c1ac4e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
739 changed files with 1007 additions and 1843 deletions

View File

@ -103,7 +103,6 @@ jobs:
- from_variant
- jsdoc
- node
- spack
- string_enum
- swc
- swc_atoms
@ -138,6 +137,7 @@ jobs:
- swc_eq_ignore_macros
- swc_macros_common
- swc_node_base
- swc_node_bundler
- swc_visit
- swc_visit_macros
- testing
@ -145,7 +145,7 @@ jobs:
- wasm
exclude:
- os: windows-latest
crate: spack
crate: swc_node_bundler
steps:
- name: Handle line endings
@ -232,10 +232,9 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-03-30
- name: Create rustdoc
run: cargo +nightly-2021-03-30 doc
run: cargo doc
- name: Create CNAME
run: |

View File

@ -115,4 +115,4 @@ jobs:
- name: (spack) example react app
run: |
export PATH="$PATH:$HOME/npm/bin"
(cd spack/tests/integration/react && npm i && npx spack)
(cd node/bundler/tests/integration/react && npm i && npx spack)

View File

@ -40,6 +40,7 @@ common
CONTRIBUTING.md
ecmascript
macros
node
node-swc
scripts
spack

View File

@ -1,3 +1,4 @@
format_strings = true
merge_imports = true
use_field_init_shorthand = true
wrap_comments = true

70
Cargo.lock generated
View File

@ -1077,7 +1077,6 @@ dependencies = [
"path-clean",
"serde",
"serde_json",
"spack",
"swc",
"swc_atoms",
"swc_babel_compat",
@ -1086,6 +1085,7 @@ dependencies = [
"swc_ecma_ast",
"swc_ecma_parser",
"swc_node_base",
"swc_node_bundler",
]
[[package]]
@ -2024,39 +2024,6 @@ dependencies = [
"url",
]
[[package]]
name = "spack"
version = "0.0.0"
dependencies = [
"anyhow",
"dashmap",
"fxhash",
"is-macro",
"log",
"once_cell",
"pretty_assertions 0.6.1",
"pretty_env_logger",
"regex",
"serde",
"serde_json",
"string_enum",
"swc",
"swc_atoms",
"swc_bundler",
"swc_common",
"swc_ecma_ast",
"swc_ecma_codegen",
"swc_ecma_loader",
"swc_ecma_parser",
"swc_ecma_transforms",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_node_base",
"tempfile",
"testing",
"walkdir",
]
[[package]]
name = "st-map"
version = "0.1.4"
@ -2755,13 +2722,46 @@ dependencies = [
[[package]]
name = "swc_node_base"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"dashmap",
"mimalloc-rust",
"swc_common",
]
[[package]]
name = "swc_node_bundler"
version = "0.0.0"
dependencies = [
"anyhow",
"dashmap",
"fxhash",
"is-macro",
"log",
"once_cell",
"pretty_assertions 0.6.1",
"pretty_env_logger",
"regex",
"serde",
"serde_json",
"string_enum",
"swc",
"swc_atoms",
"swc_bundler",
"swc_common",
"swc_ecma_ast",
"swc_ecma_codegen",
"swc_ecma_loader",
"swc_ecma_parser",
"swc_ecma_transforms",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_node_base",
"tempfile",
"testing",
"walkdir",
]
[[package]]
name = "swc_visit"
version = "0.2.5"

View File

@ -3,16 +3,12 @@
extern crate test;
use std::io::stderr;
use std::{hint::black_box, sync::Arc};
use swc_babel_compat::babelify::Babelify;
use swc_babel_compat::babelify::Context;
use swc_common::SourceFile;
use swc_common::{errors::Handler, FileName, FilePathMapping, SourceMap};
use std::{hint::black_box, io::stderr, sync::Arc};
use swc_babel_compat::babelify::{Babelify, Context};
use swc_common::{errors::Handler, FileName, FilePathMapping, SourceFile, SourceMap};
use swc_ecma_ast::Program;
use swc_ecma_parser::{JscTarget, Syntax};
use swc_ecma_transforms::compat::es2020;
use swc_ecma_transforms::typescript;
use swc_ecma_transforms::{compat::es2020, typescript};
use swc_ecma_visit::FoldWith;
use test::Bencher;

View File

@ -1,6 +1,4 @@
use crate::babelify::extract_class_body_span;
use crate::babelify::Babelify;
use crate::babelify::Context;
use crate::babelify::{extract_class_body_span, Babelify, Context};
use copyless::BoxHelper;
use serde_json::value::Value;
use swc_babel_ast::{

View File

@ -1,16 +1,13 @@
use rayon::prelude::*;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::{de::DeserializeOwned, Serialize};
use std::sync::Arc;
use swc::SwcComments;
use swc_babel_ast::{BaseComment, BaseNode, Comment, LineCol, Loc};
use swc_common::comments::CommentKind;
use swc_common::comments::Comments;
use swc_common::sync::Lrc;
use swc_common::BytePos;
use swc_common::SourceFile;
use swc_common::SourceMap;
use swc_common::Span;
use swc_common::{
comments::{CommentKind, Comments},
sync::Lrc,
BytePos, SourceFile, SourceMap, Span,
};
use swc_ecma_ast::Class;
mod class;

View File

@ -1,7 +1,6 @@
use crate::babelify::{Babelify, Context};
use copyless::BoxHelper;
use swc_atoms::js_word;
use swc_atoms::JsWord;
use swc_atoms::{js_word, JsWord};
use swc_babel_ast::{
Access, ArrayPattern, IdOrRest, IdOrString, Identifier, ObjectPattern, RestElement,
TSAnyKeyword, TSArrayType, TSAsExpression, TSBigIntKeyword, TSBooleanKeyword,

View File

@ -1,15 +1,9 @@
use super::Context;
use crate::swcify::Swcify;
use swc_babel_ast::ClassBody;
use swc_babel_ast::ClassBodyEl;
use swc_babel_ast::ClassImpl;
use swc_babel_ast::ClassMethodKind;
use swc_babel_ast::TSExpressionWithTypeArguments;
use swc_ecma_ast::ClassMember;
use swc_ecma_ast::Function;
use swc_ecma_ast::MethodKind;
use swc_ecma_ast::ParamOrTsParamProp;
use swc_ecma_ast::TsExprWithTypeArgs;
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;
impl Swcify for ClassBody {

View File

@ -1,15 +1,7 @@
use std::sync::Arc;
use swc::SwcComments;
use swc_babel_ast::BaseNode;
use swc_babel_ast::LineCol;
use swc_babel_ast::Loc;
use swc_common::BytePos;
use swc_common::FileName;
use swc_common::SourceFile;
use swc_common::SourceMap;
use swc_common::Span;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_babel_ast::{BaseNode, LineCol, Loc};
use swc_common::{BytePos, FileName, SourceFile, SourceMap, Span, SyntaxContext, DUMMY_SP};
pub struct Context {
#[allow(unused)]

View File

@ -1,121 +1,31 @@
use crate::swcify::Swcify;
use swc_atoms::js_word;
use swc_babel_ast::Arg;
use swc_babel_ast::ArrayExprEl;
use swc_babel_ast::ArrayExpression;
use swc_babel_ast::ArrowFuncExprBody;
use swc_babel_ast::ArrowFunctionExpression;
use swc_babel_ast::AssignmentExpression;
use swc_babel_ast::AwaitExpression;
use swc_babel_ast::BinaryExprLeft;
use swc_babel_ast::BinaryExprOp;
use swc_babel_ast::BinaryExpression;
use swc_babel_ast::BindExpression;
use swc_babel_ast::CallExpression;
use swc_babel_ast::Callee;
use swc_babel_ast::ClassExpression;
use swc_babel_ast::ConditionalExpression;
use swc_babel_ast::DoExpression;
use swc_babel_ast::Expression;
use swc_babel_ast::FunctionExpression;
use swc_babel_ast::Identifier;
use swc_babel_ast::Import;
use swc_babel_ast::JSXAttrVal;
use swc_babel_ast::JSXAttribute;
use swc_babel_ast::JSXEmptyExpression;
use swc_babel_ast::JSXExprContainerExpr;
use swc_babel_ast::JSXExpressionContainer;
use swc_babel_ast::JSXMemberExprObject;
use swc_babel_ast::JSXMemberExpression;
use swc_babel_ast::JSXSpreadAttribute;
use swc_babel_ast::LogicalExprOp;
use swc_babel_ast::LogicalExpression;
use swc_babel_ast::MemberExprProp;
use swc_babel_ast::MemberExpression;
use swc_babel_ast::MetaProperty;
use swc_babel_ast::ModuleExpression;
use swc_babel_ast::NewExpression;
use swc_babel_ast::ObjectExprProp;
use swc_babel_ast::ObjectExpression;
use swc_babel_ast::ObjectKey;
use swc_babel_ast::ObjectMethod;
use swc_babel_ast::ObjectPropVal;
use swc_babel_ast::ObjectProperty;
use swc_babel_ast::OptionalCallExpression;
use swc_babel_ast::OptionalMemberExprProp;
use swc_babel_ast::OptionalMemberExpression;
use swc_babel_ast::ParenthesizedExpression;
use swc_babel_ast::PatternLike;
use swc_babel_ast::PipelinePrimaryTopicReference;
use swc_babel_ast::RecordExpression;
use swc_babel_ast::SequenceExpression;
use swc_babel_ast::TSAsExpression;
use swc_babel_ast::TSNonNullExpression;
use swc_babel_ast::TSTypeAssertion;
use swc_babel_ast::TaggedTemplateExprTypeParams;
use swc_babel_ast::TaggedTemplateExpression;
use swc_babel_ast::ThisExpression;
use swc_babel_ast::TupleExpression;
use swc_babel_ast::TypeCastExpression;
use swc_babel_ast::UnaryExprOp;
use swc_babel_ast::UnaryExpression;
use swc_babel_ast::UpdateExprOp;
use swc_babel_ast::UpdateExpression;
use swc_babel_ast::YieldExpression;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use swc_ecma_ast::op;
use swc_ecma_ast::ArrayLit;
use swc_ecma_ast::ArrowExpr;
use swc_ecma_ast::AssignExpr;
use swc_ecma_ast::AwaitExpr;
use swc_ecma_ast::BinExpr;
use swc_ecma_ast::BinaryOp;
use swc_ecma_ast::BindingIdent;
use swc_ecma_ast::BlockStmtOrExpr;
use swc_ecma_ast::CallExpr;
use swc_ecma_ast::ClassExpr;
use swc_ecma_ast::ComputedPropName;
use swc_ecma_ast::CondExpr;
use swc_ecma_ast::Expr;
use swc_ecma_ast::ExprOrSpread;
use swc_ecma_ast::ExprOrSuper;
use swc_ecma_ast::FnExpr;
use swc_ecma_ast::Function;
use swc_ecma_ast::Ident;
use swc_ecma_ast::JSXAttr;
use swc_ecma_ast::JSXAttrOrSpread;
use swc_ecma_ast::JSXAttrValue;
use swc_ecma_ast::JSXEmptyExpr;
use swc_ecma_ast::JSXExpr;
use swc_ecma_ast::JSXExprContainer;
use swc_ecma_ast::JSXMemberExpr;
use swc_ecma_ast::JSXObject;
use swc_ecma_ast::KeyValueProp;
use swc_ecma_ast::Lit;
use swc_ecma_ast::MemberExpr;
use swc_ecma_ast::MetaPropExpr;
use swc_ecma_ast::MethodProp;
use swc_ecma_ast::NewExpr;
use swc_ecma_ast::ObjectLit;
use swc_ecma_ast::OptChainExpr;
use swc_ecma_ast::ParenExpr;
use swc_ecma_ast::PatOrExpr;
use swc_ecma_ast::Prop;
use swc_ecma_ast::PropName;
use swc_ecma_ast::PropOrSpread;
use swc_ecma_ast::SeqExpr;
use swc_ecma_ast::SpreadElement;
use swc_ecma_ast::TaggedTpl;
use swc_ecma_ast::ThisExpr;
use swc_ecma_ast::TsAsExpr;
use swc_ecma_ast::TsNonNullExpr;
use swc_ecma_ast::TsTypeAssertion;
use swc_ecma_ast::TsTypeParamInstantiation;
use swc_ecma_ast::UnaryExpr;
use swc_ecma_ast::UnaryOp;
use swc_ecma_ast::UpdateExpr;
use swc_ecma_ast::YieldExpr;
use swc_babel_ast::{
Arg, ArrayExprEl, ArrayExpression, ArrowFuncExprBody, ArrowFunctionExpression,
AssignmentExpression, AwaitExpression, BinaryExprLeft, BinaryExprOp, BinaryExpression,
BindExpression, CallExpression, Callee, ClassExpression, ConditionalExpression, DoExpression,
Expression, FunctionExpression, Identifier, Import, JSXAttrVal, JSXAttribute,
JSXEmptyExpression, JSXExprContainerExpr, JSXExpressionContainer, JSXMemberExprObject,
JSXMemberExpression, JSXSpreadAttribute, LogicalExprOp, LogicalExpression, MemberExprProp,
MemberExpression, MetaProperty, ModuleExpression, NewExpression, ObjectExprProp,
ObjectExpression, ObjectKey, ObjectMethod, ObjectPropVal, ObjectProperty,
OptionalCallExpression, OptionalMemberExprProp, OptionalMemberExpression,
ParenthesizedExpression, PatternLike, PipelinePrimaryTopicReference, RecordExpression,
SequenceExpression, TSAsExpression, TSNonNullExpression, TSTypeAssertion,
TaggedTemplateExprTypeParams, TaggedTemplateExpression, ThisExpression, TupleExpression,
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;

View File

@ -1,5 +1,4 @@
use crate::swcify::Context;
use crate::swcify::Swcify;
use crate::swcify::{Context, Swcify};
use swc_ecma_ast::Ident;
impl Swcify for swc_babel_ast::JSXNamespacedName {

View File

@ -1,28 +1,12 @@
use super::Context;
use crate::swcify::Swcify;
use swc_babel_ast::BigIntLiteral;
use swc_babel_ast::BooleanLiteral;
use swc_babel_ast::DecimalLiteral;
use swc_babel_ast::Literal;
use swc_babel_ast::NullLiteral;
use swc_babel_ast::NumberLiteral;
use swc_babel_ast::NumericLiteral;
use swc_babel_ast::RegExpLiteral;
use swc_babel_ast::StringLiteral;
use swc_babel_ast::TemplateElement;
use swc_babel_ast::TemplateLiteral;
use swc_babel_ast::TemplateLiteralExpr;
use swc_babel_ast::{
BigIntLiteral, BooleanLiteral, DecimalLiteral, Literal, NullLiteral, NumberLiteral,
NumericLiteral, RegExpLiteral, StringLiteral, TemplateElement, TemplateLiteral,
TemplateLiteralExpr,
};
use swc_common::DUMMY_SP;
use swc_ecma_ast::BigInt;
use swc_ecma_ast::Bool;
use swc_ecma_ast::Expr;
use swc_ecma_ast::Lit;
use swc_ecma_ast::Null;
use swc_ecma_ast::Number;
use swc_ecma_ast::Regex;
use swc_ecma_ast::Str;
use swc_ecma_ast::Tpl;
use swc_ecma_ast::TplElement;
use swc_ecma_ast::{BigInt, Bool, Expr, Lit, Null, Number, Regex, Str, Tpl, TplElement};
impl Swcify for Literal {
type Output = Lit;

View File

@ -1,13 +1,8 @@
use crate::swcify::Context;
use crate::swcify::Swcify;
use swc_babel_ast::ArrayPattern;
use swc_babel_ast::AssignmentPattern;
use swc_babel_ast::AssignmentPatternLeft;
use swc_babel_ast::LVal;
use swc_babel_ast::ObjectPattern;
use swc_babel_ast::ObjectPatternProp;
use swc_babel_ast::PatternLike;
use swc_babel_ast::RestElement;
use crate::swcify::{Context, Swcify};
use swc_babel_ast::{
ArrayPattern, AssignmentPattern, AssignmentPatternLeft, LVal, ObjectPattern, ObjectPatternProp,
PatternLike, RestElement,
};
use swc_common::Spanned;
use swc_ecma_ast::*;

View File

@ -1,104 +1,28 @@
use super::Context;
use crate::swcify::Swcify;
use swc_babel_ast::BlockStatement;
use swc_babel_ast::BreakStatement;
use swc_babel_ast::ClassDeclaration;
use swc_babel_ast::ContinueStatement;
use swc_babel_ast::DebuggerStatement;
use swc_babel_ast::DeclareClass;
use swc_babel_ast::DeclareExportAllDeclaration;
use swc_babel_ast::DeclareExportDeclaration;
use swc_babel_ast::DeclareFunction;
use swc_babel_ast::DeclareInterface;
use swc_babel_ast::DeclareModule;
use swc_babel_ast::DeclareModuleExports;
use swc_babel_ast::DeclareTypeAlias;
use swc_babel_ast::DeclareVariable;
use swc_babel_ast::DoWhileStatement;
use swc_babel_ast::EmptyStatement;
use swc_babel_ast::ExportAllDeclaration;
use swc_babel_ast::ExportDefaultDeclType;
use swc_babel_ast::ExportDefaultDeclaration;
use swc_babel_ast::ExportNamedDeclaration;
use swc_babel_ast::ExpressionStatement;
use swc_babel_ast::ForInStatement;
use swc_babel_ast::ForOfStatement;
use swc_babel_ast::ForStatement;
use swc_babel_ast::ForStmtInit;
use swc_babel_ast::ForStmtLeft;
use swc_babel_ast::FunctionDeclaration;
use swc_babel_ast::IdOrString;
use swc_babel_ast::IfStatement;
use swc_babel_ast::ImportAttribute;
use swc_babel_ast::ImportDeclaration;
use swc_babel_ast::ImportNamespaceSpecifier;
use swc_babel_ast::ImportSpecifierType;
use swc_babel_ast::LabeledStatement;
use swc_babel_ast::ReturnStatement;
use swc_babel_ast::Statement;
use swc_babel_ast::SwitchStatement;
use swc_babel_ast::ThrowStatement;
use swc_babel_ast::TryStatement;
use swc_babel_ast::VariableDeclaration;
use swc_babel_ast::VariableDeclarationKind;
use swc_babel_ast::VariableDeclarator;
use swc_babel_ast::WhileStatement;
use swc_babel_ast::WithStatement;
use swc_babel_ast::{
BlockStatement, BreakStatement, ClassDeclaration, ContinueStatement, DebuggerStatement,
DeclareClass, DeclareExportAllDeclaration, DeclareExportDeclaration, DeclareFunction,
DeclareInterface, DeclareModule, DeclareModuleExports, DeclareTypeAlias, DeclareVariable,
DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDefaultDeclType,
ExportDefaultDeclaration, ExportNamedDeclaration, ExpressionStatement, ForInStatement,
ForOfStatement, ForStatement, ForStmtInit, ForStmtLeft, FunctionDeclaration, IdOrString,
IfStatement, ImportAttribute, ImportDeclaration, ImportNamespaceSpecifier, ImportSpecifierType,
LabeledStatement, ReturnStatement, Statement, SwitchStatement, ThrowStatement, TryStatement,
VariableDeclaration, VariableDeclarationKind, VariableDeclarator, WhileStatement,
WithStatement,
};
use swc_common::DUMMY_SP;
use swc_ecma_ast::BlockStmt;
use swc_ecma_ast::BreakStmt;
use swc_ecma_ast::ClassDecl;
use swc_ecma_ast::ClassExpr;
use swc_ecma_ast::ContinueStmt;
use swc_ecma_ast::DebuggerStmt;
use swc_ecma_ast::Decl;
use swc_ecma_ast::DefaultDecl;
use swc_ecma_ast::DoWhileStmt;
use swc_ecma_ast::EmptyStmt;
use swc_ecma_ast::ExportAll;
use swc_ecma_ast::ExportDecl;
use swc_ecma_ast::ExportDefaultDecl;
use swc_ecma_ast::ExportDefaultExpr;
use swc_ecma_ast::ExportNamedSpecifier;
use swc_ecma_ast::Expr;
use swc_ecma_ast::ExprStmt;
use swc_ecma_ast::FnDecl;
use swc_ecma_ast::FnExpr;
use swc_ecma_ast::ForInStmt;
use swc_ecma_ast::ForOfStmt;
use swc_ecma_ast::ForStmt;
use swc_ecma_ast::IfStmt;
use swc_ecma_ast::ImportDecl;
use swc_ecma_ast::ImportNamedSpecifier;
use swc_ecma_ast::ImportSpecifier;
use swc_ecma_ast::ImportStarAsSpecifier;
use swc_ecma_ast::KeyValueProp;
use swc_ecma_ast::LabeledStmt;
use swc_ecma_ast::Lit;
use swc_ecma_ast::ModuleDecl;
use swc_ecma_ast::ModuleItem;
use swc_ecma_ast::NamedExport;
use swc_ecma_ast::ObjectLit;
use swc_ecma_ast::Pat;
use swc_ecma_ast::Prop;
use swc_ecma_ast::PropName;
use swc_ecma_ast::PropOrSpread;
use swc_ecma_ast::ReturnStmt;
use swc_ecma_ast::Stmt;
use swc_ecma_ast::SwitchStmt;
use swc_ecma_ast::ThrowStmt;
use swc_ecma_ast::TryStmt;
use swc_ecma_ast::TsExportAssignment;
use swc_ecma_ast::TsInterfaceDecl;
use swc_ecma_ast::TsModuleDecl;
use swc_ecma_ast::TsTypeAliasDecl;
use swc_ecma_ast::VarDecl;
use swc_ecma_ast::VarDeclKind;
use swc_ecma_ast::VarDeclOrExpr;
use swc_ecma_ast::VarDeclOrPat;
use swc_ecma_ast::VarDeclarator;
use swc_ecma_ast::WhileStmt;
use swc_ecma_ast::WithStmt;
use swc_ecma_ast::{
BlockStmt, BreakStmt, ClassDecl, ClassExpr, ContinueStmt, DebuggerStmt, Decl, DefaultDecl,
DoWhileStmt, EmptyStmt, ExportAll, ExportDecl, ExportDefaultDecl, ExportDefaultExpr,
ExportNamedSpecifier, Expr, ExprStmt, FnDecl, FnExpr, ForInStmt, ForOfStmt, ForStmt, IfStmt,
ImportDecl, ImportNamedSpecifier, ImportSpecifier, ImportStarAsSpecifier, KeyValueProp,
LabeledStmt, Lit, ModuleDecl, ModuleItem, NamedExport, ObjectLit, Pat, Prop, PropName,
PropOrSpread, ReturnStmt, Stmt, SwitchStmt, ThrowStmt, TryStmt, TsExportAssignment,
TsInterfaceDecl, TsModuleDecl, TsTypeAliasDecl, VarDecl, VarDeclKind, VarDeclOrExpr,
VarDeclOrPat, VarDeclarator, WhileStmt, WithStmt,
};
impl Swcify for BlockStatement {
type Output = BlockStmt;

View File

@ -1,26 +1,14 @@
use super::Context;
use crate::swcify::Swcify;
use swc_babel_ast::Access;
use swc_babel_ast::FlowType;
use swc_babel_ast::SuperTypeParams;
use swc_babel_ast::TSEntityName;
use swc_babel_ast::TSQualifiedName;
use swc_babel_ast::TSType;
use swc_babel_ast::TSTypeAnnotation;
use swc_babel_ast::TSTypeParameter;
use swc_babel_ast::TSTypeParameterDeclaration;
use swc_babel_ast::TSTypeParameterInstantiation;
use swc_babel_ast::TypeAnnotOrNoop;
use swc_babel_ast::TypeParamDeclOrNoop;
use swc_ecma_ast::Accessibility;
use swc_ecma_ast::Ident;
use swc_ecma_ast::TsEntityName;
use swc_ecma_ast::TsQualifiedName;
use swc_ecma_ast::TsType;
use swc_ecma_ast::TsTypeAnn;
use swc_ecma_ast::TsTypeParam;
use swc_ecma_ast::TsTypeParamDecl;
use swc_ecma_ast::TsTypeParamInstantiation;
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,
};
impl Swcify for TSTypeParameterInstantiation {
type Output = TsTypeParamInstantiation;

View File

@ -11,14 +11,10 @@ use std::{
};
use swc::Compiler;
use swc_babel_ast::File;
use swc_babel_compat::babelify::normalize::normalize;
use swc_babel_compat::babelify::{Babelify, Context};
use swc_babel_compat::babelify::{normalize::normalize, Babelify, Context};
use swc_common::{
errors::{ColorConfig, Handler},
FileName,
// FilePathMapping, SourceMap, FileName, SourceFile,
FilePathMapping,
SourceMap,
FileName, FilePathMapping, SourceMap,
};
use swc_ecma_parser::{EsConfig, Syntax};
use test::{test_main, DynTestFn, ShouldPanic, TestDesc, TestDescAndFn, TestName, TestType};

View File

@ -1,13 +1,12 @@
use crate::modules::Modules;
use crate::{
bundler::{chunk::merge::Ctx, load::TransformedModule},
modules::Modules,
Bundler, Load, Resolve,
};
use anyhow::Error;
use std::sync::atomic::Ordering;
use swc_atoms::js_word;
use swc_common::Span;
use swc_common::{SyntaxContext, DUMMY_SP};
use swc_common::{Span, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::{ModuleItem, *};
use swc_ecma_utils::{quote_ident, undefined, ExprFactory};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};

View File

@ -1,5 +1,4 @@
use crate::modules::Modules;
use crate::{bundler::chunk::merge::Ctx, Bundler, Load, ModuleId, Resolve};
use crate::{bundler::chunk::merge::Ctx, modules::Modules, Bundler, Load, ModuleId, Resolve};
use anyhow::{bail, Error};
use std::mem::take;
use swc_atoms::js_word;

View File

@ -1,19 +1,19 @@
use crate::bundler::keywords::KeywordRenamer;
use crate::dep_graph::ModuleGraph;
use crate::inline::inline;
use crate::modules::Modules;
use crate::{
bundler::load::{Imports, TransformedModule},
bundler::{
keywords::KeywordRenamer,
load::{Imports, TransformedModule},
},
dep_graph::ModuleGraph,
id::{Id, ModuleId},
inline::inline,
load::Load,
modules::Modules,
resolve::Resolve,
util::{CloneMap, ExprExt, VarDeclaratorExt},
Bundler, Hook, ModuleRecord,
};
use anyhow::Error;
use fxhash::FxBuildHasher;
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use fxhash::{FxBuildHasher, FxHashMap, FxHashSet};
use indexmap::IndexSet;
use petgraph::EdgeDirection;
#[cfg(feature = "concurrent")]

View File

@ -5,8 +5,7 @@ use crate::{
};
use ahash::AHashMap;
use anyhow::{Context, Error};
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use fxhash::{FxHashMap, FxHashSet};
#[cfg(feature = "rayon")]
use rayon::iter::ParallelIterator;
use std::time::Instant;

View File

@ -1,9 +1,10 @@
use crate::dep_graph::ModuleGraph;
use crate::{bundler::load::TransformedModule, BundleKind, Bundler, Load, ModuleId, Resolve};
use crate::{
bundler::load::TransformedModule, dep_graph::ModuleGraph, BundleKind, Bundler, Load, ModuleId,
Resolve,
};
use ahash::AHashMap;
use anyhow::{bail, Error};
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use fxhash::{FxHashMap, FxHashSet};
#[cfg(test)]
mod tests;

View File

@ -1,16 +1,13 @@
use super::Bundler;
use crate::{load::Load, resolve::Resolve};
use anyhow::{Context, Error};
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use fxhash::{FxHashMap, FxHashSet};
use retain_mut::RetainMut;
use swc_atoms::{js_word, JsWord};
use swc_common::{sync::Lrc, FileName, Mark, Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::{find_ids, ident::IdentLike, Id};
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
#[cfg(test)]
mod tests;

View File

@ -1,12 +1,9 @@
use crate::id::Id;
use crate::util::MapWithMut;
use crate::{id::Id, util::MapWithMut};
use fxhash::FxHashMap;
use swc_atoms::js_word;
use swc_ecma_ast::*;
use swc_ecma_utils::private_ident;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
#[derive(Default)]
pub struct KeywordRenamer {

View File

@ -1,4 +1,3 @@
use crate::util::fast_graph::FastDiGraphMap;
use crate::ModuleId;
use crate::{util::fast_graph::FastDiGraphMap, ModuleId};
pub(crate) type ModuleGraph = FastDiGraphMap<ModuleId, ()>;

View File

@ -1,17 +1,11 @@
use crate::id::Id;
use crate::modules::Modules;
use crate::{id::Id, modules::Modules};
use ahash::RandomState;
use std::collections::HashMap;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_visit::{
noop_visit_mut_type, noop_visit_type, Node, Visit, VisitMut, VisitMutWith, VisitWith,
};
#[derive(Debug, Default)]
pub(crate) struct InlineData {

View File

@ -2,16 +2,9 @@ use crate::ModuleId;
use fxhash::FxHashMap;
use retain_mut::RetainMut;
use std::mem::take;
use swc_common::SourceMap;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{SourceMap, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_visit::Fold;
use swc_ecma_visit::FoldWith;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_visit::{Fold, FoldWith, Visit, VisitMut, VisitMutWith, VisitWith};
mod sort;

View File

@ -1,17 +1,10 @@
use super::stmt::sort_stmts;
use crate::dep_graph::ModuleGraph;
use crate::modules::Modules;
use crate::ModuleId;
use crate::{dep_graph::ModuleGraph, modules::Modules, ModuleId};
use fxhash::FxHashSet;
use indexmap::IndexSet;
use petgraph::EdgeDirection::Outgoing;
use std::collections::VecDeque;
use std::iter::from_fn;
use std::mem::take;
use std::time::Instant;
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::SyntaxContext;
use std::{collections::VecDeque, iter::from_fn, mem::take, time::Instant};
use swc_common::{sync::Lrc, SourceMap, SyntaxContext};
use swc_ecma_ast::*;
use swc_ecma_utils::prepend_stmts;

View File

@ -1,10 +1,10 @@
use crate::util::fast_graph::FastDiGraphMap;
use fxhash::FxHashSet;
use petgraph::EdgeDirection;
use petgraph::EdgeDirection::Incoming;
use petgraph::EdgeDirection::Outgoing;
use std::collections::VecDeque;
use std::iter::repeat;
use petgraph::{
EdgeDirection,
EdgeDirection::{Incoming, Outgoing},
};
use std::{collections::VecDeque, iter::repeat};
/// Is dependancy between nodes hard?
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

View File

@ -1,10 +1,7 @@
use super::Modules;
use crate::dep_graph::ModuleGraph;
use crate::ModuleId;
use crate::{dep_graph::ModuleGraph, ModuleId};
use std::time::Instant;
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::DUMMY_SP;
use swc_common::{sync::Lrc, SourceMap, DUMMY_SP};
use swc_ecma_ast::*;
mod chunk;

View File

@ -1,27 +1,14 @@
use super::graph::Required;
use crate::id::Id;
use crate::modules::sort::graph::StmtDepGraph;
use crate::util::MapWithMut;
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use crate::{id::Id, modules::sort::graph::StmtDepGraph, util::MapWithMut};
use fxhash::{FxHashMap, FxHashSet};
use indexmap::IndexSet;
use petgraph::EdgeDirection::Incoming as Dependants;
use petgraph::EdgeDirection::Outgoing as Dependancies;
use std::collections::VecDeque;
use std::iter::from_fn;
use std::ops::Range;
use petgraph::EdgeDirection::{Incoming as Dependants, Outgoing as Dependancies};
use std::{collections::VecDeque, iter::from_fn, ops::Range};
use swc_atoms::js_word;
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::Spanned;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{sync::Lrc, SourceMap, Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::find_ids;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
pub(super) fn sort_stmts(
injected_ctxt: SyntaxContext,
@ -795,10 +782,8 @@ fn calc_deps(new: &[ModuleItem]) -> StmtDepGraph {
#[cfg(test)]
mod tests {
use super::calc_deps;
use super::Dependancies;
use crate::bundler::tests::suite;
use crate::debug::print_hygiene;
use super::{calc_deps, Dependancies};
use crate::{bundler::tests::suite, debug::print_hygiene};
use swc_common::DUMMY_SP;
use swc_ecma_ast::*;

View File

@ -1,8 +1,6 @@
use super::stmt::sort_stmts;
use crate::bundler::tests::suite;
use crate::debug::print_hygiene;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use crate::{bundler::tests::suite, debug::print_hygiene};
use swc_common::{SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::drop_span;
use testing::assert_eq;

View File

@ -3,28 +3,25 @@
#![allow(dead_code)] // We don't want to modify copied source code.
use fxhash::FxBuildHasher;
use fxhash::FxHashSet;
use indexmap::map::Keys;
use indexmap::map::{Iter as IndexMapIter, IterMut as IndexMapIterMut};
use indexmap::IndexMap;
use petgraph::graph::node_index;
use petgraph::graph::Graph;
use petgraph::visit::GraphBase;
use petgraph::visit::IntoNeighbors;
use petgraph::visit::IntoNeighborsDirected;
use petgraph::visit::NodeCount;
use petgraph::visit::Visitable;
use petgraph::IntoWeightedEdge;
use petgraph::{Directed, Direction, EdgeType, Incoming, Outgoing, Undirected};
use std::cmp::Ordering;
use std::fmt;
use std::hash::{self, Hash};
use std::iter::FromIterator;
use std::iter::{Cloned, DoubleEndedIterator};
use std::marker::PhantomData;
use std::ops::Deref;
use std::slice::Iter;
use fxhash::{FxBuildHasher, FxHashSet};
use indexmap::{
map::{Iter as IndexMapIter, IterMut as IndexMapIterMut, Keys},
IndexMap,
};
use petgraph::{
graph::{node_index, Graph},
visit::{GraphBase, IntoNeighbors, IntoNeighborsDirected, NodeCount, Visitable},
Directed, Direction, EdgeType, Incoming, IntoWeightedEdge, Outgoing, Undirected,
};
use std::{
cmp::Ordering,
fmt,
hash::{self, Hash},
iter::{Cloned, DoubleEndedIterator, FromIterator},
marker::PhantomData,
ops::Deref,
slice::Iter,
};
/// A `GraphMap` with directed edges.
///

View File

@ -1,16 +1,19 @@
use anyhow::{bail, Context, Error};
use reqwest::Url;
use sha1::{Digest, Sha1};
use std::env::current_dir;
use std::io::Write;
use std::{
env::current_dir,
fs::{create_dir_all, read_to_string, write},
io::Write,
path::{Path, PathBuf},
};
use swc_bundler::{Load, ModuleData, Resolve};
use swc_common::errors::ColorConfig;
use swc_common::errors::Handler;
use swc_common::{comments::SingleThreadedComments, sync::Lrc, FileName, SourceMap};
use swc_common::{
comments::SingleThreadedComments,
errors::{ColorConfig, Handler},
sync::Lrc,
FileName, SourceMap,
};
use swc_ecma_parser::{lexer::Lexer, JscTarget, Parser, StringInput, Syntax, TsConfig};
use swc_ecma_transforms::{react, typescript::strip};
use swc_ecma_visit::FoldWith;

View File

@ -6,10 +6,10 @@
use self::common::*;
use anyhow::Error;
use ntest::timeout;
use std::path::PathBuf;
use std::{
collections::{HashMap, HashSet},
fs::write,
path::PathBuf,
process::{Command, Stdio},
};
use swc_atoms::js_word;

View File

@ -25,8 +25,7 @@ use test::{
test_main, DynTestFn, Options, ShouldPanic::No, TestDesc, TestDescAndFn, TestName, TestType,
};
use testing::NormalizedOutput;
use walkdir::DirEntry;
use walkdir::WalkDir;
use walkdir::{DirEntry, WalkDir};
#[path = "common/mod.rs"]
mod common;

View File

@ -1,11 +1,6 @@
use crate::BytePos;
use crate::Span;
use crate::SyntaxContext;
use crate::{BytePos, Span, SyntaxContext};
use num_bigint::BigInt;
use std::cell::RefCell;
use std::cmp::PartialEq;
use std::rc::Rc;
use std::sync::Arc;
use std::{cell::RefCell, cmp::PartialEq, rc::Rc, sync::Arc};
use string_cache::Atom;
/// Derive with `#[derive(EqIgnoreSpan)]`.

View File

@ -14,10 +14,9 @@ pub use self::{
diagnostic_builder::DiagnosticBuilder,
emitter::{ColorConfig, Emitter, EmitterWriter},
};
use crate::sync::Lrc;
use crate::{
rustc_data_structures::stable_hasher::StableHasher,
sync::{Lock, LockCell},
sync::{Lock, LockCell, Lrc},
syntax_pos::{BytePos, FileLinesResult, FileName, Loc, MultiSpan, Span, NO_EXPANSION},
};
use std::{

View File

@ -13,9 +13,8 @@
//! Adds methods to generate web sourcemap.
#![deny(unused)]
pub use self::eq::EqIgnoreSpan;
pub use self::eq::TypeEq;
pub use self::{
eq::{EqIgnoreSpan, TypeEq},
errors::{SourceMapper, SourceMapperDyn},
pos::{
hygiene, BytePos, CharPos, FileName, Globals, Loc, LocWithOpt, Mark, MultiSpan, SourceFile,
@ -25,13 +24,11 @@ pub use self::{
source_map::{FileLines, FileLoader, FilePathMapping, SourceMap, SpanSnippetError},
syntax_pos::LineCol,
};
pub use ast_node::ast_serde;
pub use ast_node::{ast_node, DeserializeEnum, Spanned};
pub use ast_node::{ast_node, ast_serde, DeserializeEnum, Spanned};
pub use from_variant::FromVariant;
use serde::Serialize;
use std::fmt::Debug;
pub use swc_eq_ignore_macros::EqIgnoreSpan;
pub use swc_eq_ignore_macros::TypeEq;
pub use swc_eq_ignore_macros::{EqIgnoreSpan, TypeEq};
pub use swc_visit::chain;
#[doc(hidden)]
pub mod private;

View File

@ -12,8 +12,7 @@ use crate::{
};
use is_macro::Is;
use serde::{Deserialize, Serialize};
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node]
#[derive(Eq, Hash, EqIgnoreSpan)]

View File

@ -8,8 +8,7 @@ use crate::{
};
use is_macro::Is;
use string_enum::StringEnum;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]

View File

@ -17,8 +17,7 @@ use crate::{
};
use is_macro::Is;
use serde::{self, Deserialize, Serialize};
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span, Spanned, DUMMY_SP};
use swc_common::{ast_node, EqIgnoreSpan, Span, Spanned, DUMMY_SP};
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]

View File

@ -5,8 +5,7 @@ use crate::{
typescript::{TsParamProp, TsTypeAnn, TsTypeParamDecl},
};
use is_macro::Is;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
/// Common parts of function and method.
#[ast_node]

View File

@ -1,11 +1,7 @@
use crate::typescript::TsTypeAnn;
use serde::Deserialize;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use swc_atoms::JsWord;
use swc_common::ast_node;
use swc_common::EqIgnoreSpan;
use swc_common::Span;
use swc_common::Spanned;
use swc_common::{ast_node, EqIgnoreSpan, Span, Spanned};
/// Identifer used as a pattern.
#[derive(Spanned, Clone, Debug, PartialEq, Eq, Hash, EqIgnoreSpan, Serialize, Deserialize)]

View File

@ -6,8 +6,7 @@ use crate::{
};
use is_macro::Is;
use swc_atoms::JsWord;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
/// Used for `obj` property of `JSXMemberExpr`.
#[ast_node]

View File

@ -64,10 +64,8 @@ pub use self::{
TsTypeQuery, TsTypeQueryExpr, TsTypeRef, TsUnionOrIntersectionType, TsUnionType,
},
};
use serde::Deserialize;
use serde::Serialize;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use serde::{Deserialize, Serialize};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[macro_use]
mod macros;

View File

@ -7,8 +7,7 @@ use std::{
mem,
};
use swc_atoms::JsWord;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node]
#[derive(Eq, Hash, EqIgnoreSpan)]

View File

@ -1,8 +1,7 @@
use crate::{module_decl::ModuleDecl, stmt::Stmt};
use is_macro::Is;
use swc_atoms::JsWord;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]

View File

@ -7,8 +7,7 @@ use crate::{
ObjectLit,
};
use is_macro::Is;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]

View File

@ -1,8 +1,12 @@
use crate::ident::BindingIdent;
use crate::{expr::Expr, ident::Ident, prop::PropName, typescript::TsTypeAnn, Invalid};
use crate::{
expr::Expr,
ident::{BindingIdent, Ident},
prop::PropName,
typescript::TsTypeAnn,
Invalid,
};
use is_macro::Is;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
impl From<Ident> for Pat {
fn from(i: Ident) -> Self {

View File

@ -8,8 +8,7 @@ use crate::{
typescript::TsTypeAnn,
};
use is_macro::Is;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]

View File

@ -5,8 +5,7 @@ use crate::{
pat::Pat,
};
use is_macro::Is;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
/// Use when only block statements are allowed.
#[ast_node("BlockStatement")]

View File

@ -1,6 +1,5 @@
#![allow(clippy::vec_box)]
#![allow(missing_copy_implementations)]
use crate::BindingIdent;
use crate::{
class::Decorator,
expr::Expr,
@ -8,7 +7,7 @@ use crate::{
lit::{Bool, Number, Str},
module::ModuleItem,
pat::{ArrayPat, AssignPat, ObjectPat, Pat, RestPat},
BigInt, TplElement,
BigInt, BindingIdent, TplElement,
};
use is_macro::Is;
use serde::{
@ -17,8 +16,7 @@ use serde::{
};
use std::fmt;
use string_enum::StringEnum;
use swc_common::EqIgnoreSpan;
use swc_common::{ast_node, Span};
use swc_common::{ast_node, EqIgnoreSpan, Span};
#[ast_node("TsTypeAnnotation")]
#[derive(Eq, Hash, EqIgnoreSpan)]

View File

@ -1,7 +1,6 @@
use self::swc_ecma_parser::{EsConfig, Parser, StringInput, Syntax};
use super::*;
use crate::config::Config;
use crate::text_writer::omit_trailing_semi;
use crate::{config::Config, text_writer::omit_trailing_semi};
use std::{
fmt::Debug,
io::Write,

View File

@ -1,7 +1,9 @@
use anyhow::Error;
use std::sync::Arc;
use swc_common::sync::{Send, Sync};
use swc_common::FileName;
use swc_common::{
sync::{Send, Sync},
FileName,
};
pub trait Resolve: Send + Sync {
fn resolve(&self, base: &FileName, module_specifier: &str) -> Result<FileName, Error>;

View File

@ -1,11 +1,9 @@
#![cfg(feature = "tsc")]
use anyhow::anyhow;
use anyhow::Error;
use anyhow::{anyhow, Error};
use std::collections::HashMap;
use swc_common::FileName;
use swc_ecma_loader::resolve::Resolve;
use swc_ecma_loader::resolvers::tsc::TsConfigResolver;
use swc_ecma_loader::{resolve::Resolve, resolvers::tsc::TsConfigResolver};
#[test]
fn base_dir_exact() {}

View File

@ -1,6 +1,5 @@
use super::UsageAnalyzer;
use std::ops::Deref;
use std::ops::DerefMut;
use std::ops::{Deref, DerefMut};
use swc_ecma_ast::VarDeclKind;
impl UsageAnalyzer {

View File

@ -1,23 +1,15 @@
use self::ctx::Ctx;
use crate::marks::Marks;
use crate::util::can_end_conditionally;
use crate::util::idents_used_by;
use crate::util::now;
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use std::collections::hash_map::Entry;
use std::time::Instant;
use crate::{
marks::Marks,
util::{can_end_conditionally, idents_used_by, now},
};
use fxhash::{FxHashMap, FxHashSet};
use std::{collections::hash_map::Entry, time::Instant};
use swc_atoms::JsWord;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::find_ids;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{find_ids, ident::IdentLike, Id};
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
mod ctx;

View File

@ -1,12 +1,8 @@
use std::borrow::Cow;
use std::mem::take;
use std::{borrow::Cow, mem::take};
use swc_common::pass::CompilerPass;
use swc_ecma_ast::*;
use swc_ecma_transforms::pass::JsPass;
use swc_ecma_visit::as_folder;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::{as_folder, noop_visit_mut_type, VisitMut, VisitMutWith};
pub fn drop_console() -> impl JsPass + VisitMut {
as_folder(DropConsole { done: false })

View File

@ -1,21 +1,13 @@
use crate::analyzer::ProgramData;
use crate::analyzer::UsageAnalyzer;
use crate::util::is_hoisted_var_decl_without_init;
use crate::util::sort::is_sorted_by_key;
use crate::util::IsModuleItem;
use crate::{
analyzer::{ProgramData, UsageAnalyzer},
util::{is_hoisted_var_decl_without_init, sort::is_sorted_by_key, IsModuleItem},
};
use fxhash::FxHashSet;
use swc_common::pass::Repeated;
use swc_common::DUMMY_SP;
use swc_common::{pass::Repeated, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::find_ids;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_utils::StmtLike;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{find_ids, ident::IdentLike, Id, StmtLike};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
pub(super) struct DeclHoisterConfig {
pub hoist_fns: bool,

View File

@ -1,44 +1,39 @@
use self::drop_console::drop_console;
use self::hoist_decls::DeclHoisterConfig;
use self::optimize::optimizer;
use self::optimize::OptimizerState;
use crate::analyzer::analyze;
use crate::analyzer::ProgramData;
use crate::analyzer::UsageAnalyzer;
use crate::compress::hoist_decls::decl_hoister;
use crate::compress::pure::pure_optimizer;
use crate::debug::dump;
use crate::debug::invoke;
use crate::marks::Marks;
use crate::option::CompressOptions;
use crate::util::now;
use crate::util::unit::CompileUnit;
use crate::util::Optional;
use crate::MAX_PAR_DEPTH;
use self::{
drop_console::drop_console,
hoist_decls::DeclHoisterConfig,
optimize::{optimizer, OptimizerState},
};
use crate::{
analyzer::{analyze, ProgramData, UsageAnalyzer},
compress::{hoist_decls::decl_hoister, pure::pure_optimizer},
debug::{dump, invoke},
marks::Marks,
option::CompressOptions,
util::{now, unit::CompileUnit, Optional},
MAX_PAR_DEPTH,
};
#[cfg(feature = "pretty_assertions")]
use pretty_assertions::assert_eq;
use rayon::prelude::*;
use std::borrow::Cow;
use std::fmt;
use std::fmt::Debug;
use std::fmt::Display;
use std::fmt::Formatter;
use std::thread;
use std::time::Instant;
use swc_common::chain;
use swc_common::pass::CompilerPass;
use swc_common::pass::Repeated;
use swc_common::Globals;
use std::{
borrow::Cow,
fmt,
fmt::{Debug, Display, Formatter},
thread,
time::Instant,
};
use swc_common::{
chain,
pass::{CompilerPass, Repeated},
Globals,
};
use swc_ecma_ast::*;
use swc_ecma_transforms::optimization::simplify::dead_branch_remover;
use swc_ecma_transforms::optimization::simplify::expr_simplifier;
use swc_ecma_transforms::pass::JsPass;
use swc_ecma_transforms::{
optimization::simplify::{dead_branch_remover, expr_simplifier},
pass::JsPass,
};
use swc_ecma_utils::StmtLike;
use swc_ecma_visit::as_folder;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_visit::{as_folder, noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
mod drop_console;
mod hoist_decls;

View File

@ -4,13 +4,8 @@ use std::iter::repeat_with;
use swc_atoms::js_word;
use swc_common::DUMMY_SP;
use swc_ecma_ast::*;
use swc_ecma_utils::find_ids;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::private_ident;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_utils::{find_ids, ident::IdentLike, private_ident, Id};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
/// Methods related to the option `arguments`.
impl Optimizer<'_> {

View File

@ -1,15 +1,13 @@
use super::Optimizer;
use crate::compress::optimize::Ctx;
use crate::compress::util::negate_cost;
use crate::debug::dump;
use crate::{
compress::{optimize::Ctx, util::negate_cost},
debug::dump,
};
use swc_atoms::js_word;
use swc_common::Spanned;
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Type;
use swc_ecma_utils::Value::Known;
use swc_ecma_utils::{undefined, ExprExt};
use swc_ecma_utils::{ident::IdentLike, undefined, ExprExt, Type, Value::Known};
/// Methods related to the options `bools` and `bool_as_ints`.
impl Optimizer<'_> {

View File

@ -1,11 +1,8 @@
use super::Optimizer;
use fxhash::FxHashMap;
use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_utils::{ident::IdentLike, Id};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
/// Methods related to the option `collapse_vars`.
impl Optimizer<'_> {

View File

@ -1,21 +1,17 @@
use super::Optimizer;
use crate::compress::optimize::Ctx;
use crate::compress::util::always_terminates;
use crate::compress::util::negate_cost;
use crate::util::SpanExt;
use crate::DISABLE_BUGGY_PASSES;
use crate::{
compress::{
optimize::Ctx,
util::{always_terminates, negate_cost},
},
util::SpanExt,
DISABLE_BUGGY_PASSES,
};
use std::mem::swap;
use swc_common::EqIgnoreSpan;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use swc_common::{EqIgnoreSpan, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::AsOptExpr;
use swc_ecma_transforms_base::ext::ExprRefExt;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::ExprFactory;
use swc_ecma_utils::StmtLike;
use swc_ecma_transforms_base::ext::{AsOptExpr, ExprRefExt, MapWithMut};
use swc_ecma_utils::{ident::IdentLike, ExprExt, ExprFactory, StmtLike};
/// Methods related to the option `conditionals`. All methods are noop if
/// `conditionals` is false.

View File

@ -1,17 +1,11 @@
use super::Optimizer;
use crate::compress::util::eval_as_number;
use crate::DISABLE_BUGGY_PASSES;
use crate::{compress::util::eval_as_number, DISABLE_BUGGY_PASSES};
use std::num::FpCategory;
use swc_atoms::js_word;
use swc_common::Spanned;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::undefined;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::Value::Known;
use swc_ecma_utils::{ident::IdentLike, undefined, ExprExt, Value::Known};
/// Methods related to the option `evaludate`.
impl Optimizer<'_> {

View File

@ -1,18 +1,10 @@
use super::Optimizer;
use crate::compress::util::is_pure_undefined;
use crate::debug::dump;
use crate::util::ExprOptExt;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use crate::{compress::util::is_pure_undefined, debug::dump, util::ExprOptExt};
use swc_common::{Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::prepend;
use swc_ecma_utils::undefined;
use swc_ecma_utils::StmtLike;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{prepend, undefined, StmtLike};
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
/// Methods related to the option `if_return`. All methods are noop if
/// `if_return` is false.

View File

@ -1,21 +1,18 @@
use super::Optimizer;
use crate::compress::optimize::Ctx;
use crate::util::idents_used_by;
use crate::util::make_number;
use crate::{
compress::optimize::Ctx,
util::{idents_used_by, make_number},
};
use fxhash::FxHashMap;
use std::collections::HashMap;
use std::mem::replace;
use std::mem::swap;
use std::{
collections::HashMap,
mem::{replace, swap},
};
use swc_atoms::js_word;
use swc_common::pass::Either;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use swc_common::{pass::Either, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::undefined;
use swc_ecma_utils::ExprFactory;
use swc_ecma_utils::Id;
use swc_ecma_utils::{ident::IdentLike, undefined, ExprFactory, Id};
use swc_ecma_visit::VisitMutWith;
/// Methods related to the option `negate_iife`.

View File

@ -1,16 +1,14 @@
use super::Optimizer;
use crate::compress::optimize::util::class_has_side_effect;
use crate::compress::optimize::util::is_valid_for_lhs;
use crate::debug::dump;
use crate::util::idents_used_by;
use crate::{
compress::optimize::util::{class_has_side_effect, is_valid_for_lhs},
debug::dump,
util::idents_used_by,
};
use swc_atoms::js_word;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use swc_common::{Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::UsageFinder;
use swc_ecma_utils::{ident::IdentLike, ExprExt, UsageFinder};
/// Methods related to option `inline`.
impl Optimizer<'_> {

View File

@ -1,10 +1,8 @@
use crate::compress::optimize::unused::UnreachableHandler;
use crate::compress::optimize::Optimizer;
use crate::compress::optimize::{unused::UnreachableHandler, Optimizer};
use swc_common::DUMMY_SP;
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::Value::Known;
use swc_ecma_utils::{ExprExt, Value::Known};
/// Methods related to the option `loops`.
impl Optimizer<'_> {

View File

@ -1,39 +1,23 @@
use crate::analyzer::ProgramData;
use crate::analyzer::UsageAnalyzer;
use crate::compress::util::is_pure_undefined;
use crate::debug::dump;
use crate::marks::Marks;
use crate::option::CompressOptions;
use crate::util::contains_leaping_yield;
use crate::util::MoudleItemExt;
use crate::{
analyzer::{ProgramData, UsageAnalyzer},
compress::util::is_pure_undefined,
debug::dump,
marks::Marks,
option::CompressOptions,
util::{contains_leaping_yield, MoudleItemExt},
};
use fxhash::FxHashMap;
use retain_mut::RetainMut;
use std::fmt::Write;
use std::mem::take;
use swc_atoms::js_word;
use swc_atoms::JsWord;
use swc_common::iter::IdentifyLast;
use swc_common::pass::Repeated;
use swc_common::Mark;
use swc_common::Spanned;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use std::{fmt::Write, mem::take};
use swc_atoms::{js_word, JsWord};
use swc_common::{iter::IdentifyLast, pass::Repeated, Mark, Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::undefined;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::ExprFactory;
use swc_ecma_utils::Id;
use swc_ecma_utils::IsEmpty;
use swc_ecma_utils::ModuleItemLike;
use swc_ecma_utils::StmtLike;
use swc_ecma_utils::Type;
use swc_ecma_utils::Value;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{
ident::IdentLike, undefined, ExprExt, ExprFactory, Id, IsEmpty, ModuleItemLike, StmtLike, Type,
Value,
};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
use Value::Known;
use self::util::replace_id_with_expr;

View File

@ -1,15 +1,13 @@
use super::Optimizer;
use crate::compress::util::negate;
use crate::util::make_bool;
use crate::util::ValueExt;
use crate::{
compress::util::negate,
util::{make_bool, ValueExt},
};
use swc_atoms::js_word;
use swc_common::EqIgnoreSpan;
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::Type;
use swc_ecma_utils::Value;
use swc_ecma_utils::{ident::IdentLike, ExprExt, Type, Value};
use Value::Known;
impl Optimizer<'_> {

View File

@ -1,21 +1,20 @@
use super::{is_pure_undefined, Optimizer};
use crate::compress::optimize::util::replace_id_with_expr;
use crate::compress::util::{get_lhs_ident, get_lhs_ident_mut, is_directive};
use crate::debug::dump;
use crate::util::{idents_used_by, idents_used_by_ignoring_nested, ExprOptExt};
use crate::{
compress::{
optimize::util::replace_id_with_expr,
util::{get_lhs_ident, get_lhs_ident_mut, is_directive},
},
debug::dump,
util::{idents_used_by, idents_used_by_ignoring_nested, ExprOptExt},
};
use retain_mut::RetainMut;
use std::mem::take;
use swc_atoms::js_word;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use swc_common::{Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::{contains_this_expr, undefined, ExprExt, Id, StmtLike};
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{contains_this_expr, ident::IdentLike, undefined, ExprExt, Id, StmtLike};
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
/// Methods related to the option `sequences`. All methods are noop if
/// `sequences` is false.

View File

@ -3,9 +3,7 @@ use swc_atoms::js_word;
use swc_common::Spanned;
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::Value::Known;
use swc_ecma_utils::{ident::IdentLike, ExprExt, Value::Known};
impl Optimizer<'_> {
pub(super) fn optimize_expr_in_str_ctx_unsafely(&mut self, e: &mut Expr) {

View File

@ -2,20 +2,11 @@ use std::mem::take;
use super::Optimizer;
use crate::util::ExprOptExt;
use swc_common::EqIgnoreSpan;
use swc_common::DUMMY_SP;
use swc_common::{EqIgnoreSpan, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::prepend;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::StmtExt;
use swc_ecma_utils::Type;
use swc_ecma_utils::Value::Known;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{ident::IdentLike, prepend, ExprExt, StmtExt, Type, Value::Known};
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
/// Methods related to option `switches`.
impl Optimizer<'_> {

View File

@ -1,17 +1,13 @@
use super::Optimizer;
use crate::compress::optimize::util::class_has_side_effect;
use crate::debug::dump;
use crate::option::PureGetterOption;
use crate::{
compress::optimize::util::class_has_side_effect, debug::dump, option::PureGetterOption,
};
use swc_atoms::js_word;
use swc_common::Span;
use swc_common::DUMMY_SP;
use swc_common::{Span, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::contains_ident_ref;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_utils::{contains_ident_ref, ident::IdentLike};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
/// Methods related to the option `unused`.
impl Optimizer<'_> {

View File

@ -1,16 +1,10 @@
use super::Ctx;
use super::Optimizer;
use std::ops::Deref;
use std::ops::DerefMut;
use super::{Ctx, Optimizer};
use std::ops::{Deref, DerefMut};
use swc_atoms::JsWord;
use swc_common::Span;
use swc_ecma_ast::*;
use swc_ecma_utils::prop_name_eq;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_utils::{prop_name_eq, ExprExt, Id};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
impl<'b> Optimizer<'b> {
pub(super) fn access_property<'e>(

View File

@ -1,19 +1,14 @@
use super::Pure;
use crate::compress::util::is_pure_undefined;
use crate::compress::util::negate;
use crate::compress::util::negate_cost;
use crate::util::make_bool;
use crate::{
compress::util::{is_pure_undefined, negate, negate_cost},
util::make_bool,
};
use std::mem::swap;
use swc_atoms::js_word;
use swc_common::EqIgnoreSpan;
use swc_common::Span;
use swc_common::Spanned;
use swc_common::DUMMY_SP;
use swc_common::{EqIgnoreSpan, Span, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::Type;
use swc_ecma_utils::Value;
use swc_ecma_utils::{ExprExt, Type, Value};
impl Pure<'_> {
pub(super) fn negate_twice(&mut self, e: &mut Expr) {

View File

@ -1,11 +1,9 @@
use super::Pure;
use crate::compress::util::is_valid_identifier;
use crate::util::deeply_contains_this_expr;
use crate::{compress::util::is_valid_identifier, util::deeply_contains_this_expr};
use swc_atoms::js_word;
use swc_common::SyntaxContext;
use swc_ecma_ast::*;
use swc_ecma_utils::prop_name_eq;
use swc_ecma_utils::ExprExt;
use swc_ecma_utils::{prop_name_eq, ExprExt};
impl Pure<'_> {
pub(super) fn optimize_property_of_member_expr(&mut self, e: &mut MemberExpr) {

View File

@ -1,22 +1,11 @@
use once_cell::sync::Lazy;
use std::env;
use std::process::Command;
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::SyntaxContext;
use swc_ecma_ast::Ident;
use swc_ecma_ast::Module;
use swc_ecma_ast::StrKind;
use swc_ecma_codegen::text_writer::JsWriter;
use swc_ecma_codegen::Emitter;
use swc_ecma_transforms::fixer;
use swc_ecma_transforms::hygiene;
use swc_ecma_utils::drop_span;
use swc_ecma_utils::DropSpan;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::FoldWith;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use std::{env, process::Command};
use swc_common::{sync::Lrc, SourceMap, SyntaxContext};
use swc_ecma_ast::{Ident, Module, StrKind};
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
use swc_ecma_transforms::{fixer, hygiene};
use swc_ecma_utils::{drop_span, DropSpan};
use swc_ecma_visit::{noop_visit_mut_type, FoldWith, VisitMut, VisitMutWith};
pub(crate) struct Debugger;

View File

@ -12,30 +12,25 @@
//! them something other. Don't call methods like `visit_mut_script` nor
//! `visit_mut_module_items`.
use crate::compress::compressor;
use crate::marks::Marks;
use crate::metadata::info_marker;
use crate::option::ExtraOptions;
use crate::option::MinifyOptions;
use crate::pass::compute_char_freq::compute_char_freq;
use crate::pass::expand_names::name_expander;
use crate::pass::global_defs;
use crate::pass::hygiene::hygiene_optimizer;
pub use crate::pass::hygiene::optimize_hygiene;
use crate::pass::mangle_names::name_mangler;
use crate::pass::mangle_props::mangle_properties;
use crate::pass::precompress::precompress_optimizer;
use crate::util::now;
use crate::{
compress::compressor,
marks::Marks,
metadata::info_marker,
option::{ExtraOptions, MinifyOptions},
pass::{
compute_char_freq::compute_char_freq, expand_names::name_expander, global_defs,
hygiene::hygiene_optimizer, mangle_names::name_mangler, mangle_props::mangle_properties,
precompress::precompress_optimizer,
},
util::now,
};
use analyzer::analyze;
use pass::postcompress::postcompress_optimizer;
use std::time::Instant;
use swc_common::comments::Comments;
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::GLOBALS;
use swc_common::{comments::Comments, sync::Lrc, SourceMap, GLOBALS};
use swc_ecma_ast::Module;
use swc_ecma_visit::FoldWith;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::{FoldWith, VisitMutWith};
use timing::Timings;
mod analyzer;

View File

@ -1,22 +1,13 @@
use crate::marks::Marks;
use swc_common::comments::Comment;
use swc_common::comments::CommentKind;
use swc_common::comments::Comments;
use swc_common::Mark;
use swc_common::Span;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{
comments::{Comment, CommentKind, Comments},
Mark, Span, SyntaxContext, DUMMY_SP,
};
use swc_ecma_ast::*;
use swc_ecma_utils::find_ids;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{find_ids, ident::IdentLike, Id};
use swc_ecma_visit::{
noop_visit_mut_type, noop_visit_type, Node, Visit, VisitMut, VisitMutWith, VisitWith,
};
#[cfg(test)]
mod tests;

View File

@ -1,11 +1,9 @@
use fxhash::FxHashMap;
use regex::Regex;
use serde::Deserialize;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use swc_atoms::JsWord;
use swc_common::Mark;
use swc_ecma_ast::EsVersion;
use swc_ecma_ast::Expr;
use swc_ecma_ast::{EsVersion, Expr};
pub mod terser;

View File

@ -1,21 +1,14 @@
//! Compatibility for terser config.
use super::true_by_default;
use super::CompressOptions;
use super::TopLevelOptions;
use super::{true_by_default, CompressOptions, TopLevelOptions};
use crate::option::PureGetterOption;
use fxhash::FxHashMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use swc_atoms::JsWord;
use swc_common::input::SourceFileInput;
use swc_common::sync::Lrc;
use swc_common::FileName;
use swc_common::SourceMap;
use swc_common::DUMMY_SP;
use swc_common::{input::SourceFileInput, sync::Lrc, FileName, SourceMap, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_parser::lexer::Lexer;
use swc_ecma_parser::Parser;
use swc_ecma_parser::{lexer::Lexer, Parser};
use swc_ecma_utils::drop_span;
#[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -1,5 +1,4 @@
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::{noop_visit_mut_type, VisitMut};
/// Currently noop.
///

View File

@ -1,17 +1,9 @@
use fxhash::FxHashSet;
use std::borrow::Cow;
use swc_common::pass::CompilerPass;
use swc_common::EqIgnoreSpan;
use swc_common::Mark;
use swc_common::SyntaxContext;
use swc_common::{pass::CompilerPass, EqIgnoreSpan, Mark, SyntaxContext};
use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_utils::{ident::IdentLike, Id};
use swc_ecma_visit::{noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith};
pub fn globals_defs(defs: Vec<(Box<Expr>, Box<Expr>)>, top_level_mark: Mark) -> impl VisitMut {
GlobalDefs {

View File

@ -1,18 +1,13 @@
use crate::analyzer::analyze;
use crate::analyzer::ProgramData;
use crate::pass::hygiene::analyzer::HygieneAnalyzer;
use crate::pass::hygiene::analyzer::HygieneData;
use crate::util::now;
use crate::{
analyzer::{analyze, ProgramData},
pass::hygiene::analyzer::{HygieneAnalyzer, HygieneData},
util::now,
};
use std::time::Instant;
use swc_common::Mark;
use swc_common::SyntaxContext;
use swc_common::DUMMY_SP;
use swc_common::{Mark, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_visit::VisitWith;
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith};
mod analyzer;

View File

@ -1,21 +1,17 @@
use self::preserver::idents_to_preserve;
use super::compute_char_freq::CharFreqInfo;
use crate::analyzer::analyze;
use crate::analyzer::ProgramData;
use crate::marks::Marks;
use crate::option::MangleOptions;
use crate::util::base54::incr_base54;
use fxhash::FxHashMap;
use fxhash::FxHashSet;
use swc_atoms::js_word;
use swc_atoms::JsWord;
use crate::{
analyzer::{analyze, ProgramData},
marks::Marks,
option::MangleOptions,
util::base54::incr_base54,
};
use fxhash::{FxHashMap, FxHashSet};
use swc_atoms::{js_word, JsWord};
use swc_common::SyntaxContext;
use swc_ecma_ast::*;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;
use swc_ecma_utils::{ident::IdentLike, Id};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
mod preserver;

View File

@ -2,13 +2,8 @@ use crate::option::MangleOptions;
use fxhash::FxHashSet;
use swc_common::DUMMY_SP;
use swc_ecma_ast::*;
use swc_ecma_utils::find_ids;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{find_ids, ident::IdentLike, Id};
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
pub(super) fn idents_to_preserve<N>(options: MangleOptions, n: &N) -> FxHashSet<Id>
where

View File

@ -1,7 +1,8 @@
use crate::analyzer::analyze;
use crate::analyzer::ProgramData;
use crate::option::ManglePropertiesOptions;
use crate::util::base54::incr_base54;
use crate::{
analyzer::{analyze, ProgramData},
option::ManglePropertiesOptions,
util::base54::incr_base54,
};
use once_cell::sync::Lazy;
use std::collections::{HashMap, HashSet};
use swc_atoms::JsWord;

View File

@ -1,5 +1,7 @@
use std::io::{self, Write};
use std::time::{Duration, Instant};
use std::{
io::{self, Write},
time::{Duration, Instant},
};
use crate::util::now;

View File

@ -1,23 +1,13 @@
use fxhash::FxHashSet;
use std::time::Instant;
use swc_common::pass::CompilerPass;
use swc_common::pass::Repeated;
use swc_common::Mark;
use swc_common::Span;
use swc_common::DUMMY_SP;
use swc_common::{
pass::{CompilerPass, Repeated},
Mark, Span, DUMMY_SP,
};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::ext::MapWithMut;
use swc_ecma_utils::ident::IdentLike;
use swc_ecma_utils::Id;
use swc_ecma_utils::ModuleItemLike;
use swc_ecma_utils::StmtLike;
use swc_ecma_utils::Value;
use swc_ecma_visit::noop_visit_type;
use swc_ecma_visit::Fold;
use swc_ecma_visit::FoldWith;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use swc_ecma_utils::{ident::IdentLike, Id, ModuleItemLike, StmtLike, Value};
use swc_ecma_visit::{noop_visit_type, Fold, FoldWith, Node, Visit, VisitWith};
pub(crate) mod base54;
pub(crate) mod sort;

View File

@ -1,46 +1,39 @@
extern crate swc_node_base;
use ansi_term::Color;
use anyhow::bail;
use anyhow::Context;
use anyhow::Error;
use anyhow::{bail, Context, Error};
use once_cell::sync::Lazy;
use serde::Deserialize;
use std::env;
use std::fmt::Debug;
use std::fs::read_to_string;
use std::panic::catch_unwind;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use std::time::Instant;
use swc_common::comments::SingleThreadedComments;
use swc_common::errors::Handler;
use swc_common::sync::Lrc;
use swc_common::EqIgnoreSpan;
use swc_common::FileName;
use swc_common::Mark;
use swc_common::SourceMap;
use std::{
env,
fmt::Debug,
fs::read_to_string,
panic::catch_unwind,
path::{Path, PathBuf},
process::Command,
time::Instant,
};
use swc_common::{
comments::SingleThreadedComments, errors::Handler, sync::Lrc, EqIgnoreSpan, FileName, Mark,
SourceMap,
};
use swc_ecma_ast::*;
use swc_ecma_codegen::text_writer::JsWriter;
use swc_ecma_codegen::Emitter;
use swc_ecma_minifier::optimize;
use swc_ecma_minifier::option::terser::TerserCompressorOptions;
use swc_ecma_minifier::option::CompressOptions;
use swc_ecma_minifier::option::ExtraOptions;
use swc_ecma_minifier::option::MangleOptions;
use swc_ecma_minifier::option::MinifyOptions;
use swc_ecma_parser::lexer::input::SourceFileInput;
use swc_ecma_parser::lexer::Lexer;
use swc_ecma_parser::Parser;
use swc_ecma_transforms::fixer;
use swc_ecma_transforms::hygiene;
use swc_ecma_transforms::resolver_with_mark;
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
use swc_ecma_minifier::{
optimize,
option::{
terser::TerserCompressorOptions, CompressOptions, ExtraOptions, MangleOptions,
MinifyOptions,
},
};
use swc_ecma_parser::{
lexer::{input::SourceFileInput, Lexer},
Parser,
};
use swc_ecma_transforms::{fixer, hygiene, resolver_with_mark};
use swc_ecma_utils::drop_span;
use swc_ecma_visit::FoldWith;
use testing::assert_eq;
use testing::DebugUsingDisplay;
use testing::NormalizedOutput;
use testing::{assert_eq, DebugUsingDisplay, NormalizedOutput};
fn load_txt(filename: &str) -> Vec<String> {
let lines = read_to_string(filename).unwrap();

View File

@ -1,17 +1,12 @@
use std::path::PathBuf;
use swc_common::sync::Lrc;
use swc_common::SourceMap;
use swc_common::{input::SourceFileInput, Mark};
use swc_ecma_codegen::text_writer::JsWriter;
use swc_ecma_codegen::Emitter;
use swc_common::{input::SourceFileInput, sync::Lrc, Mark, SourceMap};
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
use swc_ecma_minifier::optimize_hygiene;
use swc_ecma_parser::{lexer::Lexer, Parser};
use swc_ecma_transforms::{fixer, hygiene, resolver_with_mark};
use swc_ecma_utils::drop_span;
use swc_ecma_visit::FoldWith;
use testing::assert_eq;
use testing::run_test2;
use testing::DebugUsingDisplay;
use testing::{assert_eq, run_test2, DebugUsingDisplay};
#[testing::fixture("tests/hygiene/identical/**/*.js")]
fn identical(input: PathBuf) {

View File

@ -1,23 +1,24 @@
use ansi_term::Color;
use anyhow::{bail, Context, Error};
use std::fs::read_to_string;
use std::path::{Path, PathBuf};
use std::process::Command;
use swc_common::comments::SingleThreadedComments;
use swc_common::errors::Handler;
use swc_common::{input::SourceFileInput, sync::Lrc};
use swc_common::{FileName, Mark, SourceFile, SourceMap};
use std::{
fs::read_to_string,
path::{Path, PathBuf},
process::Command,
};
use swc_common::{
comments::SingleThreadedComments, errors::Handler, input::SourceFileInput, sync::Lrc, FileName,
Mark, SourceFile, SourceMap,
};
use swc_ecma_ast::*;
use swc_ecma_codegen::{
text_writer::{omit_trailing_semi, JsWriter, WriteJs},
Emitter,
};
use swc_ecma_minifier::optimize;
use swc_ecma_minifier::option::{
ExtraOptions, MangleOptions, ManglePropertiesOptions, MinifyOptions,
use swc_ecma_minifier::{
optimize,
option::{ExtraOptions, MangleOptions, ManglePropertiesOptions, MinifyOptions},
};
use swc_ecma_parser::lexer::Lexer;
use swc_ecma_parser::Parser;
use swc_ecma_parser::{lexer::Lexer, Parser};
use swc_ecma_transforms::{fixer, hygiene, resolver_with_mark};
use swc_ecma_visit::FoldWith;
use testing::DebugUsingDisplay;

View File

@ -2,8 +2,7 @@
extern crate test;
use swc_common::comments::SingleThreadedComments;
use swc_common::FileName;
use swc_common::{comments::SingleThreadedComments, FileName};
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax};
use test::Bencher;

View File

@ -1,6 +1,5 @@
use super::{ident::MaybeOptionalIdentParser, *};
use crate::lexer::TokenContext;
use crate::{error::SyntaxError, Tokens};
use crate::{error::SyntaxError, lexer::TokenContext, Tokens};
use either::Either;
use swc_atoms::js_word;
use swc_common::{Spanned, SyntaxContext};

View File

@ -1,7 +1,9 @@
//! 13.3.3 Destructuring Binding Patterns
use super::{util::ExprExt, *};
use crate::parser::class_and_fn::is_not_this;
use crate::{parser::expr::PatOrExprOrSpread, token::AssignOpToken};
use crate::{
parser::{class_and_fn::is_not_this, expr::PatOrExprOrSpread},
token::AssignOpToken,
};
use std::iter;
use swc_atoms::js_word;
use swc_common::Spanned;

View File

@ -1,22 +1,14 @@
use std::path::PathBuf;
use swc_common::comments::SingleThreadedComments;
use swc_common::errors::DiagnosticBuilder;
use swc_common::errors::Handler;
use swc_common::input::SourceFileInput;
use swc_common::BytePos;
use swc_common::Span;
use swc_common::DUMMY_SP;
use swc_common::{
comments::SingleThreadedComments,
errors::{DiagnosticBuilder, Handler},
input::SourceFileInput,
BytePos, Span, DUMMY_SP,
};
use swc_ecma_ast::*;
use swc_ecma_parser::lexer::Lexer;
use swc_ecma_parser::EsConfig;
use swc_ecma_parser::Parser;
use swc_ecma_parser::Syntax;
use swc_ecma_parser::TsConfig;
use swc_ecma_visit::Node;
use swc_ecma_visit::Visit;
use swc_ecma_visit::VisitWith;
use testing::fixture;
use testing::Tester;
use swc_ecma_parser::{lexer::Lexer, EsConfig, Parser, Syntax, TsConfig};
use swc_ecma_visit::{Node, Visit, VisitWith};
use testing::{fixture, Tester};
#[fixture("tests/comments/**/input.js")]
#[fixture("tests/comments/**/input.ts")]

Some files were not shown because too many files have changed in this diff Show More