Commit Graph

21 Commits

Author SHA1 Message Date
Sebastian Markbåge 0a76fb9ec4
Copy from build to node_modules instead of linking to builds (#26210)
Using the `link:` protocol to create a dependency doesn't work when we
edit the `package.json` to lock the version to a specific version. It
didn't really work before neither, it was just that `yarn` installed an
existing `scheduler` dependency from npm instead of using the built one.

So I'm updating all the fixture to use the technique where we copy files
instead.
2023-02-21 14:48:37 -05:00
Sebastian Markbåge c8d4eeda5f
Rename `yarn start` to `yarn dev` and `yarn start:prod` to `yarn start` (#26209)
The `start` convention is a CRA convention but nobody else of the modern
frameworks / tools use this convention for a file watcher and dev mode.
Instead the common convention is `dev`. Instead `start` is for running a
production build that's already been built.

---------

Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
2023-02-21 14:18:21 -05:00
Sebastian Markbåge db5e6250d4
Rename yarn build-combined to just yarn build (#26192)
It's confusing to new contributors, and me, that you're supposed to use
`yarn build-combined` for almost everything but not fixtures.

We should use only one build command for everything.

Updated fixtures to use the folder convention of build-combined.
2023-02-17 16:00:18 -05:00
Jan Kassens 6b30832666
Upgrade prettier (#26081)
The old version of prettier we were using didn't support the Flow syntax
to access properties in a type using `SomeType['prop']`. This updates
`prettier` and `rollup-plugin-prettier` to the latest versions.

I added the prettier config `arrowParens: "avoid"` to reduce the diff
size as the default has changed in Prettier 2.0. The largest amount of
changes comes from function expressions now having a space. This doesn't
have an option to preserve the old behavior, so we have to update this.
2023-01-31 08:25:05 -05:00
Andrew Clark 9cdf8a99ed
[Codemod] Update copyright header to Meta (#25315)
* Facebook -> Meta in copyright

rg --files | xargs sed -i 's#Copyright (c) Facebook, Inc. and its affiliates.#Copyright (c) Meta Platforms, Inc. and affiliates.#g'

* Manual tweaks
2022-10-18 11:19:24 -04:00
Kay d352fd0931
Fix for SSR2 fixture not working locally (#24237)
* SS2 fixture not working locally fix

* Fix prettier issue

* prettier excess line fix

* Update render.js

* Update README.md

Co-authored-by: dan <dan.abramov@gmail.com>
2022-04-01 00:26:12 +01:00
Sebastian Markbåge 14c2be8dac
Rename Node SSR Callbacks to onShellReady/onAllReady and Other Fixes (#24030)
* I forgot to call onFatalError

I can't figure out how to write a test for this because it only happens
when there is a bug in React itself which would then be fixed if we found
it.

We're also covered by the protection of ReadableStream which doesn't leak
other errors to us.

* Abort requests if the reader cancels

No need to continue computing at this point.

* Abort requests if node streams get destroyed

This is if the downstream cancels is for example.

* Rename Node APIs for Parity with allReady

The "Complete" terminology is a little misleading because not everything
has been written yet. It's just "Ready" to be written now.

onShellReady
onShellError
onAllReady

* 'close' should be enough
2022-03-04 14:38:46 -05:00
Sebastian Markbåge 17806594cc
Move createRoot/hydrateRoot to react-dom/client (#23385)
* Move createRoot/hydrateRoot to /client

We want these APIs ideally to be imported separately from things you
might use in arbitrary components (like flushSync). Those other methods
are "isomorphic" to how the ReactDOM tree is rendered. Similar to hooks.

E.g. importing flushSync into a component that only uses it on the client
should ideally not also pull in the entry client implementation on the
server.

This also creates a nicer parity with /server where the roots are in a
separate entry point.

Unfortunately, I can't quite do this yet because we have some legacy APIs
that we plan on removing (like findDOMNode) and we also haven't implemented
flushSync using a flag like startTransition does yet.

Another problem is that we currently encourage these APIs to be aliased by
/profiling (or unstable_testing). In the future you don't have to alias
them because you can just change your roots to just import those APIs and
they'll still work with the isomorphic forms. Although we might also just
use export conditions for them.

For that all to work, I went with a different strategy for now where the
real API is in / but it comes with a warning if you use it. If you instead
import /client it disables the warning in a wrapper. That means that if you
alias / then import /client that will inturn import the alias and it'll
just work.

In a future breaking changes (likely when we switch to ESM) we can just
remove createRoot/hydrateRoot from / and move away from the aliasing
strategy.

* Update tests to import from react-dom/client

* Fix fixtures

* Update warnings

* Add test for the warning

* Update devtools

* Change order of react-dom, react-dom/client alias

I think the order matters here. The first one takes precedence.

* Require react-dom through client so it can be aliased

Co-authored-by: Andrew Clark <git@andrewclark.io>
2022-03-01 00:13:28 -05:00
Sebastian Markbåge 5690932765
Add onErrorShell Callback (#23247)
This indicates that an error has happened before the shell completed and
there's no point in emitting the result of this stream.

This is not quite the same as other fatal errors that can happen even
after streaming as started.

It's also not quite the same as onError before onCompleteShell because
onError can be called for an error inside a Suspense boundary before the
shell completes.

Implement shell error handling in Node SSR fixtures

Instead of hanging indefinitely.

Update Browser Fixture

Expose onErrorShell to the Node build

This API is not Promisified so it's just a separate callback instead.

Promisify the Browser Fizz API

It's now a Promise of a readable stream. The Promise resolves when the
shell completes. If the shell errors, the Promise is rejected.
2022-02-08 22:38:14 -05:00
Sebastian Markbåge cdb8a1d19d
[Fizz] Add option to inject bootstrapping script tags after the shell is injected (#22594)
* Add option to inject bootstrap scripts

These are emitted right after the shell as flushed.

* Update ssr fixtures to use bootstrapScripts instead of manual script tag

* Add option to FB renderer too
2021-10-19 19:36:10 -07:00
Sebastian Markbåge 579c008a75
[Fizz/Flight] pipeToNodeWritable(..., writable).startWriting() -> renderToPipeableStream(...).pipe(writable) (#22450)
* Rename pipeToNodeWritable to renderToNodePipe

* Add startWriting API to Flight

We don't really need it in this case because there's way less reason to
delay the stream in Flight.

* Pass the destination to startWriting instead of renderToNode

* Rename startWriting to pipe

This mirrors the ReadableStream API in Node

* Error codes

* Rename to renderToPipeableStream

This mimics the renderToReadableStream API for the browser.
2021-10-06 00:31:06 -04:00
Sebastian Markbåge 2cc6d79c98
Rename onReadyToStream to onCompleteShell (#22443) 2021-09-27 12:38:22 -07:00
Shannon Feng 241485a2c4
[SSR2 Fixture] Delete duplicate DOCTYPE (#21824) 2021-07-08 03:11:42 +01: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
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