mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
fix(es/transforms): Fix transforms (#1861)
swc_ecma_transforms_compat: - Organize logical assignment pass correctly. swc_ecma_transforms_optimization: - `dead_branch_remover`: Handle nullish coalescing operator correctly. (#1851)
This commit is contained in:
parent
5345c90989
commit
33f2ab2d79
@ -11,7 +11,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
|
||||
[lib]
|
||||
name = "swc"
|
||||
@ -30,15 +30,15 @@ serde = {version = "1", features = ["derive"]}
|
||||
serde_json = "1"
|
||||
sourcemap = "6"
|
||||
swc_atoms = {version = "0.2", path = "./atoms"}
|
||||
swc_bundler = {version = "0.43.0", path = "./bundler"}
|
||||
swc_bundler = {version = "0.44.0", path = "./bundler"}
|
||||
swc_common = {version = "0.10.16", path = "./common", features = ["sourcemap", "concurrent"]}
|
||||
swc_ecma_ast = {version = "0.47.0", path = "./ecmascript/ast"}
|
||||
swc_ecma_codegen = {version = "0.60.0", path = "./ecmascript/codegen"}
|
||||
swc_ecma_ext_transforms = {version = "0.19.0", path = "./ecmascript/ext-transforms"}
|
||||
swc_ecma_loader = {version = "0.9.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
|
||||
swc_ecma_parser = {version = "0.61.0", path = "./ecmascript/parser"}
|
||||
swc_ecma_preset_env = {version = "0.26.0", path = "./ecmascript/preset-env"}
|
||||
swc_ecma_transforms = {version = "0.56.0", path = "./ecmascript/transforms", features = [
|
||||
swc_ecma_preset_env = {version = "0.27.0", path = "./ecmascript/preset-env"}
|
||||
swc_ecma_transforms = {version = "0.57.0", path = "./ecmascript/transforms", features = [
|
||||
"compat",
|
||||
"module",
|
||||
"optimization",
|
||||
|
@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_bundler"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
@ -37,7 +37,7 @@ swc_ecma_ast = {version = "0.47.0", path = "../ecmascript/ast"}
|
||||
swc_ecma_codegen = {version = "0.60.0", path = "../ecmascript/codegen"}
|
||||
swc_ecma_loader = {version = "0.9.0", path = "../ecmascript/loader"}
|
||||
swc_ecma_parser = {version = "0.61.0", path = "../ecmascript/parser"}
|
||||
swc_ecma_transforms = {version = "0.56.0", path = "../ecmascript/transforms", features = ["optimization"]}
|
||||
swc_ecma_transforms = {version = "0.57.0", path = "../ecmascript/transforms", features = ["optimization"]}
|
||||
swc_ecma_utils = {version = "0.38.0", path = "../ecmascript/utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../ecmascript/visit"}
|
||||
|
||||
@ -46,7 +46,7 @@ hex = "0.4"
|
||||
ntest = "0.7.2"
|
||||
reqwest = {version = "0.10.8", features = ["blocking"]}
|
||||
sha-1 = "0.9"
|
||||
swc_ecma_transforms = {version = "0.56.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
|
||||
swc_ecma_transforms = {version = "0.57.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
|
||||
tempfile = "3.1.0"
|
||||
testing = {version = "0.10.5", path = "../testing"}
|
||||
url = "2.1.1"
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecmascript"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.42.0"
|
||||
version = "0.43.0"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@ -31,9 +31,9 @@ typescript = ["swc_ecma_transforms/typescript"]
|
||||
swc_ecma_ast = {version = "0.47.0", path = "./ast"}
|
||||
swc_ecma_codegen = {version = "0.60.0", path = "./codegen", optional = true}
|
||||
swc_ecma_dep_graph = {version = "0.29.0", path = "./dep-graph", optional = true}
|
||||
swc_ecma_minifier = {version = "0.8.0", path = "./minifier", optional = true}
|
||||
swc_ecma_minifier = {version = "0.9.0", path = "./minifier", optional = true}
|
||||
swc_ecma_parser = {version = "0.61.0", path = "./parser", optional = true}
|
||||
swc_ecma_transforms = {version = "0.56.0", path = "./transforms", optional = true}
|
||||
swc_ecma_transforms = {version = "0.57.0", path = "./transforms", optional = true}
|
||||
swc_ecma_utils = {version = "0.38.0", path = "./utils", optional = true}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "./visit", optional = true}
|
||||
|
||||
|
@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "src/lists/*.json"]
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_minifier"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
|
||||
[features]
|
||||
debug = []
|
||||
@ -27,7 +27,7 @@ swc_common = {version = "0.10.8", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
|
||||
swc_ecma_codegen = {version = "0.60.0", path = "../codegen"}
|
||||
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
|
||||
swc_ecma_transforms = {version = "0.56.0", path = "../transforms/", features = ["optimization"]}
|
||||
swc_ecma_transforms = {version = "0.57.0", path = "../transforms/", features = ["optimization"]}
|
||||
swc_ecma_transforms_base = {version = "0.20.0", path = "../transforms/base"}
|
||||
swc_ecma_utils = {version = "0.38.0", path = "../utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
|
||||
|
@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_preset_env/"
|
||||
edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_preset_env"
|
||||
version = "0.26.0"
|
||||
version = "0.27.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@ -22,7 +22,7 @@ string_enum = {version = "0.3.1", path = "../../macros/string_enum"}
|
||||
swc_atoms = {version = "0.2", path = "../../atoms"}
|
||||
swc_common = {version = "0.10.16", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
|
||||
swc_ecma_transforms = {version = "0.56.0", path = "../transforms", features = ["compat", "proposal"]}
|
||||
swc_ecma_transforms = {version = "0.57.0", path = "../transforms", features = ["compat", "proposal"]}
|
||||
swc_ecma_utils = {version = "0.38.0", path = "../utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
|
||||
walkdir = "2"
|
||||
|
@ -14,7 +14,7 @@ use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::{chain, comments::Comments, FromVariant, Mark, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms::{
|
||||
compat::{bugfixes, es2015, es2016, es2017, es2018, es2020, es3},
|
||||
compat::{bugfixes, es2015, es2016, es2017, es2018, es2020, es2021, es3},
|
||||
pass::{noop, Optional},
|
||||
};
|
||||
use swc_ecma_utils::prepend_stmts;
|
||||
@ -87,7 +87,11 @@ where
|
||||
|
||||
let pass = add!(pass, ExportNamespaceFrom, es2020::export_namespace_from());
|
||||
let pass = add!(pass, NullishCoalescing, es2020::nullish_coalescing());
|
||||
let pass = add!(pass, LogicalAssignmentOperators, es2020::operators());
|
||||
let pass = add!(
|
||||
pass,
|
||||
LogicalAssignmentOperators,
|
||||
es2021::logical_assignments()
|
||||
);
|
||||
let pass = add!(pass, OptionalChaining, es2020::optional_chaining());
|
||||
let pass = add!(pass, ClassProperties, es2020::class_properties());
|
||||
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.56.0"
|
||||
version = "0.57.0"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@ -26,12 +26,12 @@ swc_common = {version = "0.10.16", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
|
||||
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
|
||||
swc_ecma_transforms_base = {version = "0.20.0", path = "./base"}
|
||||
swc_ecma_transforms_compat = {version = "0.22.0", path = "./compat", optional = true}
|
||||
swc_ecma_transforms_module = {version = "0.23.0", path = "./module", optional = true}
|
||||
swc_ecma_transforms_optimization = {version = "0.26.0", path = "./optimization", optional = true}
|
||||
swc_ecma_transforms_proposal = {version = "0.23.0", path = "./proposal", optional = true}
|
||||
swc_ecma_transforms_react = {version = "0.24.0", path = "./react", optional = true}
|
||||
swc_ecma_transforms_typescript = {version = "0.25.0", path = "./typescript", optional = true}
|
||||
swc_ecma_transforms_compat = {version = "0.23.0", path = "./compat", optional = true}
|
||||
swc_ecma_transforms_module = {version = "0.24.0", path = "./module", optional = true}
|
||||
swc_ecma_transforms_optimization = {version = "0.27.0", path = "./optimization", optional = true}
|
||||
swc_ecma_transforms_proposal = {version = "0.24.0", path = "./proposal", optional = true}
|
||||
swc_ecma_transforms_react = {version = "0.25.0", path = "./react", optional = true}
|
||||
swc_ecma_transforms_typescript = {version = "0.26.0", path = "./typescript", optional = true}
|
||||
swc_ecma_utils = {version = "0.38.0", path = "../utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
|
||||
unicode-xid = "0.2"
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_base"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.20.0"
|
||||
version = "0.20.1"
|
||||
|
||||
[dependencies]
|
||||
fxhash = "0.2.1"
|
||||
|
@ -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.22.0"
|
||||
version = "0.23.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -3,7 +3,6 @@ pub use self::{
|
||||
class_properties::{class_properties, typescript_class_properties},
|
||||
export_namespace_from::export_namespace_from,
|
||||
nullish_coalescing::nullish_coalescing,
|
||||
operators::operators,
|
||||
opt_chaining::optional_chaining,
|
||||
};
|
||||
use swc_common::chain;
|
||||
@ -12,7 +11,6 @@ use swc_ecma_visit::Fold;
|
||||
mod class_properties;
|
||||
mod export_namespace_from;
|
||||
mod nullish_coalescing;
|
||||
mod operators;
|
||||
mod opt_chaining;
|
||||
|
||||
pub fn es2020() -> impl Fold {
|
||||
@ -21,6 +19,5 @@ pub fn es2020() -> impl Fold {
|
||||
optional_chaining(),
|
||||
class_properties(),
|
||||
export_namespace_from(),
|
||||
operators(),
|
||||
)
|
||||
}
|
@ -8,7 +8,7 @@ use swc_ecma_visit::{
|
||||
as_folder, noop_visit_mut_type, noop_visit_type, Fold, Node, Visit, VisitMut, VisitMutWith,
|
||||
};
|
||||
|
||||
pub fn operators() -> impl Fold + VisitMut {
|
||||
pub fn logical_assignments() -> impl Fold + VisitMut {
|
||||
as_folder(Operators::default())
|
||||
}
|
||||
|
8
ecmascript/transforms/compat/src/es2021/mod.rs
Normal file
8
ecmascript/transforms/compat/src/es2021/mod.rs
Normal file
@ -0,0 +1,8 @@
|
||||
pub use self::logical_assignments::logical_assignments;
|
||||
use swc_ecma_visit::{Fold, VisitMut};
|
||||
|
||||
mod logical_assignments;
|
||||
|
||||
pub fn es2021() -> impl Fold + VisitMut {
|
||||
logical_assignments()
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
pub use self::{
|
||||
bugfixes::bugfixes, es2015::es2015, es2016::es2016, es2017::es2017, es2018::es2018,
|
||||
es2020::es2020, es3::es3,
|
||||
es2020::es2020, es2021::es2021, es3::es3,
|
||||
};
|
||||
|
||||
#[macro_use]
|
||||
@ -13,5 +13,6 @@ pub mod es2016;
|
||||
pub mod es2017;
|
||||
pub mod es2018;
|
||||
pub mod es2020;
|
||||
pub mod es2021;
|
||||
pub mod es3;
|
||||
pub mod reserved_words;
|
||||
|
@ -1,10 +1,10 @@
|
||||
use swc_ecma_parser::{Syntax, TsConfig};
|
||||
use swc_ecma_transforms_compat::es2020;
|
||||
use swc_ecma_transforms_compat::es2021;
|
||||
use swc_ecma_transforms_testing::test;
|
||||
use swc_ecma_visit::Fold;
|
||||
|
||||
fn tr() -> impl Fold {
|
||||
es2020::operators()
|
||||
es2021::logical_assignments()
|
||||
}
|
||||
|
||||
fn syntax() -> Syntax {
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_module"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.23.0"
|
||||
version = "0.24.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@ -26,6 +26,6 @@ swc_ecma_utils = {version = "0.38.0", path = "../../utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../../visit"}
|
||||
|
||||
[dev-dependencies]
|
||||
swc_ecma_transforms_compat = {version = "0.22.0", path = "../compat"}
|
||||
swc_ecma_transforms_compat = {version = "0.23.0", path = "../compat"}
|
||||
swc_ecma_transforms_testing = {version = "0.20.0", path = "../testing/"}
|
||||
testing = {version = "0.10.5", path = "../../../testing/"}
|
||||
|
@ -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.26.0"
|
||||
version = "0.27.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@ -26,10 +26,10 @@ swc_ecma_utils = {version = "0.38.0", path = "../../utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../../visit"}
|
||||
|
||||
[dev-dependencies]
|
||||
swc_ecma_transforms_compat = {version = "0.22.0", path = "../compat"}
|
||||
swc_ecma_transforms_module = {version = "0.23.0", path = "../module"}
|
||||
swc_ecma_transforms_proposal = {version = "0.23.0", path = "../proposal"}
|
||||
swc_ecma_transforms_react = {version = "0.24.0", path = "../react"}
|
||||
swc_ecma_transforms_compat = {version = "0.23.0", path = "../compat"}
|
||||
swc_ecma_transforms_module = {version = "0.24.0", path = "../module"}
|
||||
swc_ecma_transforms_proposal = {version = "0.24.0", path = "../proposal"}
|
||||
swc_ecma_transforms_react = {version = "0.25.0", path = "../react"}
|
||||
swc_ecma_transforms_testing = {version = "0.20.0", path = "../testing"}
|
||||
swc_ecma_transforms_typescript = {version = "0.25.0", path = "../typescript"}
|
||||
swc_ecma_transforms_typescript = {version = "0.26.0", path = "../typescript"}
|
||||
testing = {version = "0.10.5", path = "../../../testing"}
|
||||
|
@ -1172,7 +1172,7 @@ fn ignore_result(e: Expr) -> Option<Expr> {
|
||||
left,
|
||||
op,
|
||||
right,
|
||||
}) if op != op!("&&") && op != op!("||") => {
|
||||
}) if op != op!("&&") && op != op!("||") && op != op!("??") => {
|
||||
let left = ignore_result(*left);
|
||||
let right = ignore_result(*right);
|
||||
|
||||
@ -1214,7 +1214,7 @@ fn ignore_result(e: Expr) -> Option<Expr> {
|
||||
}))
|
||||
}
|
||||
} else {
|
||||
debug_assert_eq!(op, op!("||"));
|
||||
debug_assert!(op == op!("||") || op == op!("??"));
|
||||
|
||||
let l = left.as_pure_bool();
|
||||
|
||||
|
@ -1787,3 +1787,8 @@ fn issue_1825() {
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_1851_1() {
|
||||
test("x ?? (x = 'abc');", "x ?? (x = 'abc');");
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_proposal"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.23.0"
|
||||
version = "0.24.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@ -30,6 +30,6 @@ swc_ecma_utils = {version = "0.38.0", path = "../../utils"}
|
||||
swc_ecma_visit = {version = "0.33.0", path = "../../visit"}
|
||||
|
||||
[dev-dependencies]
|
||||
swc_ecma_transforms_compat = {version = "0.22.0", path = "../compat"}
|
||||
swc_ecma_transforms_module = {version = "0.23.0", path = "../module"}
|
||||
swc_ecma_transforms_compat = {version = "0.23.0", path = "../compat"}
|
||||
swc_ecma_transforms_module = {version = "0.24.0", path = "../module"}
|
||||
swc_ecma_transforms_testing = {version = "0.20.0", path = "../testing"}
|
||||
|
@ -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.24.0"
|
||||
version = "0.25.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@ -29,7 +29,7 @@ swc_ecma_visit = {version = "0.33.0", path = "../../visit"}
|
||||
|
||||
[dev-dependencies]
|
||||
swc_ecma_codegen = {version = "0.60.0", path = "../../codegen/"}
|
||||
swc_ecma_transforms_compat = {version = "0.22.0", path = "../compat/"}
|
||||
swc_ecma_transforms_module = {version = "0.23.0", path = "../module"}
|
||||
swc_ecma_transforms_compat = {version = "0.23.0", path = "../compat/"}
|
||||
swc_ecma_transforms_module = {version = "0.24.0", path = "../module"}
|
||||
swc_ecma_transforms_testing = {version = "0.20.0", path = "../testing/"}
|
||||
testing = {version = "0.10.5", path = "../../../testing"}
|
||||
|
@ -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.25.0"
|
||||
version = "0.26.0"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@ -22,9 +22,9 @@ swc_ecma_visit = {version = "0.33.0", path = "../../visit"}
|
||||
|
||||
[dev-dependencies]
|
||||
swc_ecma_codegen = {version = "0.60.0", path = "../../codegen"}
|
||||
swc_ecma_transforms_compat = {version = "0.22.0", path = "../compat"}
|
||||
swc_ecma_transforms_module = {version = "0.23.0", path = "../module"}
|
||||
swc_ecma_transforms_proposal = {version = "0.23.0", path = "../proposal/"}
|
||||
swc_ecma_transforms_compat = {version = "0.23.0", path = "../compat"}
|
||||
swc_ecma_transforms_module = {version = "0.24.0", path = "../module"}
|
||||
swc_ecma_transforms_proposal = {version = "0.24.0", path = "../proposal/"}
|
||||
swc_ecma_transforms_testing = {version = "0.20.0", path = "../testing"}
|
||||
testing = {version = "0.10.5", path = "../../../testing"}
|
||||
walkdir = "2.3.1"
|
||||
|
@ -155,6 +155,7 @@ impl<'a, 'b, P: swc_ecma_visit::Fold> PassBuilder<'a, 'b, P> {
|
||||
} else {
|
||||
Either::Right(chain!(
|
||||
import_assertions(),
|
||||
Optional::new(compat::es2021::es2021(), self.target < JscTarget::Es2021),
|
||||
Optional::new(compat::es2020::es2020(), self.target < JscTarget::Es2020),
|
||||
Optional::new(typescript::strip(), syntax.typescript()),
|
||||
Optional::new(compat::es2018(), self.target <= JscTarget::Es2018),
|
||||
|
12
tests/fixture/issue-1701/case1/input/.swcrc
Normal file
12
tests/fixture/issue-1701/case1/input/.swcrc
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
},
|
||||
"transform": null,
|
||||
"target": "es2015",
|
||||
"loose": true,
|
||||
"keepClassNames": false
|
||||
},
|
||||
"minify": true
|
||||
}
|
7
tests/fixture/issue-1701/case1/input/index.ts
Normal file
7
tests/fixture/issue-1701/case1/input/index.ts
Normal file
@ -0,0 +1,7 @@
|
||||
const f = (...characters: Array<string>): number =>
|
||||
characters.length
|
||||
|
||||
const g = (str: string): number =>
|
||||
f(...str)
|
||||
|
||||
g("meow")
|
1
tests/fixture/issue-1701/case1/output/index.ts
Normal file
1
tests/fixture/issue-1701/case1/output/index.ts
Normal file
@ -0,0 +1 @@
|
||||
var f=function(){for(var _len=arguments.length,characters=new Array(_len),_key=0;_key<_len;_key++){characters[_key]=arguments[_key];}return characters.length;};var g=function(str){return f.apply(void 0,str);};g("meow");
|
11
tests/fixture/issue-1701/case2/input/.swcrc
Normal file
11
tests/fixture/issue-1701/case2/input/.swcrc
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
},
|
||||
"transform": null,
|
||||
"target": "es2015",
|
||||
"loose": true,
|
||||
"keepClassNames": false
|
||||
}
|
||||
}
|
7
tests/fixture/issue-1701/case2/input/index.ts
Normal file
7
tests/fixture/issue-1701/case2/input/index.ts
Normal file
@ -0,0 +1,7 @@
|
||||
const f = (...characters: Array<string>): number =>
|
||||
characters.length
|
||||
|
||||
const g = (str: string): number =>
|
||||
f(...str)
|
||||
|
||||
g("meow")
|
10
tests/fixture/issue-1701/case2/output/index.ts
Normal file
10
tests/fixture/issue-1701/case2/output/index.ts
Normal file
@ -0,0 +1,10 @@
|
||||
var f = function() {
|
||||
for(var _len = arguments.length, characters = new Array(_len), _key = 0; _key < _len; _key++){
|
||||
characters[_key] = arguments[_key];
|
||||
}
|
||||
return characters.length;
|
||||
};
|
||||
var g = function(str) {
|
||||
return f.apply(void 0, str);
|
||||
};
|
||||
g("meow");
|
5
tests/fixture/issue-1859/case1-js/input/.swcrc
Normal file
5
tests/fixture/issue-1859/case1-js/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
2
tests/fixture/issue-1859/case1-js/input/index.js
Normal file
2
tests/fixture/issue-1859/case1-js/input/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './app.config';
|
||||
export * from './database.config';
|
51
tests/fixture/issue-1859/case1-js/output/index.js
Normal file
51
tests/fixture/issue-1859/case1-js/output/index.js
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
};
|
||||
var _appConfig = _interopRequireWildcard(require("./app.config"));
|
||||
var _databaseConfig = _interopRequireWildcard(require("./database.config"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
Object.keys(_appConfig).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _appConfig[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
Object.keys(_databaseConfig).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _databaseConfig[key];
|
||||
}
|
||||
});
|
||||
});
|
10
tests/fixture/issue-1859/case2-ts/input/.swcrc
Normal file
10
tests/fixture/issue-1859/case2-ts/input/.swcrc
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
2
tests/fixture/issue-1859/case2-ts/input/index.ts
Normal file
2
tests/fixture/issue-1859/case2-ts/input/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './app.config';
|
||||
export * from './database.config';
|
51
tests/fixture/issue-1859/case2-ts/output/index.ts
Normal file
51
tests/fixture/issue-1859/case2-ts/output/index.ts
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
};
|
||||
var _appConfig = _interopRequireWildcard(require("./app.config"));
|
||||
var _databaseConfig = _interopRequireWildcard(require("./database.config"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
Object.keys(_appConfig).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _appConfig[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
Object.keys(_databaseConfig).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _databaseConfig[key];
|
||||
}
|
||||
});
|
||||
});
|
10
tests/fixture/issue-1859/case3/input/.swcrc
Normal file
10
tests/fixture/issue-1859/case3/input/.swcrc
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
1
tests/fixture/issue-1859/case3/input/bar.ts
Normal file
1
tests/fixture/issue-1859/case3/input/bar.ts
Normal file
@ -0,0 +1 @@
|
||||
export const bar = () => { }
|
1
tests/fixture/issue-1859/case3/input/foo.ts
Normal file
1
tests/fixture/issue-1859/case3/input/foo.ts
Normal file
@ -0,0 +1 @@
|
||||
export const foo = () => { }
|
2
tests/fixture/issue-1859/case3/input/index.ts
Normal file
2
tests/fixture/issue-1859/case3/input/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
import * as lib from './lib';
|
||||
console.log(lib)
|
2
tests/fixture/issue-1859/case3/input/lib.ts
Normal file
2
tests/fixture/issue-1859/case3/input/lib.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './foo';
|
||||
export * from './bar';
|
8
tests/fixture/issue-1859/case3/output/bar.js
Normal file
8
tests/fixture/issue-1859/case3/output/bar.js
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.bar = void 0;
|
||||
var bar = function() {
|
||||
};
|
||||
exports.bar = bar;
|
8
tests/fixture/issue-1859/case3/output/bar.ts
Normal file
8
tests/fixture/issue-1859/case3/output/bar.ts
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.bar = void 0;
|
||||
var bar = function() {
|
||||
};
|
||||
exports.bar = bar;
|
8
tests/fixture/issue-1859/case3/output/foo.js
Normal file
8
tests/fixture/issue-1859/case3/output/foo.js
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.foo = void 0;
|
||||
var foo = function() {
|
||||
};
|
||||
exports.foo = foo;
|
8
tests/fixture/issue-1859/case3/output/foo.ts
Normal file
8
tests/fixture/issue-1859/case3/output/foo.ts
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.foo = void 0;
|
||||
var foo = function() {
|
||||
};
|
||||
exports.foo = foo;
|
26
tests/fixture/issue-1859/case3/output/index.js
Normal file
26
tests/fixture/issue-1859/case3/output/index.js
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var lib = _interopRequireWildcard(require("./lib"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
console.log(lib);
|
26
tests/fixture/issue-1859/case3/output/index.ts
Normal file
26
tests/fixture/issue-1859/case3/output/index.ts
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var lib = _interopRequireWildcard(require("./lib"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
console.log(lib);
|
51
tests/fixture/issue-1859/case3/output/lib.js
Normal file
51
tests/fixture/issue-1859/case3/output/lib.js
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
};
|
||||
var _foo = _interopRequireWildcard(require("./foo"));
|
||||
var _bar = _interopRequireWildcard(require("./bar"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
Object.keys(_foo).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _foo[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
Object.keys(_bar).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _bar[key];
|
||||
}
|
||||
});
|
||||
});
|
51
tests/fixture/issue-1859/case3/output/lib.ts
Normal file
51
tests/fixture/issue-1859/case3/output/lib.ts
Normal file
@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
};
|
||||
var _foo = _interopRequireWildcard(require("./foo"));
|
||||
var _bar = _interopRequireWildcard(require("./bar"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
Object.keys(_foo).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _foo[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
Object.keys(_bar).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _bar[key];
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user