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

A0: Improve styled components debugging #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jalooc
Copy link

@jalooc jalooc commented Feb 2, 2023

This is my small initiative to improve styled components debugging: the import change from styled-components to styled-components/macro turns on enhanced debugging tools *, which, among others, add readable component names to the otherwise inhuman class hashes:

before -> after
image

I turned it on locally to make familiarizing with the repo easier; figured I'd make a PR since it's an overall very useful feature.

Note: Fear not the number of changed files - almost all of them are the same, tiny change.


* Normally we'd use a babel plugin for that and thus not have to update the import statements, but since CRA does not allow custom babel config, I had to fall back to using the macro.

@jalooc jalooc requested review from Kocik and deuszx February 2, 2023 01:07
@@ -0,0 +1,5 @@
module.exports = {
styledComponents: {
displayName: process.env.NODE_ENV !== 'production'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turning off the readable names on production - I guess we better not disclose internal, dev details so openly.

Copy link
Collaborator

@Kocik Kocik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I'd not it as a potential change to merge to it up to upstream? We could talk to Ross, the original author when the time comes.

@jalooc
Copy link
Author

jalooc commented Feb 6, 2023

@Kocik Yes, it's a definite candidate for the upstream. Quite significantly improves DOM/components debugging experience using the tools they already have, for pretty much zero cost. Unless they have already solved the problems in a different way: using CRA-rewire (which I did not peak because it's more of a hack).

@jalooc
Copy link
Author

jalooc commented Feb 14, 2023

FYI I'll hold on with merging this until the merge with upstream. This PR is neither breaking, nor intrusive, but involves many files so might make the big merge tad harder - something to consider when we're closer to the that date.

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