Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ compiler/**/.next

# contains invalid graphql`...` which results in a promise rejection error from `yarn prettier-all`.
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-kitchensink.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-kitchensink.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-inside-logical-expression.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/optional-call-logical.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/tagged-template-in-hook.js
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/tagged-template-literal.js

compiler/crates
compiler/apps/playground/public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ function useFragment(_arg1, _arg2) {
}

function Component(props) {
const post = useFragment(graphql`...`, props.post);
const post = useFragment(
graphql`
fragment F on T {
id
}
`,
props.post
);
const allUrls = [];
// `media` and `urls` are exported from the scope that will wrap this code,
// but `comments` is not (it doesn't need to be memoized, bc the callback
Expand Down Expand Up @@ -59,7 +66,11 @@ function Component(props) {
const $ = _c(9);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = graphql`...`;
t0 = graphql`
fragment F on T {
id
}
`;
$[0] = t0;
} else {
t0 = $[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ function useFragment(_arg1, _arg2) {
}

function Component(props) {
const post = useFragment(graphql`...`, props.post);
const post = useFragment(
graphql`
fragment F on T {
id
}
`,
props.post
);
const allUrls = [];
// `media` and `urls` are exported from the scope that will wrap this code,
// but `comments` is not (it doesn't need to be memoized, bc the callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

```javascript
function Component(props) {
const post = useFragment(graphql`...`, props.post);
const post = useFragment(
graphql`
fragment F on T {
id
}
`,
props.post
);
const allUrls = [];
// `media` and `urls` are exported from the scope that will wrap this code,
// but `comments` is not (it doesn't need to be memoized, bc the callback
Expand Down Expand Up @@ -31,7 +38,14 @@ function Component(props) {
import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(4);
const post = useFragment(graphql`...`, props.post);
const post = useFragment(
graphql`
fragment F on T {
id
}
`,
props.post,
);
let t0;
if ($[0] !== post) {
const allUrls = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
function Component(props) {
const post = useFragment(graphql`...`, props.post);
const post = useFragment(
graphql`
fragment F on T {
id
}
`,
props.post
);
const allUrls = [];
// `media` and `urls` are exported from the scope that will wrap this code,
// but `comments` is not (it doesn't need to be memoized, bc the callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

```javascript
function Component(props) {
const user = useFragment(graphql`...`, props.user) ?? {};
const user =
useFragment(
graphql`
fragment F on T {
id
}
`,
props.user
) ?? {};
return user.name;
}

Expand All @@ -13,7 +21,15 @@ function Component(props) {

```javascript
function Component(props) {
const user = useFragment(graphql`...`, props.user) ?? {};
const user =
useFragment(
graphql`
fragment F on T {
id
}
`,
props.user,
) ?? {};
return user.name;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
function Component(props) {
const user = useFragment(graphql`...`, props.user) ?? {};
const user =
useFragment(
graphql`
fragment F on T {
id
}
`,
props.user
) ?? {};
return user.name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

```javascript
function Component(props) {
const item = useFragment(graphql`...`, props.item);
const item = useFragment(
graphql`
fragment F on T {
id
}
`,
props.item
);
return item.items?.map(item => renderItem(item)) ?? [];
}

Expand All @@ -15,7 +22,14 @@ function Component(props) {
import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(2);
const item = useFragment(graphql`...`, props.item);
const item = useFragment(
graphql`
fragment F on T {
id
}
`,
props.item,
);
let t0;
if ($[0] !== item.items) {
t0 = item.items?.map(_temp) ?? [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function Component(props) {
const item = useFragment(graphql`...`, props.item);
const item = useFragment(
graphql`
fragment F on T {
id
}
`,
props.item
);
return item.items?.map(item => renderItem(item)) ?? [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
function Component(props) {
const x = makeObject();
const user = useFragment(
graphql`fragment Component_user on User { ... }`,
graphql`
fragment Component_user on User {
name
}
`,
props.user
);
const posts = user.timeline.posts.edges.nodes.map(node => {
Expand All @@ -28,7 +32,11 @@ function Component(props) {
const $ = _c(3);
const x = makeObject();
const user = useFragment(
graphql`fragment Component_user on User { ... }`,
graphql`
fragment Component_user on User {
name
}
`,
props.user,
);
const posts = user.timeline.posts.edges.nodes.map((node) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
function Component(props) {
const x = makeObject();
const user = useFragment(
graphql`fragment Component_user on User { ... }`,
graphql`
fragment Component_user on User {
name
}
`,
props.user
);
const posts = user.timeline.posts.edges.nodes.map(node => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
```javascript
function Component(props) {
const user = useFragment(
graphql`fragment Component_user on User { ... }`,
graphql`
fragment Component_user on User {
name
}
`,
props.user
);
const posts = user.timeline.posts.edges.nodes.map(node => (
Expand All @@ -25,7 +29,11 @@ import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(5);
const user = useFragment(
graphql`fragment Component_user on User { ... }`,
graphql`
fragment Component_user on User {
name
}
`,
props.user,
);
let posts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
function Component(props) {
const user = useFragment(
graphql`fragment Component_user on User { ... }`,
graphql`
fragment Component_user on User {
name
}
`,
props.user
);
const posts = user.timeline.posts.edges.nodes.map(node => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

```javascript
function Component(props) {
const user = useFragment(graphql`fragment on User { name }`, props.user);
const user = useFragment(
graphql`
fragment F on User {
name
}
`,
props.user
);
return user.name;
}

Expand All @@ -13,7 +20,14 @@ function Component(props) {

```javascript
function Component(props) {
const user = useFragment(graphql`fragment on User { name }`, props.user);
const user = useFragment(
graphql`
fragment F on User {
name
}
`,
props.user,
);
return user.name;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function Component(props) {
const user = useFragment(graphql`fragment on User { name }`, props.user);
const user = useFragment(
graphql`
fragment F on User {
name
}
`,
props.user
);
return user.name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@
```javascript
function component() {
let t = graphql`
fragment List_viewer on Viewer
@argumentDefinitions(
count: {
type: "Int"
defaultValue: 10
directives: ["@int_max_value(logged_in: 10)"]
}
cursor: { type: "ID" }
)

fragment F on T {
id
}
`;

return t;
Expand All @@ -30,17 +23,10 @@ function component() {
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = graphql`
fragment List_viewer on Viewer
@argumentDefinitions(
count: {
type: "Int"
defaultValue: 10
directives: ["@int_max_value(logged_in: 10)"]
fragment F on T {
id
}
cursor: { type: "ID" }
)

`;
`;
$[0] = t0;
} else {
t0 = $[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
function component() {
let t = graphql`
fragment List_viewer on Viewer
@argumentDefinitions(
count: {
type: "Int"
defaultValue: 10
directives: ["@int_max_value(logged_in: 10)"]
}
cursor: { type: "ID" }
)

fragment F on T {
id
}
`;

return t;
Expand Down