Closed
Description
#21641 adds the ability for DevTools to display hook "names". The way this works is:
- Run the component function to detect where all the hook calls are made (by inspecting the call stack).
- Load source files.
- Look for source maps and load them (if they exist).
- Parse source maps.
- Convert line/column number in compiled code to original source code.
- Parse original source code into AST (this is expensive).
- Extract names.
What if we had a custom transform that inferred these names during compilation and inserted metadata into the source map itself? Then DevTools could bail after step 4 and skip the expensive AST parsing step and the heuristics for inferring hook names.
It could still fall back to the more expensive step if this metadata wasn't available, but this would enable the feature to better support large apps where parsing the AST is prohibitively expensive.
See this comment below for a detailed explanation of how this might be implemented: #21782 (comment)