oxc-project / oxc-project/backlog
Cache scope tree lookups for React JSX classic mode transform
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
React JSX transform in classic mode currently performs a scope lookup on every JSX node, to find the binding React in React.createElement expressions which transform creates.
In classic mode, the binding for React can be anywhere, so we have to perform scope lookup every time to ensure correct scopes tree for weird cases like this:
export function generateHelloComponent(React) {
return function Hello() {
return <div>Greetings!</div>;
};
}
export function generateGoodbyeComponent(React) {
return function Goodbye() {
return <div>Adios!</div>;
};
}
However, this is of course a very uncommon case. 99% of the time React is bound to import React from 'react'; in top level scope.
Scope tree lookups are fairly expensive. While traversing the AST, we should cache scope tree lookups to optimize for the common case.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the React JSX classic-mode transform and trace the AST traversal where it resolves the React binding through the scope tree. Compare the common top-level binding case with the nested function-parameter examples in the issue, and consider the work complete when repeated lookups are cached without changing either transformation behavior or scope correctness.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100