mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 05:01:42 +03:00
fix(es/transforms): Fix bugs (#1691)
swc_ecma_transforms_optimization: - Don't optimize optional chaining expressions. (#1688) swc_ecma_transforms_react: - Don't panic. (#1683)
This commit is contained in:
parent
24bd5ea4a4
commit
f0d7a3d064
12
README.md
12
README.md
@ -37,17 +37,7 @@ Please see [comparison with babel](https://swc.rs/docs/comparison-babel).
|
||||
|
||||
# Performance
|
||||
|
||||
The lower bound of the speedup compared to babel is **18**. The benchmarks were run on Macbook pro, dual core, 2.3GHz Intel Core i5, 16 GB ram
|
||||
|
||||
| | performance |
|
||||
| ------------------ | :------------------------------------: |
|
||||
| swc (es3) | 761 ops/sec ±0.23% (89 runs sampled) |
|
||||
| swc (es2015) | 800 ops/sec ±1.02% (87 runs sampled) |
|
||||
| swc (es2016) | 2123 ops/sec ±0.84% (88 runs sampled) |
|
||||
| swc (es2017) | 2131 ops/sec ±1.13% (90 runs sampled) |
|
||||
| swc (es2018) | 2981 ops/sec ±0.25% (90 runs sampled) |
|
||||
| swc-optimize (es3) | 712 ops/sec ±0.21% (86 runs sampled) |
|
||||
| babel | 41.75 ops/sec ±8.07% (56 runs sampled) |
|
||||
Please see [benchmark results](https://swc.rs/docs/benchmark-transform) on the website.
|
||||
|
||||
<h2 align="center">Supporting swc</h2>
|
||||
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_compat"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.16.2"
|
||||
version = "0.16.3"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_optimization"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.19.1"
|
||||
version = "0.19.2"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -1084,6 +1084,12 @@ impl SimplifyExpr {
|
||||
impl Fold for SimplifyExpr {
|
||||
noop_fold_type!();
|
||||
|
||||
/// Currently noop
|
||||
#[inline]
|
||||
fn fold_opt_chain_expr(&mut self, n: OptChainExpr) -> OptChainExpr {
|
||||
n
|
||||
}
|
||||
|
||||
fn fold_expr(&mut self, expr: Expr) -> Expr {
|
||||
// fold children before doing something more.
|
||||
let expr = expr.fold_children_with(self);
|
||||
|
@ -0,0 +1 @@
|
||||
({ notafunction: null })?.notafunction?.();
|
@ -0,0 +1,3 @@
|
||||
({
|
||||
notafunction: null
|
||||
})?.notafunction?.();
|
@ -0,0 +1 @@
|
||||
({ notafunction: null })?.notafunction();
|
@ -0,0 +1,3 @@
|
||||
({
|
||||
notafunction: null
|
||||
})?.notafunction();
|
@ -0,0 +1 @@
|
||||
({ notafunction: null }).notafunction?.();
|
@ -0,0 +1,3 @@
|
||||
({
|
||||
notafunction: null
|
||||
}).notafunction?.();
|
@ -3,6 +3,7 @@ use swc_common::pass::Repeat;
|
||||
use swc_ecma_parser::EsConfig;
|
||||
use swc_ecma_parser::Syntax;
|
||||
use swc_ecma_transforms_optimization::simplify::dce::dce;
|
||||
use swc_ecma_transforms_optimization::simplify::expr_simplifier;
|
||||
use swc_ecma_transforms_testing::test_fixture;
|
||||
|
||||
#[testing::fixture("dce/**/input.js")]
|
||||
@ -34,3 +35,18 @@ fn dce_repeated(input: PathBuf) {
|
||||
&output,
|
||||
);
|
||||
}
|
||||
|
||||
#[testing::fixture("expr-simplifier/**/input.js")]
|
||||
fn expr(input: PathBuf) {
|
||||
let output = input.with_file_name("output.js");
|
||||
|
||||
test_fixture(
|
||||
Syntax::Es(EsConfig {
|
||||
dynamic_import: true,
|
||||
..Default::default()
|
||||
}),
|
||||
&|_| expr_simplifier(),
|
||||
&input,
|
||||
&output,
|
||||
);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_react"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.17.0"
|
||||
version = "0.17.1"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -42,10 +42,7 @@ impl Fold for JsxSrc {
|
||||
key: PropName::Ident(quote_ident!("fileName")),
|
||||
value: Box::new(Expr::Lit(Lit::Str(Str {
|
||||
span: DUMMY_SP,
|
||||
value: match file_lines.file.name {
|
||||
FileName::Real(ref p) => p.display().to_string().into(),
|
||||
_ => unimplemented!("file name for other than real files"),
|
||||
},
|
||||
value: file_lines.file.name.to_string().into(),
|
||||
has_escape: false,
|
||||
kind: Default::default(),
|
||||
}))),
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_typescript"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.18.1"
|
||||
version = "0.18.2"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
Loading…
Reference in New Issue
Block a user