mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Compiler playground] bold changed passes (#29159)
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> In the playground, it's hard to see at a glance what compiler passes are involved in introducing changes. This PR bolds every pass that introduces a change. ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> Before: <img width="1728" alt="image" src="https://github.com/facebook/react/assets/5144292/803ca786-0726-4456-b0db-520dc90a6771"> After: <img width="1728" alt="image" src="https://github.com/facebook/react/assets/5144292/38885644-00e9-4065-9c44-db533000d13a">
This commit is contained in:
@@ -187,6 +187,21 @@ function Output({ store, compilerOutput }: Props) {
|
||||
});
|
||||
}, [store.source, compilerOutput]);
|
||||
|
||||
const changedPasses: Set<string> = new Set();
|
||||
let lastResult: string = "";
|
||||
for (const [passName, results] of compilerOutput.results) {
|
||||
for (const result of results) {
|
||||
let currResult = "";
|
||||
if (result.kind === "hir" || result.kind === "reactive") {
|
||||
currResult += `function ${result.fnName}\n\n${result.value}`;
|
||||
}
|
||||
if (currResult !== lastResult) {
|
||||
changedPasses.add(passName);
|
||||
}
|
||||
lastResult = currResult;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<TabbedWindow
|
||||
@@ -194,6 +209,7 @@ function Output({ store, compilerOutput }: Props) {
|
||||
setTabsOpen={setTabsOpen}
|
||||
tabsOpen={tabsOpen}
|
||||
tabs={tabs}
|
||||
changedPasses={changedPasses}
|
||||
/>
|
||||
{compilerOutput.kind === "err" ? (
|
||||
<div
|
||||
|
||||
@@ -15,6 +15,7 @@ export default function TabbedWindow(props: {
|
||||
tabs: TabsRecord;
|
||||
tabsOpen: Set<string>;
|
||||
setTabsOpen: (newTab: Set<string>) => void;
|
||||
changedPasses: Set<string>;
|
||||
}): React.ReactElement {
|
||||
if (props.tabs.size === 0) {
|
||||
return (
|
||||
@@ -36,6 +37,7 @@ export default function TabbedWindow(props: {
|
||||
tabs={props.tabs}
|
||||
tabsOpen={props.tabsOpen}
|
||||
setTabsOpen={props.setTabsOpen}
|
||||
hasChanged={props.changedPasses.has(name)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -48,11 +50,13 @@ function TabbedWindowItem({
|
||||
tabs,
|
||||
tabsOpen,
|
||||
setTabsOpen,
|
||||
hasChanged,
|
||||
}: {
|
||||
name: string;
|
||||
tabs: TabsRecord;
|
||||
tabsOpen: Set<string>;
|
||||
setTabsOpen: (newTab: Set<string>) => void;
|
||||
hasChanged: boolean;
|
||||
}): React.ReactElement {
|
||||
const isShow = tabsOpen.has(name);
|
||||
|
||||
@@ -74,7 +78,7 @@ function TabbedWindowItem({
|
||||
title="Minimize tab"
|
||||
aria-label="Minimize tab"
|
||||
onClick={toggleTabs}
|
||||
className="p-4 duration-150 ease-in border-b cursor-pointer border-grey-200 font-medium text-secondary hover:text-link"
|
||||
className={`p-4 duration-150 ease-in border-b cursor-pointer border-grey-200 ${hasChanged ? 'font-bold' : 'font-light'} text-secondary hover:text-link`}
|
||||
>
|
||||
- {name}
|
||||
</h2>
|
||||
@@ -87,7 +91,7 @@ function TabbedWindowItem({
|
||||
aria-label={`Expand compiler tab: ${name}`}
|
||||
style={{ transform: "rotate(90deg) translate(-50%)" }}
|
||||
onClick={toggleTabs}
|
||||
className="flex-grow-0 w-5 transition-colors duration-150 ease-in font-medium text-secondary hover:text-link"
|
||||
className={`flex-grow-0 w-5 transition-colors duration-150 ease-in ${hasChanged ? 'font-bold' : 'font-light'} text-secondary hover:text-link`}
|
||||
>
|
||||
{name}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user