diff --git a/Cargo.lock b/Cargo.lock index 29ad66aba..7c043ae27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "modularize_imports" -version = "0.52.0" +version = "0.53.0" dependencies = [ "convert_case", "handlebars", @@ -1668,7 +1668,7 @@ dependencies = [ [[package]] name = "react_remove_properties" -version = "0.7.0" +version = "0.8.0" dependencies = [ "serde", "swc_atoms", @@ -1743,7 +1743,7 @@ checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" [[package]] name = "remove_console" -version = "0.8.0" +version = "0.9.0" dependencies = [ "serde", "swc_atoms", @@ -2136,7 +2136,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "styled_components" -version = "0.79.0" +version = "0.80.0" dependencies = [ "Inflector", "once_cell", @@ -2157,7 +2157,7 @@ dependencies = [ [[package]] name = "styled_jsx" -version = "0.56.0" +version = "0.57.0" dependencies = [ "easy-error", "lightningcss", @@ -2300,7 +2300,7 @@ dependencies = [ [[package]] name = "swc_constify" -version = "0.19.0" +version = "0.20.0" dependencies = [ "once_cell", "rustc-hash", @@ -2762,7 +2762,7 @@ dependencies = [ [[package]] name = "swc_emotion" -version = "0.55.0" +version = "0.56.0" dependencies = [ "base64", "byteorder", @@ -2838,7 +2838,7 @@ dependencies = [ [[package]] name = "swc_magic" -version = "0.2.0" +version = "0.3.0" dependencies = [ "serde", "swc_atoms", @@ -3075,7 +3075,7 @@ dependencies = [ [[package]] name = "swc_relay" -version = "0.27.0" +version = "0.28.0" dependencies = [ "once_cell", "regex", diff --git a/packages/constify/package.json b/packages/constify/package.json index 3eac0c027..c9f836a05 100644 --- a/packages/constify/package.json +++ b/packages/constify/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-constify", - "version": "0.1.24", + "version": "0.1.25", "description": "SWC plugin for optimization", "main": "swc_plugin_constify.wasm", "scripts": { diff --git a/packages/constify/transform/Cargo.toml b/packages/constify/transform/Cargo.toml index 4569274be..c8f439483 100644 --- a/packages/constify/transform/Cargo.toml +++ b/packages/constify/transform/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" name = "swc_constify" repository = "https://github.com/swc-project/plugins.git" -version = "0.19.0" +version = "0.20.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/emotion/package.json b/packages/emotion/package.json index 4b7360944..8b30c1964 100644 --- a/packages/emotion/package.json +++ b/packages/emotion/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-emotion", - "version": "2.5.94", + "version": "2.5.95", "description": "SWC plugin for emotion css-in-js library", "main": "swc_plugin_emotion.wasm", "scripts": { diff --git a/packages/emotion/transform/Cargo.toml b/packages/emotion/transform/Cargo.toml index 8868a2ff2..ace8d907a 100644 --- a/packages/emotion/transform/Cargo.toml +++ b/packages/emotion/transform/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" name = "swc_emotion" repository = "https://github.com/swc-project/plugins.git" -version = "0.55.0" +version = "0.56.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/jest/package.json b/packages/jest/package.json index 47e705630..f084d3b85 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-jest", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for jest", "main": "swc_plugin_jest.wasm", "scripts": { diff --git a/packages/loadable-components/package.json b/packages/loadable-components/package.json index e898f47f1..8d23acef6 100644 --- a/packages/loadable-components/package.json +++ b/packages/loadable-components/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-loadable-components", - "version": "0.3.94", + "version": "0.3.95", "description": "SWC plugin for `@loadable/components`", "main": "swc_plugin_loadable_components.wasm", "scripts": { diff --git a/packages/noop/package.json b/packages/noop/package.json index 9f67ef89f..0a70b0eeb 100644 --- a/packages/noop/package.json +++ b/packages/noop/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-noop", - "version": "1.5.92", + "version": "1.5.93", "description": "Noop SWC plugin, for debugging", "main": "swc_plugin_noop.wasm", "scripts": { diff --git a/packages/react-remove-properties/package.json b/packages/react-remove-properties/package.json index 0af6bfff7..5319a3f40 100644 --- a/packages/react-remove-properties/package.json +++ b/packages/react-remove-properties/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-react-remove-properties", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for https://www.npmjs.com/package/babel-plugin-react-remove-properties", "main": "swc_plugin_react_remove_properties.wasm", "scripts": { diff --git a/packages/react-remove-properties/transform/Cargo.toml b/packages/react-remove-properties/transform/Cargo.toml index b3f0d2d7b..208ecb4fa 100644 --- a/packages/react-remove-properties/transform/Cargo.toml +++ b/packages/react-remove-properties/transform/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" name = "react_remove_properties" repository = "https://github.com/swc-project/plugins.git" -version = "0.7.0" +version = "0.8.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/relay/package.json b/packages/relay/package.json index 8d844492e..fe4fb7c27 100644 --- a/packages/relay/package.json +++ b/packages/relay/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-relay", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for relay", "main": "swc_plugin_relay.wasm", "types": "./types.d.ts", diff --git a/packages/relay/transform/Cargo.toml b/packages/relay/transform/Cargo.toml index 6695301d7..6f4ade304 100644 --- a/packages/relay/transform/Cargo.toml +++ b/packages/relay/transform/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" name = "swc_relay" repository = "https://github.com/swc-project/plugins.git" -version = "0.27.0" +version = "0.28.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/remove-console/package.json b/packages/remove-console/package.json index eecdc8844..9ec78e109 100644 --- a/packages/remove-console/package.json +++ b/packages/remove-console/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-remove-console", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for https://www.npmjs.com/package/babel-plugin-remove-console", "main": "swc_plugin_remove_console.wasm", "scripts": { diff --git a/packages/remove-console/transform/Cargo.toml b/packages/remove-console/transform/Cargo.toml index 4ff9a14a1..5b680ccc9 100644 --- a/packages/remove-console/transform/Cargo.toml +++ b/packages/remove-console/transform/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" name = "remove_console" repository = "https://github.com/swc-project/plugins.git" -version = "0.8.0" +version = "0.9.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/styled-components/package.json b/packages/styled-components/package.json index 902f9aaaf..5d75705c5 100644 --- a/packages/styled-components/package.json +++ b/packages/styled-components/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-styled-components", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for styled-components", "main": "swc_plugin_styled_components.wasm", "scripts": { diff --git a/packages/styled-components/transform/Cargo.toml b/packages/styled-components/transform/Cargo.toml index aa17d8c57..50e59e1c8 100644 --- a/packages/styled-components/transform/Cargo.toml +++ b/packages/styled-components/transform/Cargo.toml @@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0" name = "styled_components" repository = "https://github.com/swc-project/plugins.git" -version = "0.79.0" +version = "0.80.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/packages/styled-components/transform/src/utils/analyzer.rs b/packages/styled-components/transform/src/utils/analyzer.rs index 3eaaf183c..046a5a6c0 100644 --- a/packages/styled-components/transform/src/utils/analyzer.rs +++ b/packages/styled-components/transform/src/utils/analyzer.rs @@ -93,8 +93,6 @@ impl Visit for Analyzer<'_> { } fn visit_import_decl(&mut self, i: &ImportDecl) { - let is_custom = !self.config.top_level_import_paths.is_empty(); - let is_styled = if self.config.top_level_import_paths.is_empty() { &*i.src.value == "styled-components" || i.src.value.starts_with("styled-components/") } else { @@ -105,15 +103,14 @@ impl Visit for Analyzer<'_> { for s in &i.specifiers { match s { ImportSpecifier::Named(s) => { - if is_custom - && s.imported - .as_ref() - .map(|v| match v { - ModuleExportName::Ident(v) => &*v.sym, - ModuleExportName::Str(v) => &*v.value, - }) - .unwrap_or(&*s.local.sym) - == "styled" + if s.imported + .as_ref() + .map(|v| match v { + ModuleExportName::Ident(v) => &*v.sym, + ModuleExportName::Str(v) => &*v.value, + }) + .unwrap_or(&*s.local.sym) + == "styled" { self.state.imported_local_name = Some(s.local.to_id()); } diff --git a/packages/styled-components/transform/tests/fixtures/issue-224/code.js b/packages/styled-components/transform/tests/fixtures/issue-224/code.js new file mode 100644 index 000000000..84156cf38 --- /dev/null +++ b/packages/styled-components/transform/tests/fixtures/issue-224/code.js @@ -0,0 +1,11 @@ +import { styled } from 'styled-components'; + + +const Test = styled.div` + width: 100%; +` +const Test2 = true ? styled.div`` : styled.div`` +const styles = { One: styled.div`` } +let Component +Component = styled.div`` +const WrappedComponent = styled(Inner)`` diff --git a/packages/styled-components/transform/tests/fixtures/issue-224/config.json b/packages/styled-components/transform/tests/fixtures/issue-224/config.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/packages/styled-components/transform/tests/fixtures/issue-224/config.json @@ -0,0 +1 @@ +{} diff --git a/packages/styled-components/transform/tests/fixtures/issue-224/output.js b/packages/styled-components/transform/tests/fixtures/issue-224/output.js new file mode 100644 index 000000000..be61cde0b --- /dev/null +++ b/packages/styled-components/transform/tests/fixtures/issue-224/output.js @@ -0,0 +1,29 @@ +import { styled } from 'styled-components'; +const Test = styled.div.withConfig({ + displayName: "code__Test", + componentId: "sc-8043c6cb-0" +})` + width: 100%; +`; +const Test2 = true ? styled.div.withConfig({ + displayName: "code__Test2", + componentId: "sc-8043c6cb-1" +})`` : styled.div.withConfig({ + displayName: "code__Test2", + componentId: "sc-8043c6cb-2" +})``; +const styles = { + One: styled.div.withConfig({ + displayName: "code__One", + componentId: "sc-8043c6cb-3" + })`` +}; +let Component; +Component = styled.div.withConfig({ + displayName: "code__Component", + componentId: "sc-8043c6cb-4" +})``; +const WrappedComponent = styled(Inner).withConfig({ + displayName: "code__WrappedComponent", + componentId: "sc-8043c6cb-5" +})``; diff --git a/packages/styled-jsx/package.json b/packages/styled-jsx/package.json index 9317ecb94..73c33a64b 100644 --- a/packages/styled-jsx/package.json +++ b/packages/styled-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-styled-jsx", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for styled-jsx", "main": "swc_plugin_styled_jsx.wasm", "scripts": { diff --git a/packages/styled-jsx/transform/Cargo.toml b/packages/styled-jsx/transform/Cargo.toml index 1dd82286d..689064e5a 100644 --- a/packages/styled-jsx/transform/Cargo.toml +++ b/packages/styled-jsx/transform/Cargo.toml @@ -4,7 +4,7 @@ description = "AST transforms visitor for styled-jsx" edition = "2021" license = "Apache-2.0" name = "styled_jsx" -version = "0.56.0" +version = "0.57.0" [features] custom_transform = ["swc_common/concurrent"] diff --git a/packages/swc-magic/package.json b/packages/swc-magic/package.json index 875ecf3cf..b7c435fe3 100644 --- a/packages/swc-magic/package.json +++ b/packages/swc-magic/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-swc-magic", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for swc-magic", "main": "swc_plugin_swc_magic.wasm", "scripts": { diff --git a/packages/swc-magic/transform/Cargo.toml b/packages/swc-magic/transform/Cargo.toml index 8d56598ed..fdede4504 100644 --- a/packages/swc-magic/transform/Cargo.toml +++ b/packages/swc-magic/transform/Cargo.toml @@ -4,7 +4,7 @@ description = "AST transforms visitor for swc-magic" edition = "2021" license = "Apache-2.0" name = "swc_magic" -version = "0.2.0" +version = "0.3.0" [dependencies] serde = { version = "1.0.189", features = ["derive"] } diff --git a/packages/transform-imports/package.json b/packages/transform-imports/package.json index f67714845..fa6aaac28 100644 --- a/packages/transform-imports/package.json +++ b/packages/transform-imports/package.json @@ -1,6 +1,6 @@ { "name": "@swc/plugin-transform-imports", - "version": "1.5.94", + "version": "1.5.95", "description": "SWC plugin for https://www.npmjs.com/package/babel-plugin-transform-imports", "main": "swc_plugin_transform_imports.wasm", "scripts": { diff --git a/packages/transform-imports/transform/Cargo.toml b/packages/transform-imports/transform/Cargo.toml index a1940f3c0..6035f564f 100644 --- a/packages/transform-imports/transform/Cargo.toml +++ b/packages/transform-imports/transform/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" name = "modularize_imports" repository = "https://github.com/swc-project/plugins.git" -version = "0.52.0" +version = "0.53.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 70701d4b9..ef65ae469 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -2,6 +2,7 @@ name = "xtask" version = "0.2.0" edition = "2021" +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html