Commit Graph

549 Commits

Author SHA1 Message Date
Sebastian Silbermann 149b420f63
Ensure devtools e2e test use a compatible react-is version (#22790)
* Update lockfile by running `yarn install`

* Ensure devtools e2e test use a compatible react-is version
2021-11-19 10:18:02 -05:00
Brian Vaughn aa19d569b2
Add test selectors to experimental build (#22760)
This change adds a new "react-dom/unstable_testing" entry point but I believe its contents will exactly match "react-dom/index" for the stable build. (The experimental build will have the added new selector APIs.)
2021-11-16 16:27:10 -05:00
irinakk ff9897d23e
[React Refresh] support typescript namespace syntax (#22621)
* [React Refresh] support typescript namespace syntax

* [React Refresh] handle nested namespace

Co-authored-by: Wang Yilin <wang_yil@worksap.co.jp>
2021-11-09 20:22:19 +00:00
Andrew Clark 7034408ff7
Follow-up improvements to error code extraction infra (#22516)
* Output FIXME during build for unminified errors

The invariant Babel transform used to output a FIXME comment if it
could not find a matching error code. This could happen if there were
a configuration mistake that caused an unminified message to
slip through.

Linting the compiled bundles is the most reliable way to do it because
there's not a one-to-one mapping between source modules and bundles. For
example, the same source module may appear in multiple bundles, some
which are minified and others which aren't.

This updates the transform to output the same messages for Error calls.

The source lint rule is still useful for catching mistakes during
development, to prompt you to update the error codes map before pushing
the PR to CI.

* Don't run error transform in development

We used to run the error transform in both production and development,
because in development it was used to convert `invariant` calls into
throw statements.

Now that don't use `invariant` anymore, we only have to run the
transform for production builds.

* Add ! to FIXME comment so Closure doesn't strip it

Don't love this solution because Closure could change this heuristic,
or we could switch to a differnt compiler that doesn't support it. But
it works.

Could add a bundle that contains an unminified error solely for the
purpose of testing it, but that seems like overkill.

* Alternate extract-errors that scrapes artifacts

The build script outputs a special FIXME comment when it fails to minify
an error message. CI will detect these comments and fail the workflow.

The comments also include the expected error message. So I added an
alternate extract-errors that scrapes unminified messages from the
build artifacts and updates `codes.json`.

This is nice because it works on partial builds. And you can also run it
after the fact, instead of needing build all over again.

* Disable error minification in more bundles

Not worth it because the number of errors does not outweight the size
of the formatProdErrorMessage runtime.

* Run extract-errors script in CI

The lint_build job already checks for unminified errors, but the output
isn't super helpful.

Instead I've added a new job that runs the extract-errors script and
fails the build if `codes.json` changes. It also outputs the expected
diff so you can easily see which messages were missing from the map.

* Replace old extract-errors script with new one

Deletes the old extract-errors in favor of extract-errors2
2021-10-31 15:37:32 -07:00
Andrew Clark 7d38e4fd89
CodeSandbox CI: Fall back to local build (#22473)
The `download-experimental-build` script has been flaky on CodeSandbox
CI, I think because of GitHub rate limiting.

Until we figure out how to fix that, I've updated it to fall back to a
local build.
2021-09-30 08:12:25 -07:00
Sebastian Markbåge eba248c390
[Fizz/Flight] Remove reentrancy hack (#22446)
* Remove reentrant check from Fizz/Flight

* Make startFlowing explicit in Flight

This is already an explicit call in Fizz. This moves flowing to be explicit.

That way we can avoid calling it in start() for web streams and therefore
avoid the reentrant call.

* Add regression test

This test doesn't actually error due to the streams polyfill not behaving
like Chrome but rather according to spec.

* Update the Web Streams polyfill

Not that we need this but just in case there are differences that are fixed.
2021-09-27 17:47:56 -07:00
Brian Vaughn a01cdbf813
Update Yarn build-for-devtools script to account for build/build2 changes (#22418) 2021-09-24 10:54:57 -04:00
Andrew Clark 95502f7b25
Update CodeSandbox to pull build artifacts from CI (#22400)
Instead of building them from source.

The `download-experimental-build` script polls CI until the build
has finished.
2021-09-22 11:35:56 -07:00
Andrew Clark bb0d069359
[build2 -> build] Local scripts
Update all our local scripts to use `build` instead of `build2`.

There are still downstream scripts that depend on `build2`, though, so
we can't remove it yet.
2021-09-21 15:14:09 -04:00
Michaël De Boey 0c0d1ddae4
feat(eslint-plugin-react-hooks): support ESLint 8.x (#22248) 2021-09-06 20:17:51 +01:00
Brian Vaughn b5fbf5464b
Automated DevTools release process (#22161) 2021-08-24 14:05:50 -04:00
Brian Vaughn 07e58658c9
Add script to generate DevTools changelog text (#22077) 2021-08-12 10:43:56 -04:00
Brian Vaughn c5cfa71948
DevTools: Show hook names based on variable usage (#21641)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
Co-authored-by: Saphal Patro <saphal1998@gmail.com>
Co-authored-by: VibhorCodecianGupta <vibhordelgupta@gmail.com>
2021-07-01 14:39:18 -04:00
Sebastian Silbermann 3c2341416a
Update jest to v26 (#21574)
* Install jest 26

* jsdom env now uses 16 by default

* require.requireActual -> jest.requireActual

* deduplicate added deps
2021-05-27 16:33:57 +01:00
Sebastian Silbermann 4edbcdc327
Update supported devEngines (#21364) 2021-04-27 12:03:25 -04:00
Brian Vaughn d778518998
Update build-for-devtools script to prepare unit tests too (#21182) 2021-04-06 09:24:33 -04:00
Sebastian Markbåge cf485e6f6b
[Fizz] Expose a method to abort a pending request (#21027)
* Track all suspended work while it's still pending

This allows us to abort work and put everything into client rendered mode
if we don't want to wait for further I/O.

It also allows us to cancel fallbacks if we complete the main content
before the fallback.

* Expose abort API to the browser streams

Since this API already returns a value, we need to use destructuring to
expose more options.

* Add a test including the client actually client rendering it

* Use AbortSignal option for W3C streams instead of external control

* Clean up listener after it's used once
2021-03-18 09:46:15 -07:00
Brian Vaughn 533aed8de6
Speed up DevTools local build script (#21018) 2021-03-16 14:02:24 -04:00
Andrew Clark c1cfa734fd
Add command to publish preleases via CI (#20728)
```
yarn publish-prereleases
```

Script to trigger a CircleCI workflow that publishes preleases.

**The CI workflow doesn't actually publish yet; it just runs and logs
its inputs.**
2021-02-03 15:42:34 -08:00
Brian Vaughn af16f755dc
Update DevTools to use getCacheForType API (#20548)
DevTools was built with a fork of an early idea for how Suspense cache might work. This idea is incompatible with newer APIs like `useTransition` which unfortunately prevented me from making certain UX improvements. This PR swaps out the primary usage of this cache (there are a few) in favor of the newer `unstable_getCacheForType` and `unstable_useCacheRefresh` APIs. We can go back and update the others in follow up PRs.

### Messaging changes

I've refactored the way the frontend loads component props/state/etc to hopefully make it better match the Suspense+cache model. Doing this gave up some of the small optimizations I'd added but hopefully the actual performance impact of that is minor and the overall ergonomic improvements of working with the cache API make this worth it.

The backend no longer remembers inspected paths. Instead, the frontend sends them every time and the backend sends a response with those paths. I've also added a new "force" parameter that the frontend can use to tell the backend to send a response even if the component hasn't rendered since the last time it asked. (This is used to get data for newly inspected paths.)

_Initial inspection..._
```
front |                                                      | back
      | -- "inspect" (id:1, paths:[], force:true) ---------> |
      | <------------------------ "inspected" (full-data) -- |
```
_1 second passes with no updates..._
```
      | -- "inspect" (id:1, paths:[], force:false) --------> |
      | <------------------------ "inspected" (no-change) -- |
```
_User clicks to expand a path, aka hydrate..._
```
      | -- "inspect" (id:1, paths:['foo'], force:true) ----> |
      | <------------------------ "inspected" (full-data) -- |
```
_1 second passes during which there is an update..._
```
      | -- "inspect" (id:1, paths:['foo'], force:false) ---> |
      | <----------------- "inspectedElement" (full-data) -- |
```

### Clear errors/warnings transition
Previously this meant there would be a delay after clicking the "clear" button. The UX after this change is much improved.

### Hydrating paths transition
I also added a transition to hydration (expanding "dehyrated" paths).

### Better error boundaries
I also added a lower-level error boundary in case the new suspense operation ever failed. It provides a better "retry" mechanism (select a new element) so DevTools doesn't become entirely useful. Here I'm intentionally causing an error every time I select an element.

### Improved snapshot tests
I also migrated several of the existing snapshot tests to use inline snapshots and added a new serializer for dehydrated props. Inline snapshots are easier to verify and maintain and the new serializer means dehydrated props will be formatted in a way that makes sense rather than being empty (in external snapshots) or super verbose (default inline snapshot format).
2021-01-19 09:51:32 -05:00
Andrew Clark eb0fb38230
Build stable and experimental with same command (#20573)
The goal is to simplify our CI pipeline so that all configurations
are built and tested in a single workflow.

As a first step, this adds a new build script entry point that builds
both the experimental and stable release channels into a single
artifacts directory.

The script works by wrapping the existing build script (which only
builds a single release channel at a time), then post-processing the
results to match the desired filesystem layout. A future version of the
build script would output the files directly without post-processing.

Because many parts of our infra depend on the existing layout of the
build artifacts directory, I have left the old workflows untouched.
We can incremental migrate to the new layout, then delete the old
workflows after we've finished.
2021-01-12 09:32:32 -08:00
Brian Vaughn dd16b78990 Tweaked DevTools build command slightly 2020-12-07 10:10:43 -05:00
Brian Vaughn a2a025537d
Fixed invalid DevTools work tags (#20362)
* Fixed invalid DevTools work tags

Work tags changed recently (PR #13902) but we didn't bump React versions. This meant that DevTools has valid work tags only for master (and FB www sync) but invalid work tags for the latest open source releases. To fix this, I incremneted React's version in Git (without an actual release) and added a new fork to the work tags detection branch.

This commit also adds tags for the experimental Scope and Fundamental APIs to DevTools so component names will at least display correctly. Technically these new APIs were first introduced to experimental builds ~16.9 but I didn't add a new branch to the work tags fork because I don't they're used commonly. I've just added them to the 17+ branches.

* Removed FundamentalComponent from DevTools tag defs
2020-12-01 10:33:32 -05:00
Brian Vaughn 2cf8f7f61c
Speed up local "build-for-detools" target (#20307) 2020-11-20 12:31:29 -05:00
Sebastian Markbåge e41fd1fc06
Support ESM module loaders in Flight fixture (#20229)
This lets the Flight fixture run as "type": "module" or "commonjs".

Experimental loaders can be used similar to require.extensions to do the
transpilation and replacement of .client.js references.
2020-11-12 08:11:05 -08:00
Justus Hämäläinen 06a4615be2
Allow Node 15.x (#20108)
Co-authored-by: Justus Hämäläinen <me@justushamalainen.fi>
2020-10-27 15:16:16 +00:00
oltrep f668b6c351
Bump to latest eslint-config-fbjs (#20029)
* bump package to latest

* update files to respect lint

* disable object-type-delimiter rule to work with prettier

* disable rule to let flow check pass
2020-10-16 16:06:08 +01:00
Ricky 880587366d
Deprecate old test script commands (#19893)
* Deprecate old test script commands

* Update PR template test script

* Add test-stable and test-www-classic

* Update circle test names

* Rename test-www-classic to test-classic

* Missed some job renames

* Missed some more job renames
2020-10-14 08:54:34 -04:00
E-Liang Tan 9340083395
Scheduling Profiler: Add Fast Refresh (#19757) 2020-09-03 09:17:57 -04:00
Bhumij Gupta 53e622ca7f
Fix instances of function declaration after return (#19733)
* Add ESLint plugin to check for any function declare after return
* Refactor code to move function declarations before return and fix failing lint
2020-09-01 08:55:10 -04:00
Pascal Fong Kye 1396e4a8f5
Fixes eslint warning when node type is ChainExpression (#19680)
* Add babel parser which supports ChainExpression

* Add and fix tests for new babel eslint parser

* extract function to mark node

* refactor for compatibility with eslint v7.7.0+

* Update eslint to v7.7.0
Update hook test since eslint now supports nullish coalescing
2020-08-29 21:03:23 +01:00
E-Liang Tan c641b611c4
Upgrade all @babel/* packages to fix DevTools builds on newer Node versions (#19647) 2020-08-20 11:47:16 -04:00
Ricky bc4cd92cd5
Use jest-environment-jsdom-sixteen (#19288)
* Use jest-environment-jsdom-sixteen

* Update yarn.lock

* Dedupe new jest packages in yarn.lock

* Pull upstream changes
2020-07-16 10:17:31 -04:00
Dan Abramov c7805b8d57
Use a custom jsdom fork (#19284) 2020-07-08 21:26:54 +01:00
Ricky 72bbcad160
Add new test cli (#19184)
* Add new test cli

* Remove --variant accidentally added to test-persist

* s/test/tests

* Updates from review

* Update package.json tests

* Missed a release channel in circle.yaml

* Update config.yml to use just run: with test commands

* Update release-channel options and add build dir checks

* Update test args to use the new release-channel options

* Fix error in circle config.yml

* Fix a wrong condition for the --variant check

* Fix a wrong condition for the --persistent check

* Prettier

* Require build check for devtool tests as well
2020-06-25 20:39:50 -04:00
Andrew Clark 8f05f2bd6d
Land Lanes implementation in old fork (#19108)
* Add autofix to cross-fork lint rule

* replace-fork: Replaces old fork contents with new

For each file in the new fork, copies the contents into the
corresponding file of the old fork, replacing what was already there.

In contrast to merge-fork, which performs a three-way merge.

* Replace old fork contents with new fork

First I ran  `yarn replace-fork`.

Then I ran `yarn lint` with autofix enabled. There's currently no way to
do that from the command line (we should fix that), so I had to edit the
lint script file.

* Manual fix-ups

Removes dead branches, removes prefixes from internal fields.  Stuff
like that.

* Fix DevTools tests

DevTools tests only run against the old fork, which is why I didn't
catch these earlier.

There is one test that is still failing. I'm fairly certain it's related
to the layout of the Suspense fiber: we no longer conditionally wrap the
primary children. They are always wrapped in an extra fiber.

Since this has been running in www for weeks without major issues, I'll
defer fixing the remaining test to a follow up.
2020-06-11 20:05:15 -07:00
Sebastian Markbåge c03b8661a9
Upgrade Closure Compiler (#19041)
The Symbol bug has now been fixed so we can remove the hack that renames
the global variable.
2020-05-29 09:17:14 -07:00
Toru Kobayashi fb735423bb
Fix rollup validate script (#18900)
* Revert "Revert "deps: update ESLint version to v7 (#18897)" (#18899)"

This reverts commit 84fd4b853f.

* fix rollup validate script
2020-05-27 01:19:32 +01:00
Dan Abramov 84fd4b853f
Revert "deps: update ESLint version to v7 (#18897)" (#18899)
This reverts commit 039ad34a05.
2020-05-12 20:06:14 +01:00
Toru Kobayashi 039ad34a05
deps: update ESLint version to v7 (#18897) 2020-05-12 18:41:37 +01:00
Nick Reiley d2ef120089
Allow Node 14.x (#18755) 2020-04-28 15:57:45 +01:00
Sebastian Markbåge 0960b7ba58
Upgrade fbjs-scripts (#18684)
* Upgrade fbjs-scripts

This script takes into account the NODE_ENV as part of jest cache keys.
This avoids flaky tests since we depend on different transforms in prod
and dev.

* Upgrade Fresh test to Babel 7 transform
2020-04-20 18:20:03 -07:00
Andrew Clark f3f3d77c20
Fix www tests not running in prod (#18593)
I made a mistake when setting these up a while ago. Setting the NODE_ENV
in the CircleCI config doesn't work because it's also set in the node
script command.

The number of test commands is getting out of control. Might need to fix
it at some point. Not today for me.
2020-04-13 15:53:13 -07:00
Andrew Clark 26fc16484e
Script for syncing changes between forks (#18550)
Adds command `yarn merge-fork`.

```sh
yarn merge-fork --base-dir=packages/react-reconciler/src ReactFiberWorkLoop
```

This will take all the changes in `ReactFiberWorkLoop.new.js` and apply
them to `ReactFiberWorkLoop.old.js`.

You can merge multiple modules at a time:

```sh
yarn merge-fork \
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop \
  ReactFiberBeginWork \
  ReactFiberCompleteWork \
  ReactFiberCommitWork
```

You can provide explicit "old" and "new" file names. This only works
for one module at a time:

```sh
yarn merge-fork \
  --base-dir=packages/react-reconciler/src \
  --old=ReactFiberExpirationTime.js \
  --new=ReactFiberLane.js
```

The default is to merge changes from the new module to the old one. To
merge changes in the opposite direction, use `--reverse`.

```sh
yarn merge-fork \
  --reverse \
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop
```

By default, the changes are compared to HEAD. You can use `--base-ref`
to compare to any rev. For example, while working on a PR, you might
make multiple commits to the new fork before you're ready to backport
them to the old one. In that case, you want to compare to the merge
base of your PR branch:

```sh
yarn merge-fork \
  --base-ref=$(git merge-base HEAD origin/master)
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop
```
2020-04-09 11:37:13 -07:00
dependabot[bot] 8c974a70c9
Bump minimist from 1.2.0 to 1.2.3 (#18501)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.0 to 1.2.3.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.0...1.2.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-06 19:28:56 +01:00
Dan Abramov a8f2165e83
Update to Jest 25 (#18480)
* Revert "Revert "Upgrade to jest 25 (#17896)" (#18376)"

This reverts commit fc7835c657.

* Other fixes

* Fix a broken test
2020-04-03 16:37:36 +01:00
Sebastian Markbåge e6ea3d3873
Use Closure Compiler to compile to ES5 instead of Babel (#18449)
* Upgrade Closure

There are newer versions but they don't yet have corresponding releases
of google-closure-compiler-osx.

* Configure build

* Refactor ReactSymbols a bit

Provides a little better output.
2020-04-01 12:08:37 -07:00
Andrew Clark fc7835c657
Revert "Upgrade to jest 25 (#17896)" (#18376)
This reverts commit cf0081263c.

The changes to the test code relate to changes in JSDOM that come with Jest 25:

* Several JSDOM workarounds are no longer needed.
* Several tests made assertions to match incorrect JSDOM behavior (e.g. setAttribute calls) that JSDOM has now patched to match browsers.
  * https://codesandbox.io/s/resets-value-of-datetime-input-to-fix-bugs-in-ios-safari-1ppwh
* JSDOM no longer triggers default actions when dispatching click events.
  * https://codesandbox.io/s/beautiful-cdn-ugn8f
* JSDOM fixed (jsdom/jsdom#2700) a bug so that calling focus() on an already focused element does not dispatch a FocusEvent.
* JSDOM now supports passive events.
* JSDOM has improved support for custom CSS properties.
  * But requires jsdom/cssstyle#112 to land to support webkit prefixed properties.
2020-03-24 10:51:48 -07:00
Dominic Gannaway 0140118e8e
ReactDOM.useEvent: add support for beforeblur/afterblur (#18370)
* ReactDOM.useEvent: add support for beforeblur/afterblur
2020-03-24 16:14:55 +00:00
Kerollos Magdy 9e5626cdde
Fix yarn warning on running 'yarn build-for-devtools' (#18232)
fixes #18231
2020-03-10 15:37:02 +00:00