-
Notifications
You must be signed in to change notification settings - Fork 47.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler][rfc] Simple retry for fire
Start of a simple retry pipeline. Would love feedback on how we implement this to be extensible to other compiler non-memoization features (e.g. inlineJSX)
- Loading branch information
Showing
21 changed files
with
617 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...res/compiler/transform-fire/bailout-retry/bailout-capitalized-fn-call.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @validateNoCapitalizedCalls @enableFire | ||
import {fire} from 'react'; | ||
const CapitalizedCall = require('shared-runtime').sum; | ||
|
||
function Component({prop1, bar}) { | ||
const foo = () => { | ||
console.log(prop1); | ||
}; | ||
useEffect(() => { | ||
fire(foo(prop1)); | ||
fire(foo()); | ||
fire(bar()); | ||
}); | ||
|
||
return CapitalizedCall(); | ||
} | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { useFire } from "react/compiler-runtime"; // @validateNoCapitalizedCalls @enableFire | ||
import { fire } from "react"; | ||
const CapitalizedCall = require("shared-runtime").sum; | ||
|
||
function Component(t0) { | ||
const { prop1, bar } = t0; | ||
const foo = () => { | ||
console.log(prop1); | ||
}; | ||
const t1 = useFire(foo); | ||
const t2 = useFire(bar); | ||
|
||
useEffect(() => { | ||
t1(prop1); | ||
t1(); | ||
t2(); | ||
}); | ||
return CapitalizedCall(); | ||
} | ||
|
||
``` | ||
### Eval output | ||
(kind: exception) Fixture not implemented |
16 changes: 16 additions & 0 deletions
16
...c/__tests__/fixtures/compiler/transform-fire/bailout-retry/bailout-capitalized-fn-call.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @validateNoCapitalizedCalls @enableFire | ||
import {fire} from 'react'; | ||
const CapitalizedCall = require('shared-runtime').sum; | ||
|
||
function Component({prop1, bar}) { | ||
const foo = () => { | ||
console.log(prop1); | ||
}; | ||
useEffect(() => { | ||
fire(foo(prop1)); | ||
fire(foo()); | ||
fire(bar()); | ||
}); | ||
|
||
return CapitalizedCall(); | ||
} |
55 changes: 55 additions & 0 deletions
55
...res/compiler/transform-fire/bailout-retry/bailout-eslint-suppressions.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @enableFire | ||
import {useRef} from 'react'; | ||
|
||
function Component({props, bar}) { | ||
const foo = () => { | ||
console.log(props); | ||
}; | ||
useEffect(() => { | ||
fire(foo(props)); | ||
fire(foo()); | ||
fire(bar()); | ||
}); | ||
|
||
const ref = useRef(null); | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
ref.current = 'bad'; | ||
return <button ref={ref} />; | ||
} | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { useFire } from "react/compiler-runtime"; // @enableFire | ||
import { useRef } from "react"; | ||
|
||
function Component(t0) { | ||
const { props, bar } = t0; | ||
const foo = () => { | ||
console.log(props); | ||
}; | ||
const t1 = useFire(foo); | ||
const t2 = useFire(bar); | ||
|
||
useEffect(() => { | ||
t1(props); | ||
t1(); | ||
t2(); | ||
}); | ||
|
||
const ref = useRef(null); | ||
|
||
ref.current = "bad"; | ||
return <button ref={ref} />; | ||
} | ||
|
||
``` | ||
### Eval output | ||
(kind: exception) Fixture not implemented |
18 changes: 18 additions & 0 deletions
18
...c/__tests__/fixtures/compiler/transform-fire/bailout-retry/bailout-eslint-suppressions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// @enableFire | ||
import {useRef} from 'react'; | ||
|
||
function Component({props, bar}) { | ||
const foo = () => { | ||
console.log(props); | ||
}; | ||
useEffect(() => { | ||
fire(foo(props)); | ||
fire(foo()); | ||
fire(bar()); | ||
}); | ||
|
||
const ref = useRef(null); | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
ref.current = 'bad'; | ||
return <button ref={ref} />; | ||
} |
Oops, something went wrong.