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

styled-jsx plugin doesn't handle interpolation braces correctly in some cases #340

Open
fmmoret opened this issue Aug 27, 2024 · 3 comments
Assignees

Comments

@fmmoret
Copy link

fmmoret commented Aug 27, 2024

    "@swc/cli": "0.4.0",
    "@swc/core": "1.7.18",
    "@swc/helpers": "0.5.12",

Minimal repro -- color: blue won't be applied. The parser appears to be matching on the } in ${FontStyle.Headline2}

       .heading-container {
          ${FontStyle.Headline2}
        }
        * {
          color: blue;
        }

If I paste in the value of FontStyle.Headline2 directly, it works correctly. OR if I add in extra attributes below like:

       .heading-container {
          ${FontStyle.Headline2}
          padding: 1px;
        }
        * {
          color: blue;
        }

Then it also works fine.

FontStyle.Headline2:

      font-weight: 600;
    
      
      font-family: 'NeueKabel', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    
      font-size: 36px;
      letter-spacing: -0.022em;
      line-height: 120%;
@fmmoret
Copy link
Author

fmmoret commented Aug 27, 2024

Issue just showed up after upgrading swc. Used to work on very old versions.

@fmmoret
Copy link
Author

fmmoret commented Nov 13, 2024

@kdy1 Can you give pointers as to where this fix could be made? It is blocking my team from upgrading, but the general vicinity of the parsing fix is difficult for me to locate

@kdy1
Copy link
Member

kdy1 commented Nov 14, 2024

pub fn transform_css(
cm: Arc<SourceMap>,
style_info: &LocalStyle,
is_global: bool,
class_name: &Option<String>,
browsers: &Versions,
native: &NativeConfig,
) -> Result<Expr, Error> {
and
pub fn transform_css(
_cm: Arc<SourceMap>,
style_info: &LocalStyle,
is_global: bool,
class_name: &Option<String>,
native: &NativeConfig,
) -> Result<Expr, Error> {

Those are for lightningcss mode and swc_css mode respectively

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants