react/scripts
Sebastian Markbåge b52a5624e9 [CS] Persistent Updates (#11260)
* Update build size

* [CS] Clone container instead of new root concept

The extra "root" concept is kind of unnecessary. Instead of having a
mutable container even in the persistent mode, I'll instead make the
container be immutable too and be cloned. Then the "commit" just becomes
swapping the previous container for the new one.

* Change the signature or persistence again

We may need to clone without any updates, e.g. when the children are changed.

Passing in the previous node is not enough to recycle since it won't have the
up-to-date props and children. It's really only useful to for allocation pooling.

* Implement persistent updates

This forks the update path for host fibers. For mutation mode we mark
them as having an effect. For persistence mode, we clone the stateNode with
new props/children.

Next I'll do HostRoot and HostPortal.

* Refine protocol into a complete and commit phase

finalizeContainerChildren will get called at the complete phase.
replaceContainer will get called at commit.

Also, drop the keepChildren flag. We'll never keep children as we'll never
update a container if none of the children has changed.

* Implement persistent updates of roots and portals

These are both "containers". Normally we rely on placement/deletion effects
to deal with insertions into the containers. In the persistent mode we need
to clone the container and append all the changed children to it.

I needed somewhere to store these new containers before they're committed
so I added another field.

* Commit persistent work at the end by swapping out the container

* Unify cloneOrRecycle

Originally I tried to make the recyclable instance nullable but Flow didn't
like that and it's kind of sketchy since the instance type might not be
nullable.

However, the real difference which one we call is depending on whether they
are equal. We can just offload that to the renderer. Most of them won't
need to know about this at all since they'll always clone or just create
new.

The ones that do know now have to be careful to compare them so they don't
reuse an existing instance but that's probably fine to simplify the
implementation and API.

* Add persistent noop renderer for testing

* Add basic persistent tree test

* Test bail out

This adds a test for bailouts. This revealed a subtle bug. We don't set the
return pointer when stepping into newly created fibers because there
can only be one. However, since I'm reusing this mechanism for persistent
updates, I'll need to set the return pointer because a bailed out tree
won't have the right return pointer.

* Test persistent text nodes

Found another bug.

* Add persistent portal test

This creates a bit of an unfortunate feature testing in the unmount
branch.

That's because we want to trigger nested host deletions in portals in the
mutation mode.

* Don't consider container when determining portal identity

Basically, we can't use the container to determine if we should keep
identity and update an existing portal instead of recreate it. Because
for persistent containers, there is no permanent identity.

This makes it kind of strange to even use portals in this mode. It's
probably more ideal to have another concept that has permanent identity
rather than trying to swap out containers.

* Clear portals when the portal is deleted

When a portal gets deleted we need to create a new empty container and
replace the current one with the empty one.

* Add renderer mode flags for dead code elimination

* Simplify ReactNoop fix

* Add new type to the host config for persistent configs

We need container to stay as the persistent identity of the root atom.
So that we can refer to portals over time.

Instead, I'll introduce a new type just to temporarily hold the children
of a container until they're ready to be committed into the permanent
container. Essentially, this is just a fancy array that is not an array
so that the host can choose data structure/allocation for it.

* Implement new hooks

Now containers are singletons and instead their children swap. That way
portals can use the container as part of their identity again.

* Update build size and error codes

* Address comment

* Move new files to new location
2017-10-18 18:28:23 -07:00
..
babel Update license headers BSD+Patents -> MIT 2017-09-25 18:17:44 -07:00
bench Fix a few typos (#10860) 2017-09-27 11:13:21 +01:00
circleci Use Yarn Workspaces (#11252) 2017-10-19 00:22:21 +01:00
error-codes [CS] Persistent Updates (#11260) 2017-10-18 18:28:23 -07:00
eslint-rules Simplify Jest config a little bit (#11242) 2017-10-16 23:17:00 +01:00
facts-tracker Update license headers BSD+Patents -> MIT 2017-09-25 18:17:44 -07:00
fiber Fix a few typos (#10860) 2017-09-27 11:13:21 +01:00
flow Move Flow environment into scripts/flow (#11249) 2017-10-17 14:20:00 +01:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Use Yarn Workspaces (#11252) 2017-10-19 00:22:21 +01:00
perf-counters Change license and remove references to PATENTS 2017-09-25 18:17:44 -07:00
prettier Use Yarn Workspaces (#11252) 2017-10-19 00:22:21 +01:00
print-warnings Update license headers BSD+Patents -> MIT 2017-09-25 18:17:44 -07:00
release Use Yarn Workspaces (#11252) 2017-10-19 00:22:21 +01:00
rollup [CS] Persistent Updates (#11260) 2017-10-18 18:28:23 -07:00
shared Update license headers BSD+Patents -> MIT 2017-09-25 18:17:44 -07:00
tasks Use Yarn Workspaces (#11252) 2017-10-19 00:22:21 +01:00
authors AUTHORS 2013-09-09 23:42:54 -07:00