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

[Bug]: @swc/plugin-styled-jsx not working in rsbuild #1960

Closed
uncaught opened this issue Mar 29, 2024 · 2 comments
Closed

[Bug]: @swc/plugin-styled-jsx not working in rsbuild #1960

uncaught opened this issue Mar 29, 2024 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@uncaught
Copy link

uncaught commented Mar 29, 2024

Version

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
    Memory: 11.32 GB / 15.62 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  npmPackages:
    @rsbuild/core: ^0.5.4 => 0.5.4
    @rsbuild/plugin-react: ^0.5.4 => 0.5.4

Details

All I did was using npm create rsbuild@latest and then tried to get styled-jsx with resolve to work. (Sass is a bonus here.)

Without any extra configuration, I run into this obvious error:

Uncaught Error: styled-jsx/css: if you are getting this error it means that your `resolve` tagged template literals were not transpiled.

After digging into the documentation, I've added this to the configuration:

  tools: {
    swc: {
      jsc: {
        experimental: {
          plugins: [
            [
              '@swc/plugin-styled-jsx',
              {
                plugins: ['@styled-jsx/plugin-sass'],
              },
            ],
          ],
        },
      },
    },
  },

As documented here and then here.

But that gives me this error:

Html Webpack Plugin:
Error: [html-rspack-plugin]: [html-rspack-plugin]:   × Module parse failed:
  ╰─▶   × JavaScript parsing error: Expression expected
         ╭────
       1 │  = this;
         ·  ─
         ╰────
      
  help: 
        File was processed with these loaders:
         * builtin:swc-loader??ruleSet[1].rules[3].use[0]
        You may need an additional loader to handle the result of these loaders.

I don't know where I'm going wrong here. I've not configured any HTML plugin and I can't find any issues regarding this problem.


I'm totally new to rsbuild/rspack/swc, so please point me in the right direction if this is the wrong place for this issue.

Reproduce link

https://github.com/uncaught/rsbuild-test

Reproduce Steps

git clone [email protected]:uncaught/rsbuild-test.git
cd rsbuild-test
npm install
npm run dev
@uncaught uncaught added the 🐞 bug Something isn't working label Mar 29, 2024
@chenjiahan
Copy link
Member

This might be an issue of SWC version mismatch, see: web-infra-dev/rspack#5921

@uncaught
Copy link
Author

This might be an issue of SWC version mismatch, see: web-infra-dev/rspack#5921

Thank you a lot! That was it. I locked the version to @swc/[email protected] which works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants