-
Notifications
You must be signed in to change notification settings - Fork 507
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
Doesn't play well with babel-plugin-styled-components -- plugin order matters #543
Comments
The Babel plugins that are used internally are here: Lines 64 to 102 in 3a6d42f
It might be that the Rollup plugins that are run prior change some things too (or Rollup itself). Are you using a custom Also please ignore the reference above, that was an accident as I was trying to reference two PRs I made back-to-back but this issue was created in-between |
Sorry, no there's no custom
I've even tried messing up this name, which outputs an error. That's evidence that it does pick up my plugin properly. Looking at I've also looked at typescript-plugin-styled-components which is supposed to do the same, but it's unclear how or where I should integrate that with tsdx. |
Custom plugins get added to the end of the default plugins list (unless they are merged with the defaults): Line 25 in 3a6d42f
Yea idk what it's not interacting with well. There seem to be some issues at styled-components as well like styled-components/babel-plugin-styled-components#243 that might be related as well as some on other Babel plugins. You'd have to override the You might want to try the styled-components Babel macro instead as some reports there say it has less issues. But that does require some more config if you're testing with Jest due to #383 |
How can I try that? I'd like to add it sooner to diagnose if load order is causing the issue. As for your other remarks, basically you're telling me what you'd recommend against 😀 So thanks for the info, I guess. I'd rather not write a whole bunch more config (nevermind if it's hacky), because as a general rule, config becomes exponentially harder to maintain as it grows. |
You can't -- the default plugins of TSDX don't include
I also mentioned trying the styled-components Babel macro. If it works, that would be the easiest solution by a fairly big margin. And some of the styled-components issues point to downgrading as a possible solution. |
Sorry, I must have misinterpreted indeed. I'll try the macro solution. |
Can you please report if the macro solution worked for you? Thank you. |
Ok, so I added an integration test in #627 that indeed fails to show an impact with this plugin (comments aren't removed). It seems that the docs even say that "plugin order matters" and to put it first, but TSDX doesn't quite let you control that order right now. Will be looking to improve that with presets, but it's a tough problem in general (it's even mentioned in the Also, looking at the I might be able to change |
So changing |
Sorry I haven't come around to it yet. It's not super important, so we haven't given this much priority. Glad to see you're making progress regardless 😎 |
Workaround making |
This comment has been minimized.
This comment has been minimized.
@allcontributors please add @thany for bug (it's not entirely a bug, as it's not in core, but a bug with an integration, but closest thing) |
I've put up a pull request to add @thany! 🎉 |
I can't seem to get styled-components Steps:
When I check it in the example parcel app, it doesn't seem to be respecting the css prop. Would appreciate it if anyone knows what's going on here. I thought it may be related to parcel, but can't figure it out. |
* Improve styled components build related docs: - jaredpalmer/tsdx#543 - jaredpalmer/tsdx#383 - https://styled-components.com/docs/tooling#babel-macro * v0.1.26-0
Same problem with Styled-JSX library 😞 |
Maintainer Update
For any new readers of this issue, per #543 (comment), you can use
styled-components/macro
instead ofbabel-plugin-styled-components
, which will work.Current Behavior
I'm using
babel-plugin-styled-components
to annotate styled-components with CSS classes to more easily debug them in the browser's inspector.Expected behavior
I'd expect this plugin to do something. Namely, do what it says on the tin. And it does when I run storybook for our project. But it doesn't when I'm done and want to build my project through tsdx.
Suggested solution(s)
Perhaps babel plugins ought to be merged differently. I suspect the plugins from
.babelrc
are executed too early or too late. I find it massively complicated to figure out what exactly is happening under the hood, and therefor I have no way of knowing how and when a babel plugin is executed, or supposed to be executed. But since the plugin itself does work, there must be an issue with how or when it's being called.Additional context
Our project is based on React + styled-components in Storybook. In Storybook, babel-plugin-styled-components does it job beautifully. But in the tsdx build, it does not, and indeed, I cannot find any mention of the classnames that are supposed to be generated. Having or not having this plugin, literally makes not a byte of difference in the dist files that tsdx generates.
Your environment
The text was updated successfully, but these errors were encountered: