Commit Graph

351 Commits

Author SHA1 Message Date
Andrew Clark fc57432966
Move DOM fixtures test job to main CI workflow (#22385)
Moves the RELEASE_CHANNEL_stable_yarn_test_dom_fixtures job to our new,
combined CI workflow.

After this, there are only two jobs remaining to be migrated. Then we
can delete the old workflow and build script.
2021-09-21 08:00:28 -07:00
Riley Shaw fbce2d5274
Fix #21972: Add `onResize` event to video elements (#21973)
* Fix #21972: Add `onResize` event to video elements

This is a simple fix for #21972 that adds support for the `onResize` media event.

I created a separate `videoEventTypes` array since I doubt anyone will want to add `onResize` to an audio event. It would simplify the code a bit to just add `resize` to the `mediaEventTypes` array, if that’s preferred.

Pre-commit checklist ([source](https://reactjs.org/docs/how-to-contribute.html#sending-a-pull-request))

 Fork the repository and create your branch from `main`.
 Run `yarn` in the repository root.
 If you’ve fixed a bug or added code that should be tested, add tests!
 Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
 Run `yarn test --prod` to test in the production environment.
 If you need a debugger, run `yarn debug-test --watch TestName`, open chrome://inspect, and press “Inspect”.
 Format your code with prettier (`yarn prettier`).
 Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
 Run the Flow typechecks (`yarn flow`).
 If you haven’t already, complete the CLA.

* Consolidate `videoEventTypes` array into `mediaEventTypes`
2021-09-07 23:28:19 +01:00
Junaid Farooq 0da5ad09db
Renames master to main in fixtures/flight webpack config file (#21998) 2021-08-23 10:55:37 -04:00
Shubham Pandey 6f3fcbd6fa
Some remaining instances of master to main (#21982)
Co-authored-by: Shubham Pandey <shubham.pandey@mfine.co>
2021-07-30 08:56:55 -04:00
Shannon Feng 241485a2c4
[SSR2 Fixture] Delete duplicate DOCTYPE (#21824) 2021-07-08 03:11:42 +01:00
Andrew Clark 06f7b4f43a
`act` should work without mock Scheduler (#21714)
Currently, in a React 18 root, `act` only works if you mock the
Scheduler package. This was because we didn't want to add additional
checks at runtime.

But now that the `act` testing API is dev-only, we can simplify its
implementation.

Now when an update is wrapped with `act`, React will bypass Scheduler
entirely and push its tasks onto a special internal queue. Then, when
the outermost `act` scope exists, we'll flush that queue.

I also removed the "wrong act" warning, because the plan is to move
`act` to an isomorphic entry point, simlar to `startTransition`. That's
not directly related to this PR, but I didn't want to bother
re-implementing that warning only to immediately remove it.

I'll add the isomorphic API in a follow up.

Note that the internal version of `act` that we use in our own tests
still depends on mocking the Scheduler package, because it needs to work
in production. I'm planning to move that implementation to a shared
(internal) module, too.
2021-06-22 14:25:07 -07:00
Sebastian Markbåge 568dc3532e
Remove unstable_createRoot from internal builds (#21698)
These callsites were already removed as far as I can tell.
2021-06-17 11:29:30 -07:00
Andrew Clark bd0a963445
Throw when `act` is used in production (#21686)
Upgrades the deprecation warning to a runtime error.

I did it this way instead of removing the export so the type is the same
in both builds. It will get dead code eliminated regardless.
2021-06-16 16:29:51 -04:00
Dan Abramov a0d2d1e1e1 Fix fixture lockfile manually 2021-06-16 00:04:01 +01:00
Dan Abramov 6cbf2a8b3b Add missing package lock 2021-06-15 23:52:15 +01:00
Dan Abramov c0a77029c4 Remove unused variable 2021-06-15 23:49:41 +01:00
Dan Abramov f283d7524a Use npm lockfile for fixture 2021-06-15 23:49:04 +01:00
Dan Abramov 03c5314b44
[SSR2 Fixture] Update APIs (#21688) 2021-06-15 23:20:51 +01:00
Sebastian Markbåge 9212d994ba
Merge /unstable-fizz entry point into /server (#21684) 2021-06-14 18:37:44 -07:00
Sebastian Markbåge 9343f87203
Use the server src files as entry points for the builds/tests (#21683)
* Use the server src files as entry points for the builds/tests

We need one top level entry point to target two builds so we can't have
the top level one be the entry point for the builds.

* Same thing but with the modern entry point
2021-06-14 16:23:19 -07:00
Sebastian Markbåge bd45ad05dc
Add a DOCTYPE to the stream if the <html> tag is rendered (#21680)
This makes it a lot easier to render the whole document using React without
needing to patch into the stream.

We expect that currently people will still have to patch into the stream
to do advanced things but eventually the goal is that you shouldn't
need to.
2021-06-14 13:57:17 -07:00
Andrew Clark aecb3b6d11
Deprecate ReactDOM.render and ReactDOM.hydrate (#21652)
* Use existing test warning filter for server tests

We have a warning filter for our internal tests to ignore warnings
that are too noisy or that we haven't removed from our test suite yet:
shouldIgnoreConsoleError.

Many of our server rendering tests don't use this filter, though,
because it has its own special of asserting warnings.

So I added the warning filter to the server tests, too.

* Deprecate ReactDOM.render and ReactDOM.hydrate

These are no longer supported in React 18. They are replaced by the
`createRoot` API.

The warning includes a link to documentation of the new API. Currently
it redirects to the corresponding working group post. Here's the PR to
set up the redirect: https://github.com/reactjs/reactjs.org/pull/3730

Many of our tests still use ReactDOM.render. We will need to gradually
migrate them over to createRoot.

In the meantime, I added the warnings to our internal warning filter.
2021-06-09 13:46:55 -07:00
Dan Abramov 23c80959ad Fix CSS 2021-06-04 23:12:01 +01:00
Dan Abramov 2568fecc38 Tweak fixture 2021-06-04 23:10:02 +01:00
Dan Abramov fccfc24893
[Fizz] Add another fixture (#21627) 2021-06-04 23:04:06 +01:00
Ricky e0f89aa056
Clean up Scheduler forks (#20915)
* Clean up Scheduler forks

* Un-shadow variables

* Use timer globals directly, add a test for overrides

* Remove more window references

* Don't crash for undefined globals + tests

* Update lint config globals

* Fix test by using async act

* Add test fixture

* Delete test fixture
2021-05-17 16:53:58 -04:00
Ricky 79740da4c6
Update time-slicing demo (#21401) 2021-04-30 20:50:59 -04:00
Brian Vaughn b6644fabb9
Added test fixture for scheduling profiler (#21397) 2021-04-30 15:23:45 -04:00
Brian Vaughn fc33f12bde
Remove unstable scheduler/tracing API (#20037) 2021-04-26 19:16:18 -04:00
Sebastian Markbåge af5037a7a8
[Fizz] Wire up the Fixture (#21273)
* Wire up fizz to fixture

* Fixed typo conditional
2021-04-22 15:00:35 -07: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
Sebastian Markbåge cdfde3ae11
Always rethrow original error when we replay errors (#20425)
We replay errors so you can break on paused exceptions. This is done in
the second pass so that the first pass can ignore suspense.

Originally this threw the original error. For suppression purposes
we copied the flag onto the original error.

f1dc626b29/packages/react-reconciler/src/ReactFiberScheduler.old.js (L367-L369)

During this refactor it changed to just throw the retried error:

https://github.com/facebook/react/pull/15151

We're not sure exactly why but it was likely just an optimization or
clean up.

So we can go back to throwing the original error. That helps in the case
where a memoized function is naively not rethrowing each time such as
in Node's module system.

Unfortunately this doesn't fix the problem fully.
Because invokeGuardedCallback captures the error and logs it to the browser.
So you still end up seeing the wrong message in the logs.

This just fixes so that the error boundary sees the first one.
2020-12-10 05:50:41 -08:00
Dan Abramov 40ff2395e4
[Flight] Prevent non-Server imports of aliased Server entrypoints (#20422)
* [Flight] Prevent non-Server imports of aliased Server entrypoints

* Fix Flow + await

* Tighten the types
2020-12-10 03:55:38 +00:00
Sebastian Markbåge 5fd9db732d
[Flight] Rename react-transport-... packages to react-server-... (#20403)
* Move files

* Update paths

* Rename import variables

* Rename /server to /writer

This is mainly because "React Server Server" is weird so we need another
dimension.

* Use "react-server" convention to enforce that writer is only loaded in a server
2020-12-08 08:08:57 -05:00
Sebastian Markbåge ce40f1dc2f
Use assets API + writeToDisk instead of directly writing to disk (#20402) 2020-12-07 17:54:28 -08:00
Dan Abramov 0512cd6a26
Bump fixture dependency versions (#20397)
* Bump all versions

* Switch to CJS mode

* Revert "Switch to CJS mode"

This reverts commit b3c4fd92dc.

* Fix ES mode

* Add nodemon to restart the server on edits

* Ignore /server/ from compilation
2020-12-08 01:23:49 +00:00
Sebastian Markbåge 30dfb86025
[Flight] Basic scan of the file system to find Client modules (#20383)
* Basic scan of the file system to find Client modules

This does a rudimentary merge of the plugins. It still uses the global
scan and writes to file system.

Now the plugin accepts a search path or a list of referenced client files.
In prod, the best practice is to provide a list of files that are actually
referenced rather than including everything possibly reachable. Probably
in dev too since it's faster.

This is using the same convention as the upstream ContextModule - which
powers the require.context helpers.

* Add neo-async to dependencies
2020-12-07 12:10:18 -05:00
Sebastian Markbåge 0db61a08be
Fix Flight Prod Fixture (#20382)
* Don't use async/await

Babel transpilation fails for some reason in prod.

* Set up production runner command

Uses python because meh. Just to show it's static.

* Use build folder in prod
2020-12-04 18:00:57 -08:00
Dan Abramov 41c5d00fc9
[Flight] Minimal webpack plugin (#20228) 2020-12-03 21:21:19 +00:00
Dan Abramov e23673b511
[Flight] Add getCacheForType() to the dispatcher (#20315)
* Remove react/unstable_cache

We're probably going to make it available via the dispatcher. Let's remove this for now.

* Add readContext() to the dispatcher

On the server, it will be per-request.

On the client, there will be some way to shadow it.

For now, I provide it on the server, and throw on the client.

* Use readContext() from react-fetch

This makes it work on the server (but not on the client until we implement it there.)

Updated the test to use Server Components. Now it passes.

* Fixture: Add fetch from a Server Component

* readCache -> getCacheForType<T>

* Add React.unstable_getCacheForType

* Add a feature flag

* Fix Flow

* Add react-suspense-test-utils and port tests

* Remove extra Map lookup

* Unroll async/await because build system

* Add some error coverage and retry

* Add unstable_getCacheForType to Flight entry
2020-12-03 03:44:56 +00:00
Sebastian Markbåge 3f73dcee37
Support named exports from client references (#20312)
* Rename "name"->"filepath" field on Webpack module references

This field name will get confused with the imported name or the module id.

* Switch back to transformSource instead of getSource

getSource would be more efficient in the cases where we don't need to read
the original file but we'll need to most of the time.

Even then, we can't return a JS file if we're trying to support non-JS
loader because it'll end up being transformed.

Similarly, we'll need to parse the file and we can't parse it before it's
transformed. So we need to chain with other loaders that know how.

* Add acorn dependency

This should be the version used by Webpack since we have a dependency on
Webpack anyway.

* Parse exported names of ESM modules

We need to statically resolve the names that a client component will
export so that we can export a module reference for each of the names.

For export * from, this gets tricky because we need to also load the
source of the next file to parse that. We don't know exactly how the
client is built so we guess it's somewhat default.

* Handle imported names one level deep in CommonJS using a Proxy

We use a proxy to see what property the server access and that will tell
us which property we'll want to import on the client.

* Add export name to module reference and Webpack map

To support named exports each name needs to be encoded as a separate
reference. It's possible with module splitting that different exports end
up in different chunks.

It's also possible that the export is renamed as part of minification.
So the map also includes a map from the original to the bundled name.

* Special case plain CJS requires and conditional imports using __esModule

This models if the server tries to import .default or a plain require.
We should replicate the same thing on the client when we load that
module reference.

* Dedupe acorn-related deps

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2020-11-30 14:37:27 -08:00
Sebastian Markbåge 565148d751
Disallow *.server.js imports from any other files (#20309)
This convention ensures that you can declare that you intend for a file
to only be used on the server (even if it technically might resolve
on the client).
2020-11-30 14:25:56 -08:00
Sebastian Markbåge d93b58a5e3
Add flight specific entry point for react package (#20304)
This configures the Flight fixture to use the "react-server" environment.

This allows the package.json exports field to specify a different resolution
in this environment.

I use this in the "react" package to resolve to a new bundle that excludes
the Hooks that aren't relevant in this environment like useState and useEffect.

This allows us to error early if these names are imported. If we actually
published ESM, it would we a static error. Now it's a runtime error.

You can test this by importing useState in Container.js which is used
by the client and server.
2020-11-20 08:47:13 -08:00
Sebastian Markbåge 82e99e1b02
Add Node ESM Loader and Register Entrypoints (#20274)
* Add Node ESM loader build

This adds a loader build as a first-class export. This will grow in
complexity so it deserves its own module.

* Add Node CommonJS regiter build

This adds a build as a first-class export for legacy CommonJS registration
in Node.js. This will grow in complexity so it deserves its own module.

* Simplify fixture a bit to easier show usage with or without esm

* Bump es version

We leave async function in here which are newer than ES2015.
2020-11-16 23:46:27 -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
Sebastian Markbåge e855f91e85
[Flight] Expand the fixture to use require.extensions (#20209)
* Expand fixture

Use .server convention. /server/index.js should really change too so it can be compiled but for now we treat it as bootstrapping code outside the compiled code.

Move App.server. It's part of the application code rather than the infra.

Add hybrid component used in both server/client and an extra component shared by multiple entry points.

* Use require.extensions to replace .client imports

The simplest server doesn't need AOT compilation. Instead we can just
configure require.extensions. This is probably not the best idea to use
in prod but is enough to show the set up.
2020-11-10 12:48:51 -08:00
Dan Abramov 2af07d3f4d
[Flight Fixture] Server + Client Components (#20150) 2020-11-03 03:00:23 +00:00
Simen Bekkhus 020d3aa4e8
chore: downgrade source-map-support for stack "fix" (#20026)
* chore: downgrade source-map-support for stack "fix"

* lint?
2020-10-14 20:45:54 +01:00
Dan Abramov 6d50a9d090
Fixture: Legacy JSX Runtimes (#20012)
* Fixture: Legacy JSX Runtimes

* Add more comments
2020-10-14 18:28:03 +01:00
Saikat Guha f46a80ae11
Update outdated links and fix two broken links (#19985)
* update all facebook.github.io links

* facebookincubator links : update some outdated links and fix two other broken links where they are actually the latest updated ones
2020-10-09 02:56:30 +01:00
Brian Vaughn 461cd84944
Revert "DevTools: Improve browser extension iframe support (#19854)" (#19959)
This reverts commit a99bf5c5f4.
2020-10-05 09:44:08 -04:00
6h057 a99bf5c5f4
DevTools: Improve browser extension iframe support (#19854)
Co-authored-by: Joel DSouza <joel.dsouza@kapturecrm.com>
Co-authored-by: Damien Maillard <damien.maillard@dailymotion.com>
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-09-23 16:56:13 -04:00
Brian Vaughn 26857ecfa9
Revert "DevTools: Improve browser extension iframe support (#19827)" (#19852)
This reverts commit ec39a5e901.
2020-09-17 14:57:44 -04:00
6h057 ec39a5e901
DevTools: Improve browser extension iframe support (#19827)
Co-authored-by: Joel DSouza <joel.dsouza@kapturecrm.com>
Co-authored-by: Damien Maillard <damien.maillard@dailymotion.com>
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-09-14 10:04:46 -04:00
6h057 917cb01a58
React DevTools: Show symbols used as keys in state (#19786)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-09-14 09:55:19 -04:00