Skip to content
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

refactor(next/swc): introduce swc_core for upstream SWC dep import references #39887

Closed
wants to merge 8 commits into from
Closed
2 changes: 1 addition & 1 deletion packages/next-swc/crates/core/src/hook_optimizer.rs
Expand Up @@ -74,7 +74,7 @@ impl HookOptimizer {
} = &decl;
let init_clone = init.clone();
if let Pat::Array(a) = name {
if let Expr::Call(c) = &*init.as_deref().unwrap() {
if let Expr::Call(c) = init.as_deref().unwrap() {
kdy1 marked this conversation as resolved.
Show resolved Hide resolved
if let Callee::Expr(i) = &c.callee {
if let Expr::Ident(Ident { sym, .. }) = &**i {
if self.hooks.contains(sym) {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/emotion/src/import_map.rs
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn expand_import_map(
.for_each(|(local_export_name, Config { canonical_import })| {
let ImportItem(package_name, export_name) = canonical_import;

if &*package_name == "@emotion/react" && &*export_name == "jsx" {
if &**package_name == "@emotion/react" && &**export_name == "jsx" {
return;
}

Expand Down
Expand Up @@ -312,7 +312,7 @@ impl State {
}

pub fn prefix_leading_digit(s: &str) -> Cow<str> {
if s.chars().next().map(|c| c.is_digit(10)).unwrap_or(false) {
if s.chars().next().map(|c| c.is_ascii_digit()).unwrap_or(false) {
Cow::Owned(format!("sc-{}", s))
} else {
Cow::Borrowed(s)
Expand Down
6 changes: 3 additions & 3 deletions packages/next-swc/crates/styled_jsx/src/lib.rs
Expand Up @@ -174,7 +174,7 @@ impl Fold for StyledJSXTransformer {
if let JSXElementName::Ident(Ident { sym, span, .. }) = &el.name {
if sym != "style"
&& sym != self.style_import_name.as_ref().unwrap()
&& (!is_capitalized(&*sym)
&& (!is_capitalized(&**sym)
|| self
.nearest_scope_bindings
.contains(&(sym.clone(), span.ctxt)))
Expand Down Expand Up @@ -536,13 +536,13 @@ impl StyledJSXTransformer {
}
}

return JSXStyle::Local(LocalStyle {
JSXStyle::Local(LocalStyle {
hash: format!("{:x}", hasher.finish()),
css,
css_span,
is_dynamic,
expressions,
});
})
}

fn replace_jsx_style(&mut self, el: &JSXElement) -> Result<JSXElement, Error> {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/styled_jsx/src/transform_css.rs
Expand Up @@ -115,7 +115,7 @@ pub fn transform_css(
/// Returns `(length, value)`
fn read_number(s: &str) -> (usize, usize) {
for (idx, c) in s.char_indices() {
if c.is_digit(10) {
if c.is_ascii_digit() {
continue;
}

Expand Down