-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable configuration of styled-components
transform and enable css
prop support
#37861
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9c6631d
feat: enable configuration of `styled-components` transform and enabl…
ForsakenHarmony 17645e4
lint
ForsakenHarmony 2c987dd
run display name pass after css prop
ForsakenHarmony b8882a0
assert background color and add remove `displayName` from test config…
ForsakenHarmony 712978e
only allocate string when it matches the file_stem
ForsakenHarmony 2e1d29c
assert displayName generation
ForsakenHarmony 12dd028
Merge branch 'canary' into styled-components-options
kodiakhq[bot] 911df7b
Merge branch 'canary' into styled-components-options
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,5 +209,5 @@ | |
"node": ">=12.22.0", | ||
"pnpm": ">= 7.2.1" | ||
}, | ||
"packageManager": "pnpm@7.2.1" | ||
"packageManager": "pnpm@7.3.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
pub use self::analyzer::{analyze, analyzer}; | ||
use once_cell::sync::Lazy; | ||
use regex::{Captures, Regex}; | ||
use std::{borrow::Cow, cell::RefCell}; | ||
use swc_atoms::js_word; | ||
use swc_common::{collections::AHashMap, SyntaxContext}; | ||
|
@@ -210,7 +208,11 @@ impl State { | |
false | ||
} | ||
|
||
fn import_local_name(&self, name: &str, cache_identifier: Option<&Ident>) -> Option<Id> { | ||
pub(crate) fn import_local_name( | ||
&self, | ||
name: &str, | ||
cache_identifier: Option<&Ident>, | ||
) -> Option<Id> { | ||
if name == "default" { | ||
if let Some(cached) = self.imported_local_name.clone() { | ||
return Some(cached); | ||
|
@@ -251,6 +253,10 @@ impl State { | |
name | ||
} | ||
|
||
pub(crate) fn set_import_name(&mut self, id: Id) { | ||
self.imported_local_name = Some(id); | ||
} | ||
|
||
fn is_helper(&self, e: &Expr) -> bool { | ||
self.is_create_global_style_helper(e) | ||
|| self.is_css_helper(e) | ||
|
@@ -304,10 +310,9 @@ impl State { | |
} | ||
|
||
pub fn prefix_leading_digit(s: &str) -> Cow<str> { | ||
static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"^(\d)").unwrap()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. regex here was overkill |
||
|
||
REGEX.replace(s, |s: &Captures| { | ||
// | ||
format!("sc-{}", s.get(0).unwrap().as_str()) | ||
}) | ||
if s.chars().next().map(|c| c.is_digit(10)).unwrap_or(false) { | ||
Cow::Owned(format!("sc-{}", s)) | ||
} else { | ||
Cow::Borrowed(s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't sure if it would count as a breaking change if this was enabled by default, would probably be best if it was enabled.