Skip to content

Improve hook names performance with extended source maps #21782

Closed
@bvaughn

Description

@bvaughn

#21641 adds the ability for DevTools to display hook "names". The way this works is:

  1. Run the component function to detect where all the hook calls are made (by inspecting the call stack).
  2. Load source files.
  3. Look for source maps and load them (if they exist).
  4. Parse source maps.
  5. Convert line/column number in compiled code to original source code.
  6. Parse original source code into AST (this is expensive).
  7. 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)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions