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

"Disabled SWC as replacement for Babel because of custom Babel configuration"? #20

Closed
andrewschreiber opened this issue Jan 4, 2022 · 12 comments
Labels
help wanted Extra attention is needed

Comments

@andrewschreiber
Copy link

andrewschreiber commented Jan 4, 2022

One of the big upgrades in Next 12 is use of the fast rust compiler SWC. Is there any way this .babelrc could be altered or removed while maintaining project functionality?

{
  "presets": [
    [
      "next/babel",
      {
        "styled-jsx": {
          "plugins": ["styled-jsx-plugin-postcss"]
        }
      }
    ]
  ]
}
@ixartz
Copy link
Owner

ixartz commented Jan 4, 2022

I have already spend several days looking for a solution. Currently, there aren't any solution I'm totally satisfy.

Someone already shared the babel config for SWC support:
vercel/next.js#30174 (comment)

Maybe we should wait Vercel to add support?

I'm totally open for ideas.

@ixartz ixartz added help wanted Extra attention is needed enhancement New feature or request and removed help wanted Extra attention is needed enhancement New feature or request labels Jan 4, 2022
@ixartz
Copy link
Owner

ixartz commented Jan 4, 2022

Do you see any slowness using the boilerplate?
I'm using for several Next JS projects and I don't see any issue even without using SWC compiler.

@andrewschreiber
Copy link
Author

Still is pretty quick. Vercel builds in about a minute, though ~12 seconds would be incredible (if the 5x claims are to be believed).

I think it makes sense to wait for Vercel to support it.

I am curious about removing styled-jsx altogether. Haven't used it before and I've been pretty happy with vanilla tailwind. What use do you still find for it?

@ixartz
Copy link
Owner

ixartz commented Jan 5, 2022

If you don't used styled-jsx, I think you can remove .babelrc, remove the dependencies in package.json and you should be able to enjoy SWC speed.

I added styled-jsx support because

  • It's one of Next JS core feature. It doesn't mean we should keep it...
  • There is currently some limitation in vanilla tailwind for selector. styled-jsx is able to solve it with some powerful CSS selector.

@andrewschreiber
Copy link
Author

Which selector are your referring to?

@ixartz
Copy link
Owner

ixartz commented Jan 10, 2022

Something you are currently not able to do it with Tailwind CSS is the children selector: styling the children with Tailwind. Or, the CSS attribute selector.

Maybe, we should the other way around: try to enable swc by removing the custom babel and if someone need a powerful selector, he can add it.

@oliverpatrick
Copy link

Something you are currently not able to do it with Tailwind CSS is the children selector: styling the children with Tailwind. Or, the CSS attribute selector.

Maybe, we should the other way around: try to enable swc by removing the custom babel and if someone need a powerful selector, he can add it.

Sorry if I'm mistaken with my understanding of this. Are you aware of the custom class names you can use in TailwindCSS currently? You can select pure selectors and group attributes together to select exactly what you need.

With that being said it was made in the interests of speed to do as you mentioned in the latter part of your response and remove the dependencies and the .babelrc file.

@ixartz
Copy link
Owner

ixartz commented Mar 11, 2022

@oliverpatrick Thank you for your message and your suggestion.
I reread your suggestion several and didn't fully understand your solution.
Could you share me example or a link to the documentation?

@oliverpatrick
Copy link

oliverpatrick commented Mar 12, 2022

@ixartz Sorry about that. As I said, excuse me if I’m mistaken. After a quick google search I couldn’t find anything conclusive.

Fireship on YouTube however covers quite a concise little video on tailwind and roughly mentions what I mean. I have timestamped the link for you: https://youtu.be/pfaSUYaSgRo?t=503

Hope this helps.

@ixartz
Copy link
Owner

ixartz commented Mar 12, 2022

@oliverpatrick Thank you for taking the time to share the solution. It's one possible solution but it isn't as easy as I expected.
Here is someone asking the same thing: tailwindlabs/tailwindcss#1984

I think it's an edge case: styled-jsx-plugin-postcss doesn't need for all project. We can remove it from the boilerplate and we can use the rust compiler.

@oliverpatrick
Copy link

Spot on. Thank you for taking the time to review my comments and making the boilerplate. I’m glad I could offer feedback.

@ixartz
Copy link
Owner

ixartz commented Mar 14, 2022

@oliverpatrick @andrewschreiber I just remove styled-jsx-plugin-postcss and .babelrc. By default, the boilerplate now uses SWC compiler and the warning is now removed: "Disabled SWC as replacement for Babel because of custom Babel configuration"

@ixartz ixartz closed this as completed Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants