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

[Demo] Improve learning experience by keeping component names in React DevTools #6457

Merged
merged 1 commit into from
Jul 22, 2021

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Jul 22, 2021

Problem

Create-React-App uses the TerserPlugin to minimize the production build. One side effect is that it removes the React component names, which makes a poor learning experience in our demos since the React DevTools show all components as "Anonymous":

Capture d’écran 2021-07-22 083435

Capture d’écran 2021-07-22 084136

Solution

Override the Webpack TerserPlugin configuration to disable name mangling.

While this change increases the build size a bit (about +35kB), we don't really care as our demos are intended for learning.

Capture d’écran 2021-07-22 083644

Capture d’écran 2021-07-22 084212

Bonus: I enabled the React Profiler in production mode, too.

These changes have already been pushed to the demos:

@fzaninotto fzaninotto added the RFR Ready For Review label Jul 22, 2021
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"homepage": "https://marmelab.com/react-admin-crm",
"homepage": ".",
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows the built site to be served from any location. It's more flexible than restricting it to one URL, and works better locally without breaking the production build.

See https://stackoverflow.com/a/44048328/1333479

Copy link
Collaborator

@djhi djhi left a comment

Choose a reason for hiding this comment

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

Nice!

@djhi djhi merged commit 75b7dd0 into master Jul 22, 2021
@djhi djhi deleted the improve-examples-observability branch July 22, 2021 06:56
@djhi djhi added this to the 3.17.1 milestone Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants