-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compiler): Support MetaProperty (#29752)
## Summary See #29737 ## How did you test this change? As the feature requires module support and the test runner does currently not support running tests as modules, I could only test it via playground.
- Loading branch information
Showing
17 changed files
with
202 additions
and
2 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
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
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
27 changes: 27 additions & 0 deletions
27
...r/src/__tests__/fixtures/compiler/error.todo-new-target-meta-property.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,27 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
import { Stringify } from "shared-runtime"; | ||
|
||
function foo() { | ||
const nt = new.target; | ||
return <Stringify value={nt} />; | ||
} | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
2 | | ||
3 | function foo() { | ||
> 4 | const nt = new.target; | ||
| ^^^^^^^^^^ Todo: (BuildHIR::lowerExpression) Handle MetaProperty expressions other than import.meta (4:4) | ||
5 | return <Stringify value={nt} />; | ||
6 | } | ||
7 | | ||
``` | ||
6 changes: 6 additions & 0 deletions
6
...gin-react-compiler/src/__tests__/fixtures/compiler/error.todo-new-target-meta-property.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,6 @@ | ||
import { Stringify } from "shared-runtime"; | ||
|
||
function foo() { | ||
const nt = new.target; | ||
return <Stringify value={nt} />; | ||
} |
67 changes: 67 additions & 0 deletions
67
...l-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-property.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,67 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function a() { | ||
return import.meta.url; | ||
} | ||
|
||
function b() { | ||
let a = 0; | ||
if (import.meta.url) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
function c() { | ||
let a = 0; | ||
if (import.meta.foo) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
function d() { | ||
let a = 0; | ||
if (import.meta) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
``` | ||
## Code | ||
```javascript | ||
function a() { | ||
return import.meta.url; | ||
} | ||
|
||
function b() { | ||
let a = 0; | ||
if (import.meta.url) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
function c() { | ||
let a = 0; | ||
if (import.meta.foo) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
function d() { | ||
let a = 0; | ||
if (import.meta) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
``` | ||
27 changes: 27 additions & 0 deletions
27
...er/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/meta-property.mjs
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,27 @@ | ||
function a() { | ||
return import.meta.url; | ||
} | ||
|
||
function b() { | ||
let a = 0; | ||
if (import.meta.url) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
function c() { | ||
let a = 0; | ||
if (import.meta.foo) { | ||
a = 1; | ||
} | ||
return a; | ||
} | ||
|
||
function d() { | ||
let a = 0; | ||
if (import.meta) { | ||
a = 1; | ||
} | ||
return a; | ||
} |
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