question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Distribute source maps for easier debugging in Chrome's Performance tab

See original GitHub issue

I want to propose the addition of a new file in the react-dom npm package called react-dom.production.js — a non-minified version of react-dom production build.

Edit: After some discussion(see below) it seems that distributing source maps makes more sense. Source maps will help you see the real function names and explore them. (The points below apply for source maps as well.)

Why?

There are a few ways to profile React’s performance — none of them provide a low-level view of what’s happening. I believe the best way to profile React is using Chrome’s Performance tab using a non-minified production build. Here’s why:

  • Familiar. People use the Performance tab for every other performance profiling so they are familiar with how to use it.
  • Powerful. The Performance tab is extremely powerful. Years of engineering have been put into developing it.
  • Better understanding. When using the React DevTools profiler I have a common problem – I see a component being rendered slowly but I don’t know what is causing it. In order to understand I need a more low-level view. Here are some questions that can be answered only with the Chrome Performance tab:
    • What’s the balance between the app’s code and React execution times? Should I implement some frequently updated components using custom non-React implementation?
    • What time is spend on setting attribute values, setting innerHTML and adding and removing listeners?
    • What time is spent on disposing effects? Is there a specific dispose function that is taking more than usual?
    • What time is spent on mounting effects? Is there a specific effect mount that is taking more than usual?

Disadvantages

As with every solution, there are some drawbacks to using this approach:

  • Documentation needed. In order to make sense of what’s happening you will need some knowledge of the core functions in React. A little guide with the names of the functions for mount/unmount, effects, and DOM manipulations will be useful. This of course can be done by the community(you are already linking to some community posts in React’s documentation).
  • Requires more skill. This isn’t for everybody. It’s aimed at more experienced developers. This type of profiling is a lot more overwhelming than the current approach.
  • May not fit your principles. Maybe it’s not part of your principles to introduce and promote such a complicated solution. Maybe you are more interested in searching for a more elegant and minimal solution.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
bvaughncommented, Nov 7, 2020

Discussing it seems fine!

3reactions
astoilkovcommented, Nov 7, 2020

No. These tools show the time spent in user code. This is because (a) a lot of energy has already been put into making React as fast as we can (given constraints) and (b) it’s more feasible for people to performance-tune their own components and not React anyway.

Thanks, makes sense.

What do you think about the source maps idea? Are you open to discussing and implementing it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Map Preprocessed Code to Source Code - Chrome Developers
Use Source Maps to map minified code to source code. You can then read and debug compiled code in its original source. Only...
Read more >
DevTools Debugging Tips And Shortcuts (Chrome, Firefox ...
In this article, Vitaly reviews useful features and shortcuts for debugging in Chrome, Firefox, Edge and Safari.
Read more >
Webpack Source Mapping for Debugging in Chrome
I'll show you how to quickly generate a source map with Webpack for easier debugging in Chrome. Let's get started! In Google Chrome...
Read more >
How do I attach a sourcemap to a node.js (V8) CPU profile ...
You can attach JS source maps when using chrome tools to debug JS on the page (sources tab). How can I attach my...
Read more >
Source Maps - SurviveJS
When your source code has gone through transformations, debugging in the browser becomes a problem. Source maps solve this problem by providing a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found