Commit Graph

19090 Commits

Author SHA1 Message Date
Lauren Tan
d439f279ff Add run prettier commit to .git-blame-ignore-revs
ghstack-source-id: a10c3b3d64
Pull Request resolved: https://github.com/facebook/react/pull/30391
2024-07-18 17:42:45 -04:00
Lauren Tan
abc0b712aa [ci] Fix sizebot job omitting build_and_lint dependency
ghstack-source-id: 3d457818c9
Pull Request resolved: https://github.com/facebook/react/pull/30392
2024-07-18 17:42:45 -04:00
Lauren Tan
3f4391d589 [ci] Only run sizebot on pull requests
Oops, forgot to port this bit over.

ghstack-source-id: 7fae8021d8
Pull Request resolved: https://github.com/facebook/react/pull/30390
2024-07-18 17:42:45 -04:00
Jan Kassens
fd2b3e13d3 Compiler: unfork prettier config (#30205)
Updates the prettier config to format all `.ts` and `.tsx` files in the
repo using the existing defaults and removing overrides.

The first commit in this PR contains the config changes, the second is
just the result of running `yarn prettier-all`.
2024-07-18 17:00:24 -04:00
Lauren Tan
6fac743ed7 [circleci] Inline scrape_warning_messages
This job was only being used for process_artifacts_combined in circleci
but as it was a separate job would incur the cost and time of spinning
up a new CI worker. We can simply inline this into
process_artifacts_combined.

Test plan: Download
[build.tgz](https://app.circleci.com/pipelines/github/facebook/react/57183/workflows/3b22a99e-b8a5-4c80-9682-576f24581b00/jobs/956476/artifacts)
from circleci and observe that the __test_utils__ directory is still
present.

ghstack-source-id: 8748d8fb9c
Pull Request resolved: https://github.com/facebook/react/pull/30388
2024-07-18 16:41:22 -04:00
Lauren Tan
7af570c3d9 [ci] Remove sizebot from circleci
Now that the job is migrated to GH, we can remove this from circleci.
Note that sizebot still comments on this PR.

ghstack-source-id: 337661e3b0
Pull Request resolved: https://github.com/facebook/react/pull/30387
2024-07-18 16:41:22 -04:00
Lauren Tan
4fb11acd79 [ci] Add sizebot to gh actions
Wires up sizebot in gh actions. I also fixed sizebot incorrectly
reporting that ReactAllWarnings was deleted.

ghstack-source-id: d3b1bb2088
Pull Request resolved: https://github.com/facebook/react/pull/30380
2024-07-18 16:41:22 -04:00
Lauren Tan
f6bc05a22a [ci] Add script to download artifact from github
Updates the forked script to download build artifacts from GitHub. Note
that this PR just adds the script, it does not add it to GH actions yet.

ghstack-source-id: 08b0d2f93a
Pull Request resolved: https://github.com/facebook/react/pull/30376
2024-07-18 16:41:21 -04:00
Lauren Tan
eed9ca203c [ci] Use yargs to parse args to download-experimental-build
ghstack-source-id: 0b222cf613
Pull Request resolved: https://github.com/facebook/react/pull/30375
2024-07-18 16:41:21 -04:00
Lauren Tan
21be03bfed [ci] Fork scripts/release/download-experimental-build.js
This PR just copies the original file without any modifications for
easier review.

The original script makes assumptions about CircleCI that are difficult
to untangle. So let's fork this file temporarily for GitHub actions.
Later on we will remove the original and rename this fork back to the
original naming.

ghstack-source-id: 0ce078538e
Pull Request resolved: https://github.com/facebook/react/pull/30374
2024-07-18 16:41:21 -04:00
Lauren Tan
76f8cf5277 [ci] Rename temporary build parts
Adds an _ prefix to temporary build parts from parallelization to allow
easier merging in later passes.

ghstack-source-id: 714da85972
Pull Request resolved: https://github.com/facebook/react/pull/30385
2024-07-18 16:41:20 -04:00
Mofei Zhang
b2ec0445b4 [compiler][patch] Don't wrap non-ascii fbt operands in JSXExpressionContainer
ghstack-source-id: 4b5505aa5e
Pull Request resolved: https://github.com/facebook/react/pull/30389
2024-07-18 16:18:36 -04:00
Mofei Zhang
378ab81522 [compiler][fixtures] Repro for fbt + non-ascii strings
ghstack-source-id: 0521198056
Pull Request resolved: https://github.com/facebook/react/pull/30386
2024-07-18 16:18:36 -04:00
Mofei Zhang
e15c5b15c6 [compiler][patch] Fix jsx non-ascii regex pattern
ghstack-source-id: 97ed491124
Pull Request resolved: https://github.com/facebook/react/pull/30382
2024-07-18 16:18:36 -04:00
Lauren Tan
512b09b24d [ci][ez] Rename artifact from process_artifacts_combined
Build artifacts are uniquely associated to a single workflow run, so
appending the sha was unnecessary. I originally included it to make it
easier to download later but this turns out to be unneeded.

Drops the sha suffix to make downloading the artifact in a separate
script / workflow more straightforward.

ghstack-source-id: 36ac4df4c3
Pull Request resolved: https://github.com/facebook/react/pull/30364
2024-07-18 11:53:05 -04:00
Joe Savona
163365a078 [compiler] Show outlined functions in logging, playground
ghstack-source-id: abda15e874
Pull Request resolved: https://github.com/facebook/react/pull/30344
2024-07-17 10:22:08 +09:00
Joe Savona
b810442c0e [compiler][be] Promote destructured params to temporaries
Addresses a follow-up from the previous PR. Destructured function params are currently not eagerly promoted to temporaries: we wait until PromotedUsedTemporaries. But params _always_ have to be named, so we can promote when constructing HIR.

ghstack-source-id: a6f665762e
Pull Request resolved: https://github.com/facebook/react/pull/30332
2024-07-17 10:22:08 +09:00
Joe Savona
9d7f02d9ab [compiler] General-purpose function outlining
Implements general-purpose function outlining. Specifically, anonymous function expressions which have no dependencies/context variables are extracted into named top-level functions. The original function expression is replaced with a `LoadGlobal` of the generated name.

Note that the architecture is designed to allow very general purpose forms of outlining, though we currently are very conservative in what we outline. Specifically, the outlining allows annotating functions with an optional ReactiveFunctionType, which if set will cause the outlined function to get compiled as that type. So we could for example outline a helper hook or helper component, set the type, and then have the hook/component get memoized as well. For now though we just outline with no type set, and generate the function as-is without running it through compilation.

ghstack-source-id: 2a7da6c8e8
Pull Request resolved: https://github.com/facebook/react/pull/30331
2024-07-17 10:22:08 +09:00
Joe Savona
a8c5e23e5e [compiler] Refactor Program to use queue of functions to compile
Refactors Program.ts to first traverse the `Program` node and build up a queue of functions to visit, then iterate that queue and compile the functions. This doesn't change behavior, but allows the next diff to add additional items to the queue during compilation (for function outlining).

ghstack-source-id: 858527c30c
Pull Request resolved: https://github.com/facebook/react/pull/30330
2024-07-17 10:22:08 +09:00
Joe Savona
ad08698d7f [compiler] Fixture for function outlining
Fixture demonstrating a case where we can "outline" a function expression.

ghstack-source-id: 836471518f
Pull Request resolved: https://github.com/facebook/react/pull/30329
2024-07-17 10:22:08 +09:00
Joe Savona
547c3c45ab [compiler] Store babel scope on Environment
Stores the Babel `Scope` object for the current function on the Environment, allowing access later for generating new globally unique names. The idea is to expose a small subset of the capabilities of the Scope API via Environment, so that the rest of the compiler remains decoupled from Babel. Ideally we'd use our own Scope implementation too, but we can punt on that for now since the parts we're using (global id generation) seem pretty reliable.

ghstack-source-id: 37f7113b11
Pull Request resolved: https://github.com/facebook/react/pull/30328
2024-07-17 10:22:08 +09:00
Niklas Mollenhauer
6c0386e976 fix(compiler): Align return types of ErrImp<E> and OkImpl<T> with Result<T, E> for TS 5.5 (#30345) 2024-07-16 19:51:11 -04:00
Lauren Tan
270222b191 [ci] Remove RELEASE_CHANNEL_stable_yarn_test_dom_fixtures from circleci
ghstack-source-id: 53489822aa
Pull Request resolved: https://github.com/facebook/react/pull/30359
2024-07-16 15:49:05 -04:00
Lauren Tan
243c0670ac [ci] Add RELEASE_CHANNEL_stable_yarn_test_dom_fixtures to gh actions
ghstack-source-id: 53a431f952
Pull Request resolved: https://github.com/facebook/react/pull/30358
2024-07-16 15:49:04 -04:00
Lauren Tan
34a788907b [ci] Remove run_fixtures_flight_tests from circleci
ghstack-source-id: f907271b95
Pull Request resolved: https://github.com/facebook/react/pull/30357
2024-07-16 15:49:04 -04:00
Lauren Tan
9a8f3de0a8 [ci] Add run_fixtures_flight_tests to gh actions
ghstack-source-id: 76761e302f
Pull Request resolved: https://github.com/facebook/react/pull/30356
2024-07-16 15:49:04 -04:00
Lauren Tan
16d3ca38cc [ci] Remove check_error_codes from circleci
ghstack-source-id: 3a587af04d
Pull Request resolved: https://github.com/facebook/react/pull/30355
2024-07-16 15:48:23 -04:00
Lauren Tan
43d535f545 [ci] Add check_error_codes to gh actions
ghstack-source-id: b6dbee275b
Pull Request resolved: https://github.com/facebook/react/pull/30354
2024-07-16 15:48:23 -04:00
Lauren Tan
c3c4ab31e4 [ci] Remove some circleci jobs
These are now in GH. Removes:

- yarn_lint_build
- yarn_test_build
- yarn_check_release_dependencies

ghstack-source-id: ab5c2b0250
Pull Request resolved: https://github.com/facebook/react/pull/30353
2024-07-16 15:48:23 -04:00
Lauren Tan
8d805ba2fd [ci] Remove DevTools jobs from circleci build_and_test
Now that these run in GH, we can remove these jobs from the circleci
build_and_test workflow to speed up the remaining jobs left in circleci
since this was the long pole.

I have left the definition of these jobs in tact however, as they are
used for devtools_regression_tests which has yet to be migrated to GH.

ghstack-source-id: 6f4ed3efa2
Pull Request resolved: https://github.com/facebook/react/pull/30352
2024-07-16 15:48:22 -04:00
Lauren Tan
080e36c973 [ez] Add gh actions status badges to readme
Update readme with new badges.

ghstack-source-id: 6111808cde
Pull Request resolved: https://github.com/facebook/react/pull/30350
2024-07-16 12:32:40 -04:00
Lauren Tan
b7c628042d [ci] Try sharding test_build
The tests for the build currently take about 3.5 minutes and is at the
moment the long pole for the whole workflow. By sharding we can make
this workflow faster and save about a minute or so in overall wall time.

ghstack-source-id: c23df7b6d7
Pull Request resolved: https://github.com/facebook/react/pull/30349
2024-07-16 12:32:39 -04:00
Lauren Tan
acd5355b40 [ci] Add DevTools jobs to gh actions
Adds the devtools build and test jobs to GH actions. This is more or
less a straight copy of the jobs from circleci

ghstack-source-id: f1071d754e
Pull Request resolved: https://github.com/facebook/react/pull/30347
2024-07-16 12:32:39 -04:00
Josh Story
0117239720 [Fiber] Ensure srcset and src are assigned last on img instances (#30340)
Safari has a behavior (bug) where when you consturct an Image in
javascript if you set srcset before properties for `sizes` the brwoser
will download the largest image size because it starts to load before
you communicate the sizes information.


https://x.com/OliverJAsh/status/1812408504444989588?t=CVHPqBaUiF5-6DBPGERTDA

There are likely other combinations or property order assignment that
can cause problems such as setting crossorigin after assigning src or
srcset. Conceptually we should withold the src and srcSet from the Image
instance until last so all relevant other properties can be assigned
before actually initiating any network activity.

This is an unforunate amount of code for what is realistically a bug in
Browsers but it should allow us to avoid weird regressions depending on
prop object order.

I didn't change the preload prop order because I don't believe preload
links have the same issue (they are not fetched as eagerly I believe).

One nice benefit of this change though is the img case can move higher
in the switch which is likely optimal given it's a relatively common
tag. Previously it was as low as it was because it was part of the void
element set so it couldn't be elevated without elevating less common
tags

---------

Co-authored-by: Jan Kassens <jan@kassens.net>
2024-07-16 08:25:24 -07:00
Joe Savona
fee423e083 [compiler] Handle earlier creation of early return on scopes
I'm experimenting with a new pass that sometimes creates scopes with early returns earlier in the pipeline, but there are a few passes that assume that can't happen. This PR is updating those passes just to be more resilient to help unblock experimentation.

ghstack-source-id: a9e348181d
Pull Request resolved: https://github.com/facebook/react/pull/30333
2024-07-16 13:28:19 +09:00
Joe Savona
2683c0a18c [compiler] Fix mode for generating scopes for reassignments
We have an experimental mode where we generate scopes for simple phi values, even if they aren't subsequently mutated. This mode was incorrectly generating scope ranges, leaving the start at 0 which is invalid. The fix is to allow non-zero identifier ranges to overwrite the scope start (rather than taking the min) if the scope start is still zero.

ghstack-source-id: ecbb04c96e
Pull Request resolved: https://github.com/facebook/react/pull/30321
2024-07-16 13:27:22 +09:00
Mofei Zhang
1f60a41801 [compiler][eslint] Add donotuse flag for bailouts
---
Adding an experimental / donotuse flag for small Meta internal usecase

ghstack-source-id: 908ef1e150
Pull Request resolved: https://github.com/facebook/react/pull/30342
2024-07-15 17:56:04 -04:00
Mofei Zhang
735d3d2baa [compiler][ez] Upgrade babel generator version for playground
---
The current version of `@babel/generator` used by playground has some bugs (see https://github.com/babel/babel/issues/10966)
```js
// Try pasting this into playground
function useFoo(a, b) {
  return (a ?? b) == c;
}

// Current playground output
function useFoo(a, b) {
  return a ?? b == c;
}
```

We previously locked babel library versions to be compatible with the oldest Meta internal usages. Now that both compiler and eslint plugins are bundled with rollup, this shouldn't be necessary.

ghstack-source-id: fa20d676b5
Pull Request resolved: https://github.com/facebook/react/pull/30341
2024-07-15 17:56:04 -04:00
Mofei Zhang
e307a49544 [compiler][eslint] Use logger callback instead of exceptions to report eslint diagnostics
---
* panicThreshold: `all_errors` -> `none`
* inject an error logger through compiler config (instead of using exceptions)

We currently report at most one lint warning per file, this lets us exhaustively report all available ones (see new
test fixture for example)

ghstack-source-id: 5299315574
Pull Request resolved: https://github.com/facebook/react/pull/30336
2024-07-15 17:56:04 -04:00
Mofei Zhang
6cca9c3184 [compiler][be] Fix lint violations in eslint-plugin
ghstack-source-id: 7c11dce833
Pull Request resolved: https://github.com/facebook/react/pull/30335
2024-07-15 17:56:04 -04:00
Jan Kassens
1d5a208fda [native-fb] set disableDefaultPropsExceptForClasses flag to true (#30339)
Reflecting D59402048
2024-07-15 14:20:40 -04:00
Dmytro Rykun
f510ece86d Fix fastAddProperties to properly nullify style props (#30334)
## Summary

This PR fixes the `fastAddProperties` function. Now it nullifies a prop
if it was defined in one of the items of a style array, but then set to
`undefined` or `null` in one of the subsequent items. E.g. `style:
[{top: 0}, {top: undefined}]` should evaluate to `{top: null}`. Also
added a test case for that.

## How did you test this change?
```
yarn test packages/react-native-renderer -r=xplat --variant=false
yarn test packages/react-native-renderer -r=xplat --variant=true
yarn flow native
```
2024-07-15 17:32:04 +01:00
Jan Kassens
fc1371f6bf [native-fb] set consoleManagedByDevToolsDuringStrictMode flag to true (#30338)
Reflecting D59232098.
2024-07-15 12:31:17 -04:00
Sebastian Markbåge
8b08e99efa [Flight] Encode the name of a function as an object property (#30325)
Unfortunately, Firefox doesn't include the name of a function in stack
traces if you set it as either `.name` or `.displayName` at runtime.
Only if you include it declarative.

We also can't include it into a named function expression because not
all possible names are expressible declaratively. E.g. spaces or
punctuations.

However, we can express any name if it's an object property and since
object properties now give their name declarative to the function
defined inside of them, we can declaratively express any name this way.
2024-07-13 16:33:48 -04:00
Josh Story
79e4f23808 [Fizz] correctly track header length (#30327)
The interstital characters in our link header tracking are not
contributing to the remaining capacity calculation so when a lot of
inditidual links are present in the link header it can allow an
overflowing link header to be included. This change corrects the math so
it properly prevents overflow.
2024-07-13 07:24:43 -07:00
Jelle Voost
c5eca9b082 Fixed useSyncExternalStoreWithSelector to update memoizedSnapshot on change (#25968)
## Summary

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->

A proposed fix for the bug described in
https://github.com/facebook/react/issues/25967

## How did you test this change?

See the issue linked above, test scenario included in the code sandbox:
https://codesandbox.io/s/fervent-ives-0vm9es?file=/src/App.jsx

<!--
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.
-->
2024-07-12 23:57:45 -04:00
Sebastian Markbåge
127a0fbf1a Add build-for-flight-dev script to package.json (#30326)
Similar to the build-for-devtools script. I often have to build locally
for the flight fixture. This builds a subset that makes it work (in
DEV).
2024-07-12 18:03:10 -04:00
Sebastian Markbåge
ff89ba7346 Disable consoleWithStackDev Transform except in RN/WWW (#30313)
Stacked on #30308.

This is now a noop module so we can stop applying the transform of
console.error using the Babel plugin in the mainline builds. I'm keeping
the transform for RN/WWW for now although it might be nice if the
transform moved into those systems as it gets synced instead of keeping
it upstream.

In jest tests we're already not running the forks for RN/WWW so we don't
need it at all there.
2024-07-12 14:39:38 -04:00
Sebastian Markbåge
400e822277 Remove Component Stack from React Logged Warnings and Error Reporting (#30308)
React transpiles some of its own `console.error` calls into a helper
that appends component stacks to those calls. However, this doesn't
cover user space `console.error` calls - which includes React helpers
that React has moved into third parties like createClass and prop-types.

The idea is that any user space component can add a warning just like
React can which is why React DevTools adds them too if they don't
already exist. Having them appended in both places is tricky because now
you have to know whether to remove them from React's logs.

Similarly it's often common for server-side frameworks to forget to
cover the `console.error` logs from other sources since React DevTools
isn't active there. However, it's also annoying to get component stacks
clogging the terminal - depending on where the log came from.

In the future `console.createTask()` will cover this use case natively
and when available we don't append them at all.

The new strategy relies on either:

- React DevTools existing to add them to React logs as well as third
parties.
- `console.createTask` being supported and surfaced.
- A third party framework showing the component stack either in an Error
Dialog or appended to terminal output.

For a third party to be able to implement this they need to be able to
get the component stack. To get the component stack from within a
`console.error` call you need to use the `React.captureOwnerStack()`
helper which is only available in `enableOwnerStacks` flag. However,
it's possible to polyfill with parent stacks using internals as a stop
gap. There's a question of whether React 19 should just go out with
`enableOwnerStacks` to expose this but regardless I think it's best it
doesn't include component stacks from the runtime for consistency.

In practice it's not really a regression though because typically either
of the other options exists and error dialogs don't implement
`console.error` overrides anyway yet. SSR terminals might miss them but
they'd only have them in DEV warnings to begin with an a subset of React
warnings. Typically those are either going to happen on the client
anyway or replayed.

Our tests are written to assert that component stacks work in various
scenarios all over the place. To ensure that this keeps working I
implement a "polyfill" that is similar to that expected a server
framework might do - in `assertConsoleErrorDev` and `toErrorDev`.

This PR doesn't yet change www or RN since they have their own forks of
consoleWithStackDev for now.
2024-07-12 13:02:22 -04:00
Lauren Tan
1e8efe7fd4 [ci] Combine Runtime workflows
Merges most workflows into a single workflow, which should make the
"Checks" tab easier to visualize sincee it will all be graphed in a
single interface. There should be no change in behavior, this is a
mechanical change.

ghstack-source-id: a5241a2420
Pull Request resolved: https://github.com/facebook/react/pull/30324
2024-07-12 12:53:06 -04:00