-
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
25 changed files
with
758 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
43 changes: 43 additions & 0 deletions
43
...ugin-react-compiler/src/__tests__/fixtures/compiler/error.insert-fire.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,43 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @enableFire | ||
import {fire} from 'react'; | ||
|
||
function Component({props, bar}) { | ||
const foo = () => { | ||
console.log(props); | ||
}; | ||
useEffect(() => { | ||
fire(foo(props), bar); | ||
fire(...foo); | ||
fire(bar); | ||
fire(props.foo()); | ||
}); | ||
|
||
return null; | ||
} | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
7 | }; | ||
8 | useEffect(() => { | ||
> 9 | fire(foo(props), bar); | ||
| ^^^^^^^^^^^^^^^^^^^^^ InvalidReact: Cannot compile `fire`. fire() can only take in a single call expression as an argument but received multiple arguments (9:9) | ||
InvalidReact: Cannot compile `fire`. fire() can only take in a single call expression as an argument but received a spread argument (10:10) | ||
InvalidReact: Cannot compile `fire`. `fire()` can only receive a function call such as `fire(fn(a,b)). Method calls and other expressions are not allowed (11:11) | ||
InvalidReact: Cannot compile `fire`. `fire()` can only receive a function call such as `fire(fn(a,b)). Method calls and other expressions are not allowed (12:12) | ||
10 | fire(...foo); | ||
11 | fire(bar); | ||
12 | fire(props.foo()); | ||
``` | ||
16 changes: 16 additions & 0 deletions
16
...packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.insert-fire.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 @@ | ||
// @enableFire | ||
import {fire} from 'react'; | ||
|
||
function Component({props, bar}) { | ||
const foo = () => { | ||
console.log(props); | ||
}; | ||
useEffect(() => { | ||
fire(foo(props), bar); | ||
fire(...foo); | ||
fire(bar); | ||
fire(props.foo()); | ||
}); | ||
|
||
return null; | ||
} |
50 changes: 50 additions & 0 deletions
50
...ts__/fixtures/compiler/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
...ompiler/src/__tests__/fixtures/compiler/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(); | ||
} |
Oops, something went wrong.