diff --git a/Cargo.lock b/Cargo.lock index 8495234bde47..11d3a1fedc5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2307,7 +2307,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "swc" -version = "0.66.0" +version = "0.66.1" dependencies = [ "ahash", "anyhow", @@ -2412,7 +2412,7 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "0.67.0" +version = "0.67.1" dependencies = [ "ahash", "anyhow", @@ -2579,7 +2579,7 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.74.1" +version = "0.74.2" dependencies = [ "bitflags", "memchr", @@ -2655,7 +2655,7 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.36.0" +version = "0.36.1" dependencies = [ "ansi_term 0.12.1", "anyhow", @@ -2713,7 +2713,7 @@ dependencies = [ [[package]] name = "swc_ecma_preset_env" -version = "0.51.0" +version = "0.51.1" dependencies = [ "dashmap", "indexmap", @@ -2739,7 +2739,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.80.0" +version = "0.80.1" dependencies = [ "pretty_assertions 0.6.1", "sourcemap", @@ -2856,7 +2856,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.50.0" +version = "0.50.1" dependencies = [ "dashmap", "indexmap", @@ -2954,7 +2954,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "0.46.1" +version = "0.46.2" dependencies = [ "rustc-hash", "serde", @@ -3002,7 +3002,7 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.72.0" +version = "0.72.1" dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", @@ -3513,7 +3513,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm" -version = "1.2.94" +version = "1.2.95" dependencies = [ "anyhow", "console_error_panic_hook", diff --git a/Cargo.toml b/Cargo.toml index 1c11a93fd002..b704e2afdbe7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc" repository = "https://github.com/swc-project/swc.git" -version = "0.66.0" +version = "0.66.1" [lib] name = "swc" @@ -52,16 +52,16 @@ serde = {version = "1", features = ["derive"]} serde_json = "1" sourcemap = "6" swc_atoms = {version = "0.2", path = "./atoms"} -swc_bundler = {version = "0.67.0", path = "./bundler"} +swc_bundler = {version = "0.67.1", path = "./bundler"} swc_common = {version = "0.13.0", path = "./common", features = ["sourcemap", "concurrent"]} swc_ecma_ast = {version = "0.54.0", path = "./ecmascript/ast"} swc_ecma_codegen = {version = "0.74.0", path = "./ecmascript/codegen"} swc_ecma_ext_transforms = {version = "0.31.0", path = "./ecmascript/ext-transforms"} swc_ecma_loader = {version = "0.20.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]} -swc_ecma_minifier = {version = "0.36.0", path = "./ecmascript/minifier"} +swc_ecma_minifier = {version = "0.36.1", path = "./ecmascript/minifier"} swc_ecma_parser = {version = "0.73.0", path = "./ecmascript/parser"} -swc_ecma_preset_env = {version = "0.51.0", path = "./ecmascript/preset-env"} -swc_ecma_transforms = {version = "0.80.0", path = "./ecmascript/transforms", features = [ +swc_ecma_preset_env = {version = "0.51.1", path = "./ecmascript/preset-env"} +swc_ecma_transforms = {version = "0.80.1", path = "./ecmascript/transforms", features = [ "compat", "module", "optimization", @@ -72,7 +72,7 @@ swc_ecma_transforms = {version = "0.80.0", path = "./ecmascript/transforms", fea swc_ecma_transforms_base = {version = "0.35.0", path = "./ecmascript/transforms/base"} swc_ecma_utils = {version = "0.46.0", path = "./ecmascript/utils"} swc_ecma_visit = {version = "0.40.0", path = "./ecmascript/visit"} -swc_ecmascript = {version = "0.72.0", path = "./ecmascript"} +swc_ecmascript = {version = "0.72.1", path = "./ecmascript"} swc_visit = {version = "0.2.3", path = "./visit"} tracing = "0.1.28" diff --git a/bundler/Cargo.toml b/bundler/Cargo.toml index 9ba8e0ce1f16..d3afdd73d077 100644 --- a/bundler/Cargo.toml +++ b/bundler/Cargo.toml @@ -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.67.0" +version = "0.67.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -36,7 +36,7 @@ swc_ecma_ast = {version = "0.54.0", path = "../ecmascript/ast"} swc_ecma_codegen = {version = "0.74.0", path = "../ecmascript/codegen"} swc_ecma_loader = {version = "0.20.0", path = "../ecmascript/loader"} swc_ecma_parser = {version = "0.73.0", path = "../ecmascript/parser"} -swc_ecma_transforms = {version = "0.80.0", path = "../ecmascript/transforms", features = ["optimization"]} +swc_ecma_transforms = {version = "0.80.1", path = "../ecmascript/transforms", features = ["optimization"]} swc_ecma_utils = {version = "0.46.0", path = "../ecmascript/utils"} swc_ecma_visit = {version = "0.40.0", path = "../ecmascript/visit"} tracing = "0.1.28" @@ -47,7 +47,7 @@ ntest = "0.7.2" path-clean = "=0.1.0" reqwest = {version = "0.11.4", features = ["blocking"]} sha-1 = "0.9" -swc_ecma_transforms = {version = "0.80.0", path = "../ecmascript/transforms", features = ["react", "typescript"]} +swc_ecma_transforms = {version = "0.80.1", path = "../ecmascript/transforms", features = ["react", "typescript"]} swc_node_base = {version = "0.4.0", path = "../node/base"} tempfile = "3.1.0" testing = {version = "0.14.0", path = "../testing"} diff --git a/ecmascript/Cargo.toml b/ecmascript/Cargo.toml index be64b43062ed..e194354ed0db 100644 --- a/ecmascript/Cargo.toml +++ b/ecmascript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecmascript" repository = "https://github.com/swc-project/swc.git" -version = "0.72.0" +version = "0.72.1" [package.metadata.docs.rs] all-features = true @@ -35,10 +35,10 @@ typescript = ["typescript-parser", "swc_ecma_transforms/typescript"] swc_ecma_ast = {version = "0.54.0", path = "./ast"} swc_ecma_codegen = {version = "0.74.0", path = "./codegen", optional = true} swc_ecma_dep_graph = {version = "0.42.0", path = "./dep-graph", optional = true} -swc_ecma_minifier = {version = "0.36.0", path = "./minifier", optional = true} +swc_ecma_minifier = {version = "0.36.1", path = "./minifier", optional = true} swc_ecma_parser = {version = "0.73.0", path = "./parser", optional = true, default-features = false} -swc_ecma_preset_env = {version = "0.51.0", path = "./preset-env", optional = true} -swc_ecma_transforms = {version = "0.80.0", path = "./transforms", optional = true} +swc_ecma_preset_env = {version = "0.51.1", path = "./preset-env", optional = true} +swc_ecma_transforms = {version = "0.80.1", path = "./transforms", optional = true} swc_ecma_utils = {version = "0.46.0", path = "./utils", optional = true} swc_ecma_visit = {version = "0.40.0", path = "./visit", optional = true} diff --git a/ecmascript/codegen/Cargo.toml b/ecmascript/codegen/Cargo.toml index 26d2f14cca94..fe775b86682f 100644 --- a/ecmascript/codegen/Cargo.toml +++ b/ecmascript/codegen/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_codegen" repository = "https://github.com/swc-project/swc.git" -version = "0.74.1" +version = "0.74.2" [dependencies] bitflags = "1" diff --git a/ecmascript/codegen/src/lib.rs b/ecmascript/codegen/src/lib.rs index 18da3499eaff..e332e72f37f1 100644 --- a/ecmascript/codegen/src/lib.rs +++ b/ecmascript/codegen/src/lib.rs @@ -178,12 +178,19 @@ where } #[emitter] - fn emit_import(&mut self, node: &ImportDecl) -> Result { - self.emit_leading_comments_of_span(node.span(), false)?; + fn emit_import(&mut self, n: &ImportDecl) -> Result { + self.emit_leading_comments_of_span(n.span(), false)?; - keyword!("import"); - let starts_with_ident = !node.specifiers.is_empty() - && match &node.specifiers[0] { + { + let span = if n.span.is_dummy() { + DUMMY_SP + } else { + Span::new(n.span.lo, n.span.lo + BytePos(6), Default::default()) + }; + keyword!(span, "import"); + } + let starts_with_ident = !n.specifiers.is_empty() + && match &n.specifiers[0] { ImportSpecifier::Default(_) => true, _ => false, }; @@ -196,7 +203,7 @@ where let mut specifiers = vec![]; let mut emitted_default = false; let mut emitted_ns = false; - for specifier in &node.specifiers { + for specifier in &n.specifiers { match specifier { ImportSpecifier::Named(ref s) => { specifiers.push(s); @@ -213,7 +220,7 @@ where emitted_ns = true; - assert!(node.specifiers.len() <= 2); + assert!(n.specifiers.len() <= 2); punct!("*"); formatting_space!(); keyword!("as"); @@ -237,7 +244,7 @@ where punct!("{"); self.emit_list( - node.span(), + n.span(), Some(&specifiers), ListFormat::NamedImportsOrExportsElements, )?; @@ -248,7 +255,7 @@ where formatting_space!(); } - emit!(node.src); + emit!(n.src); formatting_semi!(); } diff --git a/ecmascript/minifier/Cargo.toml b/ecmascript/minifier/Cargo.toml index 33b31f6a0803..344021a74e98 100644 --- a/ecmascript/minifier/Cargo.toml +++ b/ecmascript/minifier/Cargo.toml @@ -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.36.0" +version = "0.36.1" [features] debug = ["backtrace"] @@ -29,7 +29,7 @@ swc_common = {version = "0.13.0", path = "../../common"} swc_ecma_ast = {version = "0.54.0", path = "../ast"} swc_ecma_codegen = {version = "0.74.0", path = "../codegen"} swc_ecma_parser = {version = "0.73.0", path = "../parser"} -swc_ecma_transforms = {version = "0.80.0", path = "../transforms/", features = ["optimization"]} +swc_ecma_transforms = {version = "0.80.1", path = "../transforms/", features = ["optimization"]} swc_ecma_transforms_base = {version = "0.35.0", path = "../transforms/base"} swc_ecma_utils = {version = "0.46.0", path = "../utils"} swc_ecma_visit = {version = "0.40.0", path = "../visit"} diff --git a/ecmascript/preset-env/Cargo.toml b/ecmascript/preset-env/Cargo.toml index f5c627f34a6c..a67ec2f21cfa 100644 --- a/ecmascript/preset-env/Cargo.toml +++ b/ecmascript/preset-env/Cargo.toml @@ -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.51.0" +version = "0.51.1" # 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.13.0", path = "../../common"} swc_ecma_ast = {version = "0.54.0", path = "../ast"} -swc_ecma_transforms = {version = "0.80.0", path = "../transforms", features = ["compat", "proposal"]} +swc_ecma_transforms = {version = "0.80.1", path = "../transforms", features = ["compat", "proposal"]} swc_ecma_utils = {version = "0.46.0", path = "../utils"} swc_ecma_visit = {version = "0.40.0", path = "../visit"} walkdir = "2" diff --git a/ecmascript/transforms/Cargo.toml b/ecmascript/transforms/Cargo.toml index af14073ce8db..874e663c2178 100644 --- a/ecmascript/transforms/Cargo.toml +++ b/ecmascript/transforms/Cargo.toml @@ -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.80.0" +version = "0.80.1" [package.metadata.docs.rs] all-features = true @@ -28,10 +28,10 @@ swc_ecma_parser = {version = "0.73.0", path = "../parser"} swc_ecma_transforms_base = {version = "0.35.0", path = "./base"} swc_ecma_transforms_compat = {version = "0.40.0", path = "./compat", optional = true} swc_ecma_transforms_module = {version = "0.44.0", path = "./module", optional = true} -swc_ecma_transforms_optimization = {version = "0.50.0", path = "./optimization", optional = true} +swc_ecma_transforms_optimization = {version = "0.50.1", path = "./optimization", optional = true} swc_ecma_transforms_proposal = {version = "0.44.0", path = "./proposal", optional = true} swc_ecma_transforms_react = {version = "0.46.0", path = "./react", optional = true} -swc_ecma_transforms_typescript = {version = "0.46.1", path = "./typescript", optional = true} +swc_ecma_transforms_typescript = {version = "0.46.2", path = "./typescript", optional = true} swc_ecma_utils = {version = "0.46.0", path = "../utils"} swc_ecma_visit = {version = "0.40.0", path = "../visit"} unicode-xid = "0.2" diff --git a/ecmascript/transforms/optimization/Cargo.toml b/ecmascript/transforms/optimization/Cargo.toml index 778953b1c560..a0357a2b13d9 100644 --- a/ecmascript/transforms/optimization/Cargo.toml +++ b/ecmascript/transforms/optimization/Cargo.toml @@ -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.50.0" +version = "0.50.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -32,5 +32,5 @@ swc_ecma_transforms_module = {version = "0.44.0", path = "../module"} swc_ecma_transforms_proposal = {version = "0.44.0", path = "../proposal"} swc_ecma_transforms_react = {version = "0.46.0", path = "../react"} swc_ecma_transforms_testing = {version = "0.36.0", path = "../testing"} -swc_ecma_transforms_typescript = {version = "0.46.1", path = "../typescript"} +swc_ecma_transforms_typescript = {version = "0.46.2", path = "../typescript"} testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/typescript/Cargo.toml b/ecmascript/transforms/typescript/Cargo.toml index 37b905cbd216..7865d740ddc2 100644 --- a/ecmascript/transforms/typescript/Cargo.toml +++ b/ecmascript/transforms/typescript/Cargo.toml @@ -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.46.1" +version = "0.46.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/ecmascript/transforms/typescript/src/strip.rs b/ecmascript/transforms/typescript/src/strip.rs index bb30713e37a2..939cf8ff986f 100644 --- a/ecmascript/transforms/typescript/src/strip.rs +++ b/ecmascript/transforms/typescript/src/strip.rs @@ -1444,16 +1444,18 @@ impl VisitMut for Strip { } fn visit_mut_import_decl(&mut self, import: &mut ImportDecl) { - if &*import.src.value == "react" { - return; - } - self.is_side_effect_import = import.specifiers.is_empty(); + let src = &import.src; import.specifiers.retain(|s| match *s { ImportSpecifier::Named(ImportNamedSpecifier { ref is_type_only, .. }) if *is_type_only => false, + + ImportSpecifier::Default(..) if &*src.value == "react" => { + return true; + } + ImportSpecifier::Default(ImportDefaultSpecifier { ref local, .. }) | ImportSpecifier::Named(ImportNamedSpecifier { ref local, .. }) | ImportSpecifier::Namespace(ImportStarAsSpecifier { ref local, .. }) => { diff --git a/package.json b/package.json index e50b0bbcd5a4..92740ae9afa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@swc/core", - "version": "1.2.94", + "version": "1.2.95", "description": "Super-fast alternative for babel", "homepage": "https://swc.rs", "main": "./index.js", diff --git a/tests/fixture/deno-10014/case1/output/index.map b/tests/fixture/deno-10014/case1/output/index.map index 893a7e860815..eccb7e2355ab 100644 --- a/tests/fixture/deno-10014/case1/output/index.map +++ b/tests/fixture/deno-10014/case1/output/index.map @@ -1,5 +1,5 @@ { - "mappings": "OAAO,CAAa;SAEX,CAAC,GAAG,CAAC;IACV,CAAC;AACL,CAAC;SAEQ,CAAC,CAAC,KAAS,EAAE,CAAC;QAAZ,CAAC,GAAD,KAAS,cAAL,KAAK,GAAT,KAAS;IAChB,EAAE,EAAE,CAAC,EAAE,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAO;IAC3B,CAAC;IACD,CAAC,EAAE,CAAC;AACR,CAAC;AAED,CAAC", + "mappings": "AAAA,MAAM,CAAC,CAAa;SAEX,CAAC,GAAG,CAAC;IACV,CAAC;AACL,CAAC;SAEQ,CAAC,CAAC,KAAS,EAAE,CAAC;QAAZ,CAAC,GAAD,KAAS,cAAL,KAAK,GAAT,KAAS;IAChB,EAAE,EAAE,CAAC,EAAE,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAO;IAC3B,CAAC;IACD,CAAC,EAAE,CAAC;AACR,CAAC;AAED,CAAC", "names": [ "a", "t", diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index f1bf3fc9e768..dd0f7baf1231 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -6,7 +6,7 @@ license = "Apache-2.0 AND MIT" name = "wasm" publish = false repository = "https://github.com/swc-project/swc.git" -version = "1.2.94" +version = "1.2.95" [lib] crate-type = ["cdylib"]