Commit Graph

1036 Commits

Author SHA1 Message Date
Sophie Alpert
2bd1222a82
Format danger percents better (#12256)
Test Plan: yolo? yarn danger pr didn't give me any useful output. :\
2018-02-21 15:48:37 -08:00
Andrew Clark
93ce76b7ea Update bundle sizes for simple-cache-provider 2018-02-15 19:19:40 -08:00
Andrew Clark
4312b82932
[experimental] simple-cache-provider (#12224)
* [experimental] simple-cache-provider

Pushing an early version of this for testing and demonstration purposes.

* Change invariant to DEV-only warning

* Use function overloading for createResource type

Expresses that primitive keys do not require a hash function, but
non-primitive keys do.

* More tests

* Use export *

* Make Record type a disjoint union

* Pass miss argument separate from key to avoid a closure
2018-02-15 16:38:15 -08:00
Andrew Clark
1fd205ad2d
Additional release script options for publishing canary versions (#12219)
* Additional release script options for publishing canary versions

- `branch` specifies a branch other than master
- `local` skips pulling from the remote branch and checking CircleCI
- `tag` specifies an npm dist tag other than `latest` or `next`

We may add a higher-level `canary` option in the future.

* Address Brian's feedback:

- Updated description of `local` option
- Throws if the `latest` tag is specified for a prerelease version
2018-02-13 11:44:27 -08:00
Brian Vaughn
e2563a3c52
Handle packages without dependencies (#12217) 2018-02-12 15:46:43 -08:00
Brian Vaughn
fb85cf2e9c Update bundle sizes for 16.3.0-alpha.1 release 2018-02-12 10:41:41 -08:00
Brian Vaughn
d4afeb5aff
Added ReactFabric shim (#12216) 2018-02-12 10:12:46 -08:00
Brian Vaughn
41b8c65f1e
Add react-is package (#12199)
Authoritative brand checking library.

Can be used without any dependency on React. Plausible replacement for `React.isValidElement.`
2018-02-11 14:08:40 -08:00
Orta
c7ce0091dc [Danger] Use the PR's mergebase for a branch in the dangerfile (#12049)
* [Danger] Use the PR's mergebase for a branch in the dangerfile instead of
the root commit's parent.

* [Danger] Get the full history to find the merge base
2018-02-11 19:43:29 +00:00
Dan Abramov
78a595aeb7 Update sizes 2018-02-10 13:48:07 +00:00
Dan Abramov
f07dd45b75 Fix build stats display 2018-02-10 13:37:33 +00:00
Dan Abramov
467b1034ce
Disable for...of by default, rewrite cases where it matters (#12198)
* Add no-for-of lint rule

* Ignore legit use cases of for..of

* Rewrite for..of in source code
2018-02-09 16:11:22 +00:00
Sophie Alpert
49b0ca1b83
Fix finding Fabric feature flags (#12189)
Test Plan: yarn build fabric, inspect build/react-native/ReactFabric-dev.js to see enablePersistentReconciler = true.
2018-02-08 13:28:17 -08:00
Brian Vaughn
cbf729659e
Enable warnAboutDeprecatedLifecycles for ReactNative (#12186) 2018-02-08 10:48:18 -08:00
Dan Abramov
f828ca407f
Expose persistent reconciler to custom renderers (#12156) 2018-02-05 16:56:21 +00:00
Brian Vaughn
ad07be755d
Release script does a fresh Yarn install of deps (#12149)
This would have caught the recent Yarn workspaces / semver issue sooner.
2018-02-04 17:06:14 -08:00
Brian Vaughn
dc271876a2
Pre-release version fix (#12148)
* Ran updated release script to fix deps
* Release script handles prerelease deps correctly
* Update noop-renderer dependencies on reconciler package
2018-02-04 08:54:42 -08:00
Ivan Starkov
be85544b89 Fix process.CI typo (#12146) 2018-02-04 01:56:06 +00:00
Brian Vaughn
885a291141 Update bundle sizes for 16.3.0-alpha.0 release 2018-02-02 13:01:34 -08:00
Brian Vaughn
4da13ec5e1 Update error codes for 16.3.0-alpha.0 release 2018-02-02 13:01:33 -08:00
Brian Vaughn
d27b45131d
updated ReactFeatureFlags shim (#12116) 2018-01-29 16:11:18 -08:00
Brian Vaughn
d0e75dcfe2
Improve toWarnDev matcher DX for unexpected warnings (#12082)
Use jest-diff to format the warnings in a way that makes it easier to spot the differences.
2018-01-23 14:46:58 -08:00
Brian Vaughn
098745b2d1
Improved toWarnDev matcher to avoid swallowing errors (#12081)
While writing tests for unsafe async warnings, I noticed that in certain cases, errors were swallowed by the toWarnDev matcher and resulted in confusing test failures. For example, if an error prevented the code being tested from logging an expected warning- the test would fail saying that the warning hadn't been logged rather than reporting the unexpected error. I think a better approach for this is to always treat caught errors as the highest-priority reason for failing a test.

I reran all of the test cases for this matcher that I originally ran with PR #11786 and ensured they all still pass.
2018-01-23 14:46:50 -08:00
Dan Abramov
04d8fecc4a
Temporarily disable Danger
Its calculation is currently a bit misleading.
@orta plans to look into this but for now I'll disable.
2018-01-22 19:31:35 +00:00
Sebastian Markbåge
6031bea239
Add Experimental Fabric Renderer (#12069) 2018-01-22 09:58:35 -08:00
Sebastian Markbåge
d3647583b3
Remove experimental RT/CS renderers (#12032)
Will follow up with adding a new one.
2018-01-17 18:07:25 -08:00
Orta
d8d797645c Adds Danger and a rule showing build size differences (#11865)
* Adds danger_js with an initial rule for warning about large PRs

Signed-off-by: Anandaroop Roy <roop@artsymail.com>

* [WIP] Get the before and after for the build results

* [Dev] More work on the Dangerfile

* [Danger] Split the reports into sections based on their package

* Remove the --extract-errors on the circle build

* [Danger] Improve the lookup for previous -> current build to also include the environment

* Fix rebase
2018-01-17 01:49:38 +00:00
Rick Hanlon II
4f309f86df Plug ~100 test leaks (#12020) 2018-01-15 11:15:19 +00:00
Semen Zhydenko
5b975411a1 Minor typos fixed (#12005)
* commiting -> committing

* doens't -> doesn't

* interuption -> interruption

* inital -> initial

* statment -> statement
2018-01-11 12:24:49 +00:00
Dan Abramov
4501996398
Use 2 workers for all tests on CI (#11990) 2018-01-10 23:54:23 +00:00
Brian Vaughn
ec67ee400c
Upgrade to ESLint 4.1 and add no-focused-tests rule (#11977)
* Runs a lint rule on tests only that errors if it sees `fdescribe` or `fit` calls.
* Changes `file:` to `link:` for our custom, internal rules (just to simplify updating these in the future).
* Updates `eslint` from 3.10 -> 4.1 and `babel-eslint` from 7.1 -> 8.0 so that we can run this new rule only against tests.
2018-01-09 10:55:51 -08:00
Md Zubair Ahmed
77f96ed9c3 changed {} in pck.json and split them with && in fixtures (#11982) 2018-01-09 11:15:09 +00:00
Rick Hanlon II
26185759e4 Enable coverage, set jest maxWorkers to 2 (#11983) 2018-01-08 02:27:24 +00:00
Lucas Azzola
052a5f27f3 Use Prettier Config API (#11980) 2018-01-07 11:51:59 +00:00
Dan Abramov
48833f698d
Disable coverage again (#11974)
* Disable coverage again

* Update test_entry_point.sh
2018-01-05 18:59:13 +00:00
Brian Vaughn
c94b4b8b86
Fixed potential false-positive in toWarnDev matcher (#11898)
* Warn about spying on the console

* Added suppress warning flag for spyOn(console)

* Nits

* Removed spy-on-console guard

* Fixed a potential source of false-positives in toWarnDev() matcher
Also updated (most of) ReactIncrementalErrorLogging-test.internal to use the new matcher

* Removed unused third param to spyOn

* Improved clarity of inline comments

* Removed unused normalizeCodeLocInfo() method
2018-01-05 09:44:45 -08:00
Dan Abramov
1ebeb0542f
Move npm output from build/packages/* to build/node_modules/* (#11962)
* Move build/packages/* to build/node_modules/*

This fixes Node resolution in that folder and lets us require() packages in it in Node shell for manual testing.

* Link fixtures to packages/node_modules

This updates the location and also uses link: instead of file: to avoid Yarn caching the folder contents.
2018-01-04 19:01:31 +00:00
Dan Abramov
d289d4b634
Update to Jest 22 (#11956)
* Bump deps to Jest 22

* Prevent jsdom from logging intentionally thrown errors

This relies on our existing special field that we use to mute errors.
Perhaps, it would be better to instead rely on preventDefault() directly.
I outlined a possible strategy here: https://github.com/facebook/react/issues/11098#issuecomment-355032539

* Update snapshots

* Mock out a method called by ReactART that now throws

* Calling .click() no longer works, dispatch event instead

* Fix incorrect SVG element creation in test

* Render SVG elements inside <svg> to avoid extra warnings

* Fix range input test to use numeric value

* Fix creating SVG element in test

* Replace brittle test that relied on jsdom behavior

The test passed in jsdom due to its implementation details.

The original intention was to test the mutation method, but it was removed a while ago.

Following @nhunzaker's suggestion, I moved the tests to ReactDOMInput and adjusted them to not rely on implementation details.

* Add a workaround for the expected extra client-side warning

This is a bit ugly but it's just two places. I think we can live with this.

* Only warn once for mismatches caused by bad attribute casing

We used to warn both about bad casing and about a mismatch.
The mismatch warning was a bit confusing. We didn't know we warned twice because jsdom didn't faithfully emulate SVG.

This changes the behavior to only leave the warning about bad casing if that's what caused the mismatch.
It also adjusts the test to have an expectation that matches the real world behavior.

* Add an expected warning per comment in the same test
2018-01-04 18:57:30 +00:00
Brian Vaughn
bb881f2de7
Updated toWarnDev matcher so that ReactFiberScheduler won't suppress its errors (#11958) 2018-01-03 15:23:05 -08:00
Brian Vaughn
b5334a44e9
toWarnInDev matcher; throw on unexpected console.error (#11786)
* Added toWarnInDev matcher and connected to 1 test
* Added .toLowPriorityWarnDev() matcher
* Reply Jest spy with custom spy. Unregister spy after toWarnDev() so unexpected console.error/warn calls will fail tests.
* console warn/error throws immediately in tests by default (if not spied on)
* Pass-thru console message before erroring to make it easier to identify
* More robustly handle unexpected warnings within try/catch
* Error message includes remaining expected warnings in addition to unexpected warning
2018-01-02 11:06:41 -08:00
Brandon Dail
22e2bf7684
Return event name from getVendorPrefixedEventName (#11951) 2018-01-02 10:46:51 -08:00
Dan Abramov
0deea32667
Run some tests in Node environment (#11948)
* Run some tests in Node environment

* Separate SSR tests that require DOM

This allow us to run others with Node environment.
2018-01-02 18:42:18 +00:00
Dan Abramov
dd8b387b69
Reënable stats downloading
I'm running out of ideas to keep these commit messages entertaining. Thankfully this should keep the CI green and we can forget any of it ever happened.
2017-12-24 02:09:01 +00:00
Dan Abramov
d88a033cc3
Temporarily disable downloading the results file
I promise, we're close to fixing this. I fixed the last bug and now just need to run this to upload a "good" file and then re-enable it again...
2017-12-24 01:52:37 +00:00
Dan
e5cd4dd23e Record sizes 2017-12-24 01:47:49 +00:00
Dan
251193d4fc Fix writing stats to the file 2017-12-24 01:44:08 +00:00
Dan Abramov
32797fd3a3
We can reenable this now 2017-12-24 01:25:06 +00:00
Dan
5bf608723d Fix a few more issues that should fix the CI 2017-12-24 01:16:13 +00:00
Dan Abramov
bf9b0adcbd
This will fix CI, this time for real 2017-12-24 00:41:03 +00:00
Dan Abramov
021a567793
We can add this back now (should fix CI) 2017-12-23 22:31:37 +00:00
Dan Abramov
25321dcb23
Temporarily remove a script section that crashes
This will let us upload the updated stats to the server to fix this script
2017-12-23 22:22:24 +00:00
Orta
cf96d84040 [Dev] Adds module and bundle type metadata to the rollup results json (#11914) 2017-12-23 19:22:59 +00:00
Dan Abramov
247c524170
Update results.json from master before the build (#11882) 2017-12-18 18:56:38 +00:00
Dan Abramov
e40f6a9568
Upload build stats to the server (#11880) 2017-12-18 18:17:27 +00:00
Sam Goldman
d906de7f60 Use declare module.exports syntax for flow libdefs (#11861)
We added this to Flow in v0.25 (about 2 years ago), but never actually
deprecated the legacy `declare var exports` syntax. Hoping to do that
soon, so clearing up uses that I can find.

Test Plan: flow
2017-12-15 12:17:46 +00:00
Andrew Clark
7a72aa0a4a Record sizes 2017-12-12 16:07:36 -08:00
Dan Abramov
73265fc478
Simplify SyntheticEvent declarations (#11837) 2017-12-12 16:45:40 +00:00
Dan Abramov
7299238278
Update Rollup deps (#11829) 2017-12-11 16:54:12 +00:00
Jack Hou
e8e62ebb59 use different eslint config for es6 and es5 (#11794)
* use different eslint config for es6 and es5

* remove confusing eslint/baseConfig.js & add more eslint setting for es5, es6

* more clear way to run eslint on es5 & es6 file

* seperate ESNext, ES6, ES6 path, and use different lint config

* rename eslint config file & update eslint rules

* Undo yarn.lock changes

* Rename a file

* Remove unnecessary exceptions

* Refactor a little bit

* Refactor and tweak the logic

* Minor issues
2017-12-11 15:52:46 +00:00
Dan Abramov
abdbb16d4b Record sizes 2017-12-10 17:05:25 +00:00
Dan Abramov
bee4baf1fd
Oops, fix CI 2017-12-08 00:41:25 +00:00
Dan Abramov
9cccde927f
Add yarn build --pretty (#11801) 2017-12-07 22:47:56 +00:00
Dan Abramov
f93e34e980
Remove an extra allocation for open source bundles (#11797)
* Remove EventListener fbjs utility

EventListener normalizes event subscription for <= IE8. This is no
longer necessary. element.addEventListener is sufficient.

* Remove an extra allocation for open source bundles

* Split into two functions to avoid extra runtime checks

* Revert unrelated changes
2017-12-07 22:28:59 +00:00
Dan Abramov
41f920e430
Add a test-only transform to catch infinite loops (#11790)
* Add a test-only transform to catch infinite loops

* Only track iteration count, not time

This makes the detection dramatically faster, and is okay in our case because we don't have tests that iterate so much.

* Use clearer naming

* Set different limits for tests

* Fail tests with infinite loops even if the error was caught

* Add a test
2017-12-07 20:53:13 +00:00
Dan Abramov
f72043a369
Refactor the build scripts (#11787)
* Rewrite the build scripts

* Don't crash when doing FB-only builds

* Group sync imports under Sync.*

* Don't print known errors twice

* Use an exclamation that aligns vertically
2017-12-06 20:11:32 +00:00
Dan Abramov
2e29637ddf Record sizes 2017-12-05 14:20:32 +00:00
Yu Tian
6d242904cd Issue #11257(Updated) - Change build process to include npm pack and unpacking (#11750)
* Change build process to include npm pack and unpacking generated packages to corresponding build directories.

* Update function name, change to use os's default temp directory

* appending uuid to temp npm packaging directory.
2017-12-05 13:53:53 +00:00
Dan Abramov
d7f6ece27c
Remove the unused shim 2017-12-04 15:47:11 +00:00
Dan Abramov
62f8a822b0 Pin lighthouse at 2.0.0 2017-12-04 13:23:30 +00:00
Dan Abramov
8540768616
Fix benchmark runner (#11749) 2017-12-02 00:00:29 +00:00
Dan Abramov
f99ecce596 Record sizes 2017-12-01 02:36:50 +00:00
Dan Abramov
46b3c3e4ae
Use static injection for ReactErrorUtils (#11725)
* Use `this` inside invokeGuardedCallback

It's slightly odd but that's exactly how our www fork works.
Might as well do it in the open source version to make it clear we rely on context here.

* Move invokeGuardedCallback into a separate file

This lets us introduce forks for it.

* Add a www fork for invokeGuardedCallback

* Fix Flow
2017-11-30 19:10:46 +00:00
Dan Abramov
642a678a80
Replace ReactFiberErrorLogger injection with static forks (#11717) 2017-11-30 17:57:13 +00:00
Dan Abramov
060581b128
Fix issues with the new fork plugin (#11723) 2017-11-30 16:20:09 +00:00
Dan Abramov
8cbc16f0fa
Unify the way we fork modules (#11711)
* Unify the way we fork modules

* Replace rollup-plugin-alias with our own plugin

This does exactly what we need and doesn't suffer from https://github.com/rollup/rollup-plugin-alias/issues/34.

* Move the new plugin to its own file

* Rename variable for consistency

I settled on calling them "forks" since we already have a different concept of "shims".

* Move fork config into its own file
2017-11-30 12:11:00 +00:00
Dan Abramov
c78db58a61 Record sizes 2017-11-30 01:18:55 +00:00
Dan Abramov
6340d6cf2e
Delete Fiber test tracker (#11704) 2017-11-29 15:27:16 +00:00
Gabriel Kalani
b097a34eba refactor: scripts/error-codes (#11697)
Convert scripts/error-codes to use ES6 syntax
2017-11-29 01:13:12 +00:00
Brian Vaughn
9895a0ff63
Added ReactFeatureFlags shim for React Native (#11694)
* Added ReactFeatureFlags shim for React Native

* Fixed header license comment
2017-11-28 15:16:53 -08:00
Dan Abramov
5f9b4934a0
Fix CI fact uploading (#11693) 2017-11-28 22:39:43 +00:00
Brian Vaughn
53ab1948b5
Blacklist spyOn(). Add explicit spyOnProd() and spyOnDevAndProd() (#11691)
* Blacklist spyOn(). Add explicit spyOnProd() and spyOnDevAndProd()

* Wording tweak.

* Fixed lint no-shadow warning
2017-11-28 14:06:26 -08:00
Clement Hoang
edb2b3d3a7 Update bundle sizes for 16.2.0 release 2017-11-28 13:29:23 -08:00
rivenhk
8e876d244c Move ReactFiberTreeReflection to react-reconciler/reflection (#11683)
* Move ReactFiberTreeReflection to react-reconciler/reflection #11659

* Use * for react-reconciler

We don't know the latest local version, and release script currently doesn't bump deps automatically.

* Remove unused field

* Use CommonJS in entry point for consistency

* Undo the CommonJS change

I didn't realize it would break the build.

* Record sizes

* Remove reconciler fixtures

They're unnecessary now that we run real tests on reconciler bundles.
2017-11-28 16:57:22 +00:00
Dan Abramov
b89dc25e3f Record sizes 2017-11-28 16:03:30 +00:00
Jordan Tepper
7788bcdb26 Do not fail yarn linc for ignored file warning (#11615) (#11641)
* Add rule to ignore default handling of not linting hidden files

* Undo changes

* Add function to validate warnings

* Use validateWarnings when reporting linc command

* Restore files

* Contain code to line file
2017-11-28 13:54:46 +00:00
Alex Cordeiro
158f040d54 Lint untracked files with yarn linc (#11665)
* Lint untracked files with yarn linc (#11646)

* Run prettier on untracked files

* Unify code for listing changed files into shared utility
2017-11-27 23:30:36 +00:00
Clement Hoang
f6894dc48b
Set fragment export flags to true (#11672) 2017-11-27 13:09:15 -08:00
Dan Abramov
a65a8abc65
Use async/await in Rollup scripts (#11669) 2017-11-27 17:57:28 +00:00
Dan Abramov
018276976c Show nicer message on syntax errors 2017-11-27 15:55:46 +00:00
Dan Abramov
0c164bb485
Upload build on the same node where it happens (#11666) 2017-11-26 18:03:30 +00:00
Adrian Carolli
53ef71b8e8 Add bundle linting and tests to the release script (#11662)
* Add bundle linting and tests to the release script

 - add yarn lint-build
- use yarn lint-build in circle ci build.sh
- add yarn lint-build, yarn test-prod, yarn test-build, and yarn test-build-prod to the realse script

* Improve readability of release test messages

* Run prettier

* Updating package versions for release 16.2.0

* Seperate bundle specific tests

- Moved the runYarnTask into utils since its being used two files now
- Uncomment out checks I mistakenly committed

* Revert a bunch of version bump changes

Mistakenly commited by release script

* .js for consistency
2017-11-26 16:47:20 +00:00
Dan Abramov
f53bd033e7
Fix Jest call in the release script
Just running jest binary will no longer work
2017-11-25 16:13:28 +00:00
Dan Abramov
d235e61dc2
Don't reset error codes on CI build (#11655)
* Don't reset error codes on CI build

* Add an explanation
2017-11-25 02:23:13 +00:00
Dan Abramov
575982b96d
Forbid Haste in Jest (#11647) 2017-11-23 18:02:47 +00:00
Dan Abramov
fa7a97fc46
Run 90% of tests on compiled bundles (both development and production) (#11633)
* Extract Jest config into a separate file

* Refactor Jest scripts directory structure

Introduces a more consistent naming scheme.

* Add yarn test-bundles and yarn test-prod-bundles

Only files ending with -test.public.js are opted in (so far we don't have any).

* Fix error decoding for production bundles

GCC seems to remove `new` from `new Error()` which broke our proxy.

* Build production version of react-noop-renderer

This lets us test more bundles.

* Switch to blacklist (exclude .private.js tests)

* Rename tests that are currently broken against bundles to *-test.internal.js

Some of these are using private APIs. Some have other issues.

* Add bundle tests to CI

* Split private and public ReactJSXElementValidator tests

* Remove internal deps from ReactServerRendering-test and make it public

* Only run tests directly in __tests__

This lets us share code between test files by placing them in __tests__/utils.

* Remove ExecutionEnvironment dependency from DOMServerIntegrationTest

It's not necessary since Stack.

* Split up ReactDOMServerIntegration into test suite and utilities

This enables us to further split it down. Good both for parallelization and extracting public parts.

* Split Fragment tests from other DOMServerIntegration tests

This enables them to opt other DOMServerIntegration tests into bundle testing.

* Split ReactDOMServerIntegration into different test files

It was way too slow to run all these in sequence.

* Don't reset the cache twice in DOMServerIntegration tests

We used to do this to simulate testing separate bundles.
But now we actually *do* test bundles. So there is no need for this, as it makes tests slower.

* Rename test-bundles* commands to test-build*

Also add test-prod-build as alias for test-build-prod because I keep messing them up.

* Use regenerator polyfill for react-noop

This fixes other issues and finally lets us run ReactNoop tests against a prod bundle.

* Run most Incremental tests against bundles

Now that GCC generator issue is fixed, we can do this.
I split ErrorLogging test separately because it does mocking. Other error handling tests don't need it.

* Update sizes

* Fix ReactMount test

* Enable ReactDOMComponent test

* Fix a warning issue uncovered by flat bundle testing

With flat bundles, we couldn't produce a good warning for <div onclick={}> on SSR
because it doesn't use the event system. However the issue was not visible in normal
Jest runs because the event plugins have been injected by the time the test ran.

To solve this, I am explicitly passing whether event system is available as an argument
to the hook. This makes the behavior consistent between source and bundle tests. Then
I change the tests to document the actual logic and _attempt_ to show a nice message
(e.g. we know for sure `onclick` is a bad event but we don't know the right name for it
on the server so we just say a generic message about camelCase naming convention).
2017-11-23 17:44:58 +00:00
Dan Abramov
e949d57508
Remove global mocks by adding support for "suppressReactErrorLogging" property (#11636)
* Remove global mocks

They are making it harder to test compiled bundles.

One of them (FeatureFlags) is not used. It is mocked in some specific test files (and that's fine).

The other (FiberErrorLogger) is mocked to silence its output. I'll look if there's some other way to achieve this.

* Add error.suppressReactErrorLogging and use it in tests

This adds an escape hatch to *not* log errors that go through React to the console.
We will enable it for our own tests.
2017-11-23 01:15:22 +00:00
Dan Abramov
1cb6199d22
Consolidate all symbols in a single file (#11629)
* Consolidate all symbols in a single file

This reduces the code duplication as we have quite a few now.

* Record sizes
2017-11-22 18:08:22 +00:00
Dan Abramov
d1f6fbd22a Record sizes 2017-11-22 16:15:04 +00:00
Dan Abramov
6041f481b7
Run Jest in production mode (#11616)
* Move Jest setup files to /dev/ subdirectory

* Clone Jest /dev/ files into /prod/

* Move shared code into scripts/jest

* Move Jest config into the scripts folder

* Fix the equivalence test

It fails because the config is now passed to Jest explicitly.
But the test doesn't know about the config.

To fix this, we just run it via `yarn test` (which includes the config).
We already depend on Yarn for development anyway.

* Add yarn test-prod to run Jest with production environment

* Actually flip the production tests to run in prod environment

This produces a bunch of errors:

Test Suites: 64 failed, 58 passed, 122 total
Tests:       740 failed, 26 skipped, 1809 passed, 2575 total
Snapshots:   16 failed, 4 passed, 20 total

* Ignore expectDev() calls in production

Down from 740 to 175 failed.

Test Suites: 44 failed, 78 passed, 122 total
Tests:       175 failed, 26 skipped, 2374 passed, 2575 total
Snapshots:   16 failed, 4 passed, 20 total

* Decode errors so tests can assert on their messages

Down from 175 to 129.

Test Suites: 33 failed, 89 passed, 122 total
Tests:       129 failed, 1029 skipped, 1417 passed, 2575 total
Snapshots:   16 failed, 4 passed, 20 total

* Remove ReactDOMProduction-test

There is no need for it now. The only test that was special is moved into ReactDOM-test.

* Remove production switches from ReactErrorUtils

The tests now run in production in a separate pass.

* Add and use spyOnDev() for warnings

This ensures that by default we expect no warnings in production bundles.
If the warning *is* expected, use the regular spyOn() method.

This currently breaks all expectDev() assertions without __DEV__ blocks so we go back to:

Test Suites: 56 failed, 65 passed, 121 total
Tests:       379 failed, 1029 skipped, 1148 passed, 2556 total
Snapshots:   16 failed, 4 passed, 20 total

* Replace expectDev() with expect() in __DEV__ blocks

We started using spyOnDev() for console warnings to ensure we don't *expect* them to occur in production. As a consequence, expectDev() assertions on console.error.calls fail because console.error.calls doesn't exist. This is actually good because it would help catch accidental warnings in production.

To solve this, we are getting rid of expectDev() altogether, and instead introduce explicit expectation branches. We'd need them anyway for testing intentional behavior differences.

This commit replaces all expectDev() calls with expect() calls in __DEV__ blocks. It also removes a few unnecessary expect() checks that no warnings were produced (by also removing the corresponding spyOnDev() calls).

Some DEV-only assertions used plain expect(). Those were also moved into __DEV__ blocks.

ReactFiberErrorLogger was special because it console.error()'s in production too. So in that case I intentionally used spyOn() instead of spyOnDev(), and added extra assertions.

This gets us down to:

Test Suites: 21 failed, 100 passed, 121 total
Tests:       72 failed, 26 skipped, 2458 passed, 2556 total
Snapshots:   16 failed, 4 passed, 20 total

* Enable User Timing API for production testing

We could've disabled it, but seems like a good idea to test since we use it at FB.

* Test for explicit Object.freeze() differences between PROD and DEV

This is one of the few places where DEV and PROD behavior differs for performance reasons.
Now we explicitly test both branches.

* Run Jest via "yarn test" on CI

* Remove unused variable

* Assert different error messages

* Fix error handling tests

This logic is really complicated because of the global ReactFiberErrorLogger mock.
I understand it now, so I added TODOs for later.

It can be much simpler if we change the rest of the tests that assert uncaught errors to also assert they are logged as warnings.
Which mirrors what happens in practice anyway.

* Fix more assertions

* Change tests to document the DEV/PROD difference for state invariant

It is very likely unintentional but I don't want to change behavior in this PR.
Filed a follow up as https://github.com/facebook/react/issues/11618.

* Remove unnecessary split between DEV/PROD ref tests

* Fix more test message assertions

* Make validateDOMNesting tests DEV-only

* Fix error message assertions

* Document existing DEV/PROD message difference (possible bug)

* Change mocking assertions to be DEV-only

* Fix the error code test

* Fix more error message assertions

* Fix the last failing test due to known issue

* Run production tests on CI

* Unify configuration

* Fix coverage script

* Remove expectDev from eslintrc

* Run everything in band

We used to before, too. I just forgot to add the arguments after deleting the script.
2017-11-22 13:02:26 +00:00
Dan Abramov
7e7127387b
Run Jest tests with "development" environment (#11612) 2017-11-21 16:28:42 +00:00
Dan Abramov
40a176d859
Remove mentions of module map in Jest config (#11611) 2017-11-21 16:01:10 +00:00
Bryce Kalow
7e692fb496 Fixes typo in eslint script (#11607) 2017-11-21 02:46:57 +00:00
Brian Vaughn
dbf715c958
Read debugRenderPhaseSideEffects from GK (#11603)
* Forked ReactFeatureFlags for React Native to enable debugRenderPhaseSideEffects GK
* Changed debugRenderPhaseSideEffects in www feature flags to be runtime as well
2017-11-20 14:05:53 -08:00
Andy Davies
adcf980333 Re-enable UMD build for TestUtils (#11599)
Fixes #11111
2017-11-20 12:41:01 -05:00
Soo Jae Hwang
962042f827 Improve formatting of errors when building (#11456)
* Improve formatting of errors when building

* Remove undefined from the header when error.plugin is undefined

* Add babel-code-frame and syntax highlighting in error message

* Run yarn prettier and fix code format
2017-11-19 14:23:33 +00:00
Soo Jae Hwang
01a867b3ea Upgrade rollup dependency (#11591)
* Record build results before upgrading rollup

* Upgrade rollup and record new results.json
2017-11-18 13:49:40 +00:00
Brian Vaughn
7f68544f0d
New feature flags to help detect unexpected lifecycle side effects (#11587)
Added `debugRenderPhaseSideEffects` feature flag to help detect unexpected side effects in pre-commit lifecycle hooks and `setState` reducers.
2017-11-17 10:49:54 -08:00
Andrew Clark
9b36df86c6
Use requestIdleCallback timeout to force expiration (#11548)
* Don't call idle callback unless there's time remaining

* Expiration fixture

Fixture that demonstrates how async work expires after a certain interval.
The fixture clogs the main thread with animation work, so it only works if the
`timeout` option is provided to `requestIdleCallback`.

* Pass timeout option to requestIdleCallback

Forces `requestIdleCallback` to fire if too much time has elapsed, even if the
main thread is busy. Required to make expiration times work properly. Otherwise,
async work can expire, but React never has a chance to flush it because the
browser never calls into React.
2017-11-15 13:46:17 -08:00
Brian Vaughn
3322f6bf31
Re-add haste modules for ReactTypes and ReactNativeRTTypes shims (#11557)
* Re-add haste module for ReactNativeRTTypes

* Re-added ReactTypes @providesModule annotation as well

* Updated expected provides modules list

* Improved clarity of check_modules.sh error message

* Added ReactTypes to provides module whitelist
2017-11-15 08:17:15 -08:00
HardikModha
2d23a4563e Reading package.json safely in the build script by ignoring the system files. #11544 (#11546) 2017-11-13 18:21:17 +00:00
Johnson
200db83850 lint task: update scripts/eslint.js sharing code with linc.js; (#11518)
* (build infrastructure): unify lint and linc buid task;

* Fail on warnings

* Fail on warnings
2017-11-13 17:07:35 +00:00
Dan Abramov
cc5534a66d Update bundle sizes for 16.1.1 release 2017-11-13 16:11:15 +00:00
Brian Vaughn
ac0e670545
Release script tweaks (#11504)
* Added missing params object to execUnlessDry call

* Public package names are no longer hard-coded

* Added "v" prefix to git tag

* Show more accurate in-progress duration

* Properly bucket-bridage params

* Prettier

* Publish command logs stack with error
2017-11-09 16:29:51 +00:00
Clement Hoang
dc48cc38ea
Enable createRoot API in www (#11501) 2017-11-09 15:33:49 +00:00
Dan Abramov
c3a529325f Fix the release script 2017-11-09 15:16:24 +00:00
Dan Abramov
7d9b4ba35a Update bundle sizes for 16.1.0 release 2017-11-09 14:55:57 +00:00
Dan Abramov
17aa4d4682 Update bundle sizes for 16.1.0-rc release 2017-11-08 22:59:38 +00:00
Dan Abramov
c83596df65
Consolidate build process with GCC (#11483)
* Consolidate build process with GCC

* Record sizes

* Refactor header and footer wrapping

It is easier to understand if we just explicitly type them out.
2017-11-08 22:37:11 +00:00
Brian Vaughn
8a0285fb43
Release script follow-up (#11482)
* Add a timeout before querying npm right after publish

* Conditionally log some post publish steps

* Print ready-to-paste 'yarn add' instructions for CRA prerelease testing
2017-11-08 19:59:26 +00:00
Clement Hoang
94f44aeba7
Update prettier to 1.8.1 (#10785)
* Change prettier dependency in package.json version 1.8.1

* Update yarn.lock

* Apply prettier changes

* Fix ReactDOMServerIntegration-test.js

* Fix test for ReactDOMComponent-test.js
2017-11-07 18:09:33 +00:00
Dan Abramov
de48ad1646
Add react-call-return to publish list 2017-11-07 16:16:46 +00:00
Dan Abramov
0bd2c2bb3d Fix error reporting in release script 2017-11-07 15:03:08 +00:00
Dan Abramov
a653f910f8 Update bundle sizes for 16.1.0-beta.1 release 2017-11-07 14:53:31 +00:00
Dan Abramov
0acde04377 Update error codes for 16.1.0-beta.1 release 2017-11-07 14:53:31 +00:00
Kiho · Cham
acb268c577 minor typo (#11477)
concurently --> concurrently
2017-11-07 09:39:15 +00:00
Dan Abramov
2c228f15a0
Correctly replace shims using relative requires (#11472) 2017-11-06 16:53:13 +00:00
Dan Abramov
96914c98df
Split static and dynamic www feature flags (#11471) 2017-11-06 16:17:43 +00:00
Dan Abramov
3b27160f82
Put perf integration behind a feature flag (#11455)
* Enable User Timing API integration with a feature flag

* Expose a way to toggle user timing flag in www

* Update ReactNativeCSFeatureFlags.js

* Update ReactFeatureFlags.js
2017-11-06 16:07:08 +00:00
Dan Abramov
699496164d Record sizes 2017-11-06 15:34:42 +00:00
Dan Abramov
46f7b0d945
Fix dead code elimination for feature flags (#11453)
* Fix dead code elimination for feature flags

Turning flags into named exports fixes dead code elimination.

This required some restructuring of how we verify that flag types match up. I used the Check<> trick combined with import typeof, as suggested by @calebmer.

For www, we can no longer re-export `require('ReactFeatureFlags')` directly, and instead destructure it. This means flags have to be known at init time. This is already the case so it's not a problem. In fact it may be better since it removes extra property access in tight paths.

For things that we *want* to be dynamic on www (currently, only performance flag) we can export a function to toggle it, and then put it on the secret exports. In fact this is better than just letting everyone mutate the flag at arbitrary times since we can provide, e.g., a ref counting interface to it.

* Record sizes
2017-11-06 14:14:48 +00:00
Dan Abramov
b6a7beefe4
Use Rollup legacy mode for www builds (#11469) 2017-11-06 13:57:15 +00:00
Joe Lim
1d1f7038ec Handle prettier error (#11466)
* handle prettier error

* error if prettier fail
2017-11-06 11:17:51 +00:00
Joe Lim
40fbed5721 Use prettier api (#11458)
* use prettier-api

* fix string to boolean

* fix eslint

* fix typo

* cleanup

* use object assign
2017-11-05 21:06:08 +00:00
Dan Abramov
92b7b172cc
Use named exports in more places (#11457)
* Convert EventPlugin{Hub,Registry} to named exports

* Convert EventPluginUtils to named exports

* Convert EventPropagators to named exports

* Convert ReactControlledComponent to named exports

* Convert ReactGenericBatching to named exports

* Convert ReactDOMComponentTree to named exports

* Convert ReactNativeComponentTree to named exports

* Convert ReactNativeRTComponentTree to named exports

* Convert FallbackCompositionState to named exports

* Convert ReactEventEmitterMixin to named exports

* Convert ReactBrowserEventEmitter to named exports

* Convert ReactNativeEventEmitter to named exports

* Convert ReactDOMEventListener to named exports

* Convert DOMMarkupOperations to named exports

* Convert DOMProperty to named exports

* Add suppression for existing Flow violation

Flow didn't see it before.

* Update sizes
2017-11-05 11:58:36 +00:00
Joe Lim
7432013872 make linc script cross platform (#11447)
* make linc script cross platform

* fix typo

* attempt to fix long command error

* use eslint node api

* Update linc.js
2017-11-04 18:09:28 +00:00
Dan Abramov
646781b0b4 Tweak the bundle validation script
Exit on error, and minor nits.
2017-11-04 13:00:49 +00:00
Soo Jae Hwang
da86a4553b Validate built bundles exists (#11452) 2017-11-04 12:57:48 +00:00
Brian Vaughn
af08b5cbca
Release script follow-up work after 16.1.0-beta release (#11437)
* Build script creates git tag

* Build script post instructions print better relative paths

* Pre-release (<1.0) version numbers also include pre-release suffix (eg '-beta.0')

* Post-NPM-publish step properly handles minor rev comparison check

* Release script also updates @next tag when publishing @latest

* Fixed a typo. Improved inline comment.
2017-11-03 13:19:32 -07:00
Dan Abramov
61d35ce1f3 Record sizes and fix bundle lint 2017-11-03 18:01:53 +00:00
Brian Vaughn
1298e15f84 Update bundle sizes for 16.1.0-beta release 2017-11-02 15:34:31 -07:00
Brian Vaughn
8306553301 Update error codes for 16.1.0-beta release 2017-11-02 15:34:31 -07:00
Brian Vaughn
a181ba8707
Auto-install (or update) release script Yarn deps before running (#11434) 2017-11-02 15:21:28 -07:00
Dan Abramov
c0ee8df26c Record sizes 2017-11-02 19:54:58 +00:00
Dan Abramov
21d0c11523
Convert the Source to ES Modules (#11389)
* Update transforms to handle ES modules

* Update Jest to handle ES modules

* Convert react package to ES modules

* Convert react-art package to ES Modules

* Convert react-call-return package to ES Modules

* Convert react-test-renderer package to ES Modules

* Convert react-cs-renderer package to ES Modules

* Convert react-rt-renderer package to ES Modules

* Convert react-noop-renderer package to ES Modules

* Convert react-dom/server to ES modules

* Convert react-dom/{client,events,test-utils} to ES modules

* Convert react-dom/shared to ES modules

* Convert react-native-renderer to ES modules

* Convert react-reconciler to ES modules

* Convert events to ES modules

* Convert shared to ES modules

* Remove CommonJS support from transforms

* Move ReactDOMFB entry point code into react-dom/src

This is clearer because we can use ES imports in it.

* Fix Rollup shim configuration to work with ESM

* Fix incorrect comment

* Exclude external imports without side effects

* Fix ReactDOM FB build

* Remove TODOs I don’t intend to fix yet
2017-11-02 19:50:03 +00:00
Dan Abramov
fbf617a263
Update Rollup (#11427)
* Update Rollup

* Strip "use strict" in individual modules

* Record sizes
2017-11-02 16:56:12 +00:00
Dan Abramov
f302a6a334 Record sizes 2017-11-02 16:26:54 +00:00
Dan Abramov
4008f6d37d
Validate built bundles with a few ESLint rules (#11432) 2017-11-02 15:50:25 +00:00
Dan Abramov
9d75a62d14
Depend on prop-types/checkPropTypes, not prop-types itself (#11420)
* Remove prop-types/checkPropTypes reimplementation

* Remove renderer dependency on top-level PropTypes

This annotation is unnecessary because we already warn for bad event listener types.

* Record sizes
2017-11-01 10:57:24 +00:00
Dan Abramov
9f2b15909a Record sizes 2017-10-31 22:14:22 +00:00
Márcio Vicente
d61af82390 Removing dot to avoid redirect to facebook.com (#11400)
* Removing dot to avoid redirect to facebook.com

* Changing phrase instead of using

* Tweak test

* Reset unrelated file
2017-10-30 14:16:18 +00:00
Sebastian Markbåge
696908f496
[CS] Implement Some Stuff (#11390)
* Implement CS first take

This is using a pure JS API. This should probably switch to native hooks
at some later point but I'll start ironing out issues at this level first.

* Use async scheduling by default

The scheduled callback gets called immediately in render with infinite
time for now. Later this will be per root and abortable.

* Fix up the type signature of the ReactNativeCSType export

* Add escape hatch for special cased children

Working around the fact that we can't map arbitrary children slots. Just
the "children" prop.

* Readd providesModule for ReactNativeCSTypes

* Fix lint

* Fix ReactNativeTypes providesModule and CI check

* Special case a parent instance that doesn't have a props object

CSCustom can be anything here. Ugly but whatevs.

* Don't forget to store stateUpdater so that we can trigger updates

* Fix test
2017-10-27 20:05:34 -07:00
Dan Abramov
707ca7f492 Update Jest and remove hacks (#11372)
* Update Jest

* Remove hacks for Jest + Workspace integration

They were fixed by https://github.com/facebook/jest/pull/4761.

* Use relative requires in tests relying on private APIs

I changed them to absolute to work around a Jest bug.
The bug has been fixed so I can revert my past changes now.
2017-10-26 15:15:24 +01:00
Brian Vaughn
c86ae4b46f Added naive scheduleDeferredCallback implementation for RN (#11362)
* Added naive scheduleDeferredCallback implementation for RN

* Fixed ReactNative shim's expected @provideModule
2017-10-25 14:13:34 -07:00
Dan Abramov
2c0a8fb99e Add react-call-return package (#11364) 2017-10-25 22:23:55 +03:00
Dan Abramov
087c48bb36 Reorder imports (#11359)
* Reorder imports

* Record sizes
2017-10-25 21:07:54 +03:00
Dan Abramov
f1c6488f1b Forbid adding new files with @providesModule (#11361)
* Forbid adding new files with @providesModule

* Turn off Haste mode in Flow config

* chmod a+x

* Try to fix bash

* Try to fix bash again
2017-10-25 19:50:34 +03:00
Brian Vaughn
72ba8db504 Added unit test that would have caught the recent error code transform regression (#11356)
* Added an automated test that would have caught the recent error code transform bug

* Renamed dev-expression-with-codes test to replace-invariant-error-codes

* Formatting nit
2017-10-25 08:21:55 -07:00
Dan Abramov
3ad5bd803f Expose TapEventPlugin on the www bundle (#11360) 2017-10-25 17:37:49 +03:00
Dan Abramov
1eed302d34 Drop Haste (#11303)
* Use relative paths in packages/react

* Use relative paths in packages/react-art

* Use relative paths in packages/react-cs

* Use relative paths in other packages

* Fix as many issues as I can

This uncovered an interesting problem where ./b from package/src/a would resolve to a different instantiation of package/src/b in Jest.

Either this is a showstopper or we can solve it by completely fobbidding remaining /src/.

* Fix all tests

It seems we can't use relative requires in tests anymore. Otherwise Jest becomes confused between real file and symlink.
https://github.com/facebook/jest/issues/3830

This seems bad... Except that we already *don't* want people to create tests that import individual source files.
All existing cases of us doing so are actually TODOs waiting to be fixed.

So perhaps this requirement isn't too bad because it makes bad code looks bad.

Of course, if we go with this, we'll have to lint against relative requires in tests.
It also makes moving things more painful.

* Prettier

* Remove @providesModule

* Fix remaining Haste imports I missed earlier

* Fix up paths to reflect new flat structure

* Fix Flow

* Fix CJS and UMD builds

* Fix FB bundles

* Fix RN bundles

* Prettier

* Fix lint

* Fix warning printing and error codes

* Fix buggy return

* Fix lint and Flow

* Use Yarn on CI

* Unbreak Jest

* Fix lint

* Fix aliased originals getting included in DEV

Shouldn't affect correctness (they were ignored) but fixes DEV size regression.

* Record sizes

* Fix weird version in package.json

* Tweak bundle labels

* Get rid of output option by introducing react-dom/server.node

* Reconciler should depend on prop-types

* Update sizes last time
2017-10-25 02:55:00 +03:00
Dan Abramov
793a28d698 Use simple invariant in case of missing error codes (#11350) 2017-10-24 09:11:03 -07:00
Dan Abramov
d5f26b041e Rename Haste modules (#11349) 2017-10-24 17:26:07 +03:00
Dan Abramov
4ceb5a4aa0 Record sizes 2017-10-23 15:06:36 +01:00
Andrew Clark
2e4663f616 Split performWork into renderRoot and commitRoot (#11264)
* Split performWork into renderRoot and commitRoot

It turns out that the scheduler is too coupled to how the DOM renderer
works. Specifically, the requestIdleCallback model, and how roots are
committed immediately after completing. Other renderers have different
constraints for when to yield and when to commit work.

We're moving towards a model where the scheduler only works on a single
root at a time, and the render phase and commit phase are split into
distinct entry points. This gives the renderer more control over when
roots are committed, coordinating multiple roots, deferring the commit
phase, batching updates, when to yield execution, and so on.

In this initial commit, I've left the renderers alone and only changed
the scheduler. Mostly, this involved extracting logic related to
multiple roots and moving it into its own section at the bottom of the
file. The idea is that this section can be lifted pretty much as-is
into the renderers. I'll do that next.

* Remove FiberRoot scheduleAt

Isn't actually used anywhere

* Make the root schedule a linked list again

Since this still lives inside the renderer, let's just use the
FiberRoot type. The FiberRoot concept will likely be lifted out
eventually, anyway.

* commitRoot should accept a HostRoot

This way it's less reliant on the alternate model

* Unify branches

* Remove dead branch

onUncaughtError is only called while we're working on a root.

* remainingWork -> remainingExpirationTime

I was wary of leaking NoWork but mixing numbers and null is worse so
let's just do it until we think of something better.

* Rename stuff
2017-10-20 13:22:29 -07:00
Brian Vaughn
c7d28a0136 Fix build/sync script for RN/CS/RT (#11302)
While testing some changes to RN, I noticed that the '--sync-fbsource' flag had been broken recently by things being moved around and the newly-added CS renderer. Fixed it up.
2017-10-20 12:58:53 -07:00
Dan Abramov
e779c39dfe Flatten everything (#11304)
* Flatten everything

* Fix ReactDOMServerNode build

* Fix native builds
2017-10-20 20:14:52 +01:00
Brian Vaughn
fa5adb3bc4 Release script no longer auto-updates peerDependencies react version (#11292)
* Release script ensures peer dep matches release major version, but otherwise no longer auto-updates them to exactly match the release version.
* f
2017-10-20 08:53:15 -07:00
Brian Vaughn
845b1afdc5 Rollup script can now extract error codes and build in a single pass (#11291)
* Rollup build scripts can now extract error codes while building

* I can't spell ternary
2017-10-20 08:35:33 -07:00
Dan Abramov
ab853e6f3e Group event code together and forbid cross-client/server imports (#11298)
* react-dom/src/syntheticEvents => events, and put plugins into it

* Flatten react-dom/src/shared

* Split react-dom/src/client/utils into event/ and root client folder

Makes it clearer what is used by what.

* Strictly separate modules that can be imported by client and server
2017-10-20 13:51:50 +01:00
Dan Abramov
c080537a7b Flatten the shared/ folder (#11297)
* shared/src -> shared

It's not a real package and doesn't even have package.json.
This will also make importing less weird if we drop Haste.

* Get rid of shared/utils

Moved event-specific into shared/event.
Moved rest to the root since distinction has always been pretty arbitrary.

* Fix references to old shared/src paths
2017-10-20 12:59:57 +01:00
Dan Abramov
313611572b Reorganize code structure (#11288)
* Move files and tests to more meaningful places

* Fix the build

Now that we import reconciler via react-reconciler, I needed to make a few tweaks.

* Update sizes

* Move @preventMunge directive to FB header

* Revert unintentional change

* Fix Flow coverage

I forgot to @flow-ify those files. This uncovered some issues.

* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down

Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down

Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime

Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink

Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out

Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown

And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right

And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-19 19:50:24 +01:00
Dan Abramov
1a81be4625 Include component stack in more places, including SSR (#11284)
* Include component stack in more places, including SSR

* Forbid including reconciler code into the server bundle

* Tighten up the Flow annotation

* Fix lint

* Gosh Prettier
2017-10-19 17:43:40 +01:00
Dan Abramov
c625b868f5 Only renderers should depend on reconciler code (#11281)
* Only renderers should depend on reconciler code

* Remove react-art dependency on react-dom modules

They share ReactDOMFrameScheduling so I moved it to shared.
2017-10-19 15:52:45 +01:00
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
Dan Abramov
d9c1dbd617 Use Yarn Workspaces (#11252)
* Enable Yarn workspaces for packages/*

* Move src/isomorphic/* into packages/react/src/*

* Create index.js stubs for all packages in packages/*

This makes the test pass again, but breaks the build because npm/ folders aren't used yet.
I'm not sure if we'll keep this structure--I'll just keep working and fix the build after it settles down.

* Put FB entry point for react-dom into packages/*

* Move src/renderers/testing/* into packages/react-test-renderer/src/*

Note that this is currently broken because Jest ignores node_modules,
and so Yarn linking makes Jest skip React source when transforming.

* Remove src/node_modules

It is now unnecessary. Some tests fail though.

* Add a hacky workaround for Jest/Workspaces issue

Jest sees node_modules and thinks it's third party code.

This is a hacky way to teach Jest to still transform anything in node_modules/react*
if it resolves outside of node_modules (such as to our packages/*) folder.

I'm not very happy with this and we should revisit.

* Add a fake react-native package

* Move src/renderers/art/* into packages/react-art/src/*

* Move src/renderers/noop/* into packages/react-noop-renderer/src/*

* Move src/renderers/dom/* into packages/react-dom/src/*

* Move src/renderers/shared/fiber/* into packages/react-reconciler/src/*

* Move DOM/reconciler tests I previously forgot to move

* Move src/renderers/native-*/* into packages/react-native-*/src/*

* Move shared code into packages/shared

It's not super clear how to organize this properly yet.

* Add back files that somehow got lost

* Fix the build

* Prettier

* Add missing license headers

* Fix an issue that caused mocks to get included into build

* Update other references to src/

* Re-run Prettier

* Fix lint

* Fix weird Flow violation

I didn't change this file but Flow started complaining.
Caleb said this annotation was unnecessarily using $Abstract though so I removed it.

* Update sizes

* Fix stats script

* Fix packaging fixtures

Use file: instead of NODE_PATH since NODE_PATH.
NODE_PATH trick only worked because we had no react/react-dom in root node_modules, but now we do.

file: dependency only works as I expect in Yarn, so I moved the packaging fixtures to use Yarn and committed lockfiles.
Verified that the page shows up.

* Fix art fixture

* Fix reconciler fixture

* Fix SSR fixture

* Rename native packages
2017-10-19 00:22:21 +01:00
Dan Abramov
dee604dbe2 Add static injection for feature flags (#11269)
* Replace ReactDOMFeatureFlags with ReactFeatureFlags

* Add static injection for feature flags
2017-10-18 18:40:52 +01:00
Dan Abramov
c539be0515 Remove unused bundle flag (#11267) 2017-10-18 14:00:44 +01:00
Dan Abramov
066f02281b Put NativeCS bundles into their own directory (#11266) 2017-10-18 13:56:07 +01:00
Dan Abramov
daf75f0671 Record sizes 2017-10-17 22:54:11 +01:00
Brian Vaughn
90370f28ff Removed test utils dependency on test renderer from bundle config (#11259) 2017-10-17 14:31:12 -07:00
Dan Abramov
1ef250d881 Move Flow environment into scripts/flow (#11249)
* Move flow environment into scripts/flow

* Run Prettier
2017-10-17 14:20:00 +01:00
Dan Abramov
49d4381c67 Simplify Jest config a little bit (#11242)
* Inline getTestDocument into test cases

* Remove mention of mock file we do not use

* Remove unused configuration entries

* Move eslint-rules package into the scripts/ folder
2017-10-16 23:17:00 +01:00
Brian Vaughn
9ed78ad277 Tweaked wording of release script README 2017-10-16 15:02:41 -07:00
Brian Vaughn
c371c152ab Release script (#11223)
* First chunk of new release script

* Re-ordered build steps to combine error codes and releases

* Reorganized build files; added stub publish script

* First pass at publis script. Also collect and print dry-run commits/publish commands.

* Deleted old react-release-manager scripts

* Cleaned up release package.json

* Basic README instructions

* Removed unnecessary 'async' keyword from a method

* Wordsmithing

* Tweaked README

* Renamed build -> build-commands and publish -> publish-commands to avoid conflict with .gitignore

* Bump pre-release package versions differently

* Prettier

* Improved CircleCI API token setup instructions message

* Lint fix

* Typofix
2017-10-16 15:01:14 -07:00
Dan Abramov
f8134966c9 Record sizes 2017-10-16 20:51:36 +01:00
Andrew Clark
3ffb5d0876 Deterministic updates (#10715)
* Deterministic updates

High priority updates typically require less work to render than
low priority ones. It's beneficial to flush those first, in their own
batch, before working on more expensive low priority ones. We do this
even if a high priority is scheduled after a low priority one.

However, we don't want this reordering of updates to affect the terminal
state. State should be deterministic: once all work has been flushed,
the final state should be the same regardless of how they were
scheduled.

To get both properties, we store updates on the queue in insertion
order instead of priority order (always append). Then, when processing
the queue, we skip over updates with insufficient priority. Instead of
removing updates from the queue right after processing them, we only
remove them if there are no unprocessed updates before it in the list.

This means that updates may be processed more than once.

As a bonus, the new implementation is simpler and requires less code.

* Fix ceiling function

Mixed up the operators.

* Remove addUpdate, addReplaceState, et al

These functions don't really do anything. Simpler to use a single
insertUpdateIntoFiber function.

Also splits scheduleUpdate into two functions:

- scheduleWork traverses a fiber's ancestor path and updates their
  expiration times.
- scheduleUpdate inserts an update into a fiber's update queue, then
  calls scheduleWork.

* Remove getExpirationTime

The last remaining use for getExpirationTime was for top-level async
updates. I moved that check to scheduleUpdate instead.

* Move UpdateQueue insertions back to class module

Moves UpdateQueue related functions out of the scheduler and back into
the class component module. It's a bit awkward that now we need to pass
around createUpdateExpirationForFiber, too. But we can still do without
addUpdate, replaceUpdate, et al.

* Store callbacks as an array of Updates

Simpler this way.

Also moves commitCallbacks back to UpdateQueue module.

* beginUpdateQueue -> processUpdateQueue

* Updates should never have an expiration of NoWork

* Rename expiration related functions

* Fix update queue Flow types

Gets rid of an unneccessary null check
2017-10-13 17:21:25 -07:00
Sebastian Markbåge
36a2afccc5 [CS] Split Host Config Out into a Mutable or Immutable Mode (#11213)
* CS renderer

Because we didn't have enough RN experiments. I want to add one more.

* Split out hydration from the host config object

This makes it easier to do feature detection on the configuration.

* Move mutation host config to separate optional object

* Refs and life-cycles should happen even in immutable mode

* Unmount components even in non-mutation mode

This is the same as committing deletions but instead of finding host
components to delete, it only invokes componentWillUnmount and detaching
of refs.

* Add persistent updates API

This mode will use a clone based API instead of mutating host instances.

Needs implementation still.

It's awkward that there can be more than one child inserted into the root.
So we need a new API to create a "root" instance so that we can update it
atomically. Alternatively we could keep the mutable API for containers
and assume that most use cases would only have a single root.

* Package up CS renderer

* Fix reconciler package fixture
2017-10-13 14:29:59 -07:00
Dustan Kasten
111731dedd React reconciler package (#10758)
* Initial commit of react-reconciler bundle

* I think it’s working 🙀

* React reconciler: slightly better description and README

* Drop react-reconciler version to an unstable release number

* Convert to moduleType enum and fix packaging

* eslint

* s/Renderer/Reconciler in docs

* yarn prettier

* change names of things in the react-reconciler readme

* change predicate

* rollup: flip object-assign shimming check

* copy noop renderer into react-reconciler fixture

* Change reconciler fixture test

* prettier

* Remove a bunch of Noop test renderer

* Delete a bunch of stuff we don’t care about for reconciler teesting. Add flow pragmas for future flow pragma testing

* Remove PATENTS

* Update Reconciler fixture docs

* ReactDOMUnstableNativeDependencies should be ISOMORPHIC

* Inline fixture renderer

* Make it "RENDERER"

* There is no UMD build. It also doesn't need propTypes.

* Tweak how the reconciler is built

* Record sizes

* Update README.md
2017-10-11 19:29:26 +01:00
Dan Abramov
6c592deac9 Record sizes 2017-10-11 19:06:43 +01:00
Brian Vaughn
8b3ad851fd Update build scripts to put RN-RT files in the right places (#11183) 2017-10-10 13:44:43 -07:00
Dan Abramov
b2101cb328 Record sizes 2017-10-10 16:06:05 +01:00
Sebastian Markbåge
5744571140 [RT] More predictable things (#11139)
* Inject the right event emitter

Previously this was injecting the ReactNativeEventEmitter even though
we want the ReactNativeRTEventEmitter.

RCTEventEmitter is also just an abstraction around BatchedBridge that
registers a single name. We can't register more than one with it. Removed
that abstraction for now so we don't have to add it back into the RN repo.

* Unify appendChildToDetachedParent and appendChild, separate root

Merge appendChildToDetachedParent and appendChild. We don't need the distinction.

We do however need a separate notion for the root container.
Calling this `appendChildToContext` since Context has a meaning here.

* Add a simple shallow comparison so that we don't send updates for equal props

This still sends all props if any differs. Not sure we'll want that but I
think so.

* Add BatchedBridge to bundle externals

* Lint
2017-10-06 19:08:22 -07:00
Brian Vaughn
ebb1d316bd Delete documentation and website source (#11137)
* Deleted docs folder

* Deleted www folder

* Remove Netlify website build command

* Removed refs to docs and www from ESlint config

* Removed refs to www/docs from Flow config

* Removed unnecessary .gitignore config

* Updated license check to remove refs to docs

* Removed gh-pages specific portions of Circle build scripts
There may be more that we can remove (eg set_up_github_keys.sh) but I'm not positive

* Removed docs specific license
2017-10-06 10:18:05 -07:00
Dan Abramov
7d3b44bf37 Add production bundles for Test and Shallow renderers (#11112)
* Add production bundles for Test and Shallow renderers

* Remove unused/broken file from test renderer

* Add production bundle for TestUtils
2017-10-05 15:26:52 +01:00
Sophie Alpert
dffb206a04 Remove references to PATENTS that crept in (#11091) 2017-10-04 12:40:41 -07:00
Sebastian Markbåge
761decb352 Fork React Native render into an "RT" renderer (#11072)
This is an experimental new protocol for some experiments we want to play
with. To make that easier, I'm just going to fork it.

This experiment won't use the event system so I by-pass it and just invoke
functions on the props object for now.

I also fork the UIManager into a new RTManager.
2017-10-03 18:48:23 -04:00
Brian Vaughn
07b1da8964 Removed PooledClass (and tests) (#11053) 2017-10-02 16:54:40 -07:00
Dan Abramov
2fdb84d999 Add legacy JSFiddle files (#11030)
* Add legacy JSFiddle files

* Exclude from Prettier
2017-10-02 16:48:59 +01:00
Dan Abramov
e3a1c6616f Update sizes 2017-10-02 14:31:39 +01:00
Dan Abramov
c1ea3cda30 Delete DOMProperty www shim
It's unused
2017-10-02 13:49:53 +01:00
skratchdot
0344f7ad55 [Gatsby] "https://facebook.github.io/react/" -> "https://reactjs.org/" (#10970) 2017-09-29 18:43:22 -07:00
Dan Abramov
366c4bb5cb Don't let UMD create extraneous global variables (#10935) 2017-09-29 12:48:33 +01:00
Brian Vaughn
96fde8a09a Add new docs website (#10896)
Adds a new docs website, built with Gatsby JS, to replace the old Jekyll site. Source code for the new site lives in /www (although markdown and YML data still comes from the legacy /docs folder).

Changes to either markdown or website source code can be previewed on Netlify. The react-js bot should automatically add comments to each PR with preview links. (This preview is generated by running the newly-added yarn build:docs command in the root package.json.)

The majority of the changes in this PR are contained within the new /www directory. However some minor modifications have been made to existing content in the /docs directory:

* Modified frontmatter author block to always be an array
* Small markdown formatting tweaks
2017-09-28 10:18:04 -07:00
Dan Abramov
aad0970192 Remove Stack (part 1, safe: unused files and tests) (#10794)
* Remove Fiber Jest project

* Remove Stack reconciler and ReactDOMStack code

* Fix tests depending on Stack internals

* Fix Flow
2017-09-27 15:15:20 +01:00
Leslie
ccb2f82a83 Fix a few typos (#10860) 2017-09-27 11:13:21 +01:00
Andrew Clark
7ccfbfc25d Update error codes 2017-09-26 08:44:21 -07:00
Sophie Alpert
b765fb25eb Change license and remove references to PATENTS
Only remaining references:

```
docs/_posts/2014-10-28-react-v0.12.md
51:You can read the full text of the [LICENSE](https://github.com/facebook/react/blob/master/LICENSE) and [`PATENTS`](https://github.com/facebook/react/blob/master/PATENTS) files on GitHub.

docs/_posts/2015-04-17-react-native-v0.4.md
20:* **Patent Grant**: Many of you had concerns and questions around the PATENTS file. We pushed [a new version of the grant](https://code.facebook.com/posts/1639473982937255/updating-our-open-source-patent-grant/).

src/__mocks__/vendor/third_party/WebComponents.js
8: * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
```
2017-09-25 18:17:44 -07:00
Sophie Alpert
d63249d034 Update license headers BSD+Patents -> MIT
Did find and replace in TextMate.

```
find: (?:( \*)( ))?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+(?:this source tree|the same directory)\.$
replace: $1$2Copyright (c) $3-present, Facebook, Inc.\n$1\n$1$2This source code is licensed under the MIT license found in the\n$1$2LICENSE file in the root directory of this source tree.
```
2017-09-25 18:17:44 -07:00
Dan Abramov
4c45058355 Record sizes 2017-09-24 17:44:13 +02:00
Brian Vaughn
836d1c5d0c ReactNativeBridgeEventPlugin supports lazily-registered event types (#10679)
* ReactNativeBridgeEventPlugin supports lazily-registered event types
This accompanies changes on the native side to now specify which event types each view manager supports as part of its view config. Ultimately the goal is to lazily initialize view managers on the native side as well.
* Bubbling and direct attributes are optional on view config
This should help ease transition for pre-existing JS-only components.
2017-09-14 14:55:32 -07:00
Dan Abramov
03443a2e23 Record sizes 2017-09-14 14:04:11 +01:00
Dan Abramov
07f129bec2 Update error codes 2017-09-14 13:37:26 +01:00
Dan Abramov
bacaf60e15 Update sizes 2017-09-14 13:27:27 +01:00
Dan Abramov
af36a05d5a Fix FB isomorphic build (#10704)
* Freeze bundle configs before the build

This ensures we don't accidentally mutate it.

* Fix config mutation during the build uncovered by freeze

* Fix FB isomorphic build by marking object-assign as an external

* Bye bye redundant check
2017-09-14 01:24:31 +01:00
Dan Abramov
43dae749aa Stop exposing shallow renderer from TestUtils (#10682)
* Stop exposing ShallowRenderer from TestUtils

* Record sizes

* Lint
2017-09-12 19:29:28 +01:00
Dan Abramov
f74981beee Share Object.assign polyfill between UMD builds (#10671) 2017-09-11 19:22:59 +01:00
Dan Abramov
6552519a21 Update sizes 2017-09-11 16:51:58 +01:00
François Chalifour
83b63e5ff8 Fix test names in ReactDOMComponent-test (#10113)
* Fix test names in ReactDOMComponent-test

* Run record-tests script for Fiber
2017-09-10 14:52:09 -07:00
Nikoloz Buligini
c294b0995a adds missing else clause (#10660) 2017-09-10 12:42:53 -07:00
guoyong yi
8b7082eced Add license headers on build bundles (#10490)
* Add license headers on build bundles

* Add the filename IMO to header

* Preserve headers in production bundles

* Use ECMASCRIPT5_STRICT to preserve "use strict"
2017-09-07 19:38:16 +01:00
Flarnie Marchan
49c8d717a0 16.0.0-rc.1 (#10630) 2017-09-06 15:43:22 -07:00
Flarnie Marchan
8e4654015a Update error codes and results.json (#10619)
* Update results.json

**what is the change?:**
Ran the build after updating Yarn lockfile and recorded latest build
size results.

**why make this change?:**
Let's get an idea of bundle size at this point, when we are preparing
the 16.0 RC.

**test plan:**
NA

**issue:**
https://github.com/facebook/react/issues/8854

* Update error codes

https://github.com/facebook/react/tree/master/scripts/release-manager#update-the-error-codes
2017-09-06 11:11:19 -07:00
Nikita Lebedev
a8845587a3 Fix typo in script function name (#10611) 2017-09-05 10:28:34 -07:00
Dan Abramov
9f772abdc6 Update sizes 2017-08-31 22:35:42 -07:00
Brian Vaughn
e34ac7c066 Embed ReactNative event types in JavaScript (#10567)
* ReactNative doesn't query UIManager for native event types
This is a pre-req to unblock Prepack optimiations for ReactNative apps
* Replaced mock ReactNativeEventTypes with mock Platform
* Added Platform.OS to RN host hooks Flow types
2017-08-31 15:27:54 -07:00
Brian Vaughn
5ee72dcd82 Add --sync-www flag to build script (#10571) 2017-08-30 09:38:14 -07:00
Brian Vaughn
99171321c3 Lint command fails if there are any warnings (#10572)
You get a lint failure! You get a lint failure! Eeeeverybody gets a lint failure!
2017-08-30 08:03:17 -07:00
Andrew Clark
b9c8e4e9df Remove UMD builds from fixture directory (#10547) 2017-08-25 17:17:31 -07:00
Andrew Clark
2d5c4542df Update eslintignore and prettier config to ignore UMD builds of React 2017-08-25 11:35:43 -07:00
Andrew Clark
5fd942a03c Move attribite-behavior to fixtures 2017-08-25 10:40:09 -07:00
Andrew Clark
b775e74e4e Use monospace font-family 2017-08-25 10:37:46 -07:00
Andrew Clark
888c537121 Wrap string values in quotes
All other types are formatted as as <type: param>
2017-08-25 10:37:46 -07:00
Andrew Clark
5f71165486 Add table of attribute behavior (#10536)
* [WIP] Table of attribute behavior

* getAttribute helper

* add getters for attributes V-Z

* More special cases

* Add getters for more attributes

* Add tagName to attribute config

* Switch default accessor to getProperty instead of getAttribute

* Add containerTagName and tagName config

* Compare result to default value

* Add overrideStringValue config option

* add section for Sebastian and update a couple more attributes

* 'array with string' should use string override, too

* Add additional value types

Strings on, off, true, false

* more attribute updates

* More attributes

* Remove old directory

* add more attribute configs

* More attributes

* just a couple more attribute updates

* More attributes

* Fix the seb parts

* Fix the seb parts

# Conflicts:
#	scripts/attribute-behavior/src/App.js

* More attributes

* Prettier

* More attributes

* More attributes

* Fix some bugs in seb's set

* Fix the rest of flarnie's section

* More attributes

* Prettier

* Finish my section (Andrew)

* Compare against UMD build of master

Once we get past MVP stage we can hook this up to the build system so
these files are automatically copied over.

* Fix attributes that don't have compatible properties

Avoid all undefined reads.

* Test multiple input types

Tests different input types and valueAsNumber property. This value is often
NaN. To compare that we also need to switch to Object.is.

* Ignore checked in copies of React 15 bundles in attribute fixture

**what is the change?:**
We checked in bundles of React v15 to run comparisons of attribute
behavior on DOM elements between 15 and 16.

This commit tells prettier and eslint to ignore those files, and fixes a
prettier lint in one other file from that fixture.

**why make this change?:**
To get CI passing.

**test plan:**
`yarn prettier` doesn't change anything, eslint passes

**issue:**

* update README for attribute table fixture

* run prettier again
2017-08-25 10:03:30 -07:00
Brian Vaughn
2fa38ac1cc Delete ReactNativeStack 🎉 🎉 🎉 (#10511)
* Removed createReactNativeComponentClassStack and renamed createReactNativeComponentClassFiber => createReactNativeComponentClass

* Removed findNumericNodeHandleStack and renamed findNumericNodeHandleFiber => findNumericNodeHandle

* Renamed ReactNativeFiberEntry => ReactNativeEntry

* Removed all references to ReactNativeFeatureFlags and RN stack

* Removed severl RN modules that are no longer used

* Renamed ReactNativeEntry => ReactNativeFiberEntry for now. We'll probably remove 'fiber' references later

* Update build results json

* Deleted snapshot

* Re-add accidentally deleted test

* Remove now-unnecessary hack in test

* Fix lint

* RN findNodeHandle no longer adds props directly to read-only owner (#10520)

* Added ReactNativeMount-test snapshot for 'renders and reorders children' test
2017-08-23 15:53:55 -07:00
Brian Vaughn
e464cf2def Removed ReactNativeFeatureFlag shim from RN bundle (#10472) 2017-08-18 08:26:11 -07:00
Ian Sutherland
7f6b940919 Added unit tests for creating an element with a ref in a constructor. Only set ReactCurrentOwner.current in dev mode when the component has no constructor. (#10025) 2017-08-15 11:21:49 +02:00
Brandon Dail
5ff5700625 Add explicit invariant when ReactDOM is loaded w/o React (#10449) 2017-08-13 13:16:13 -05:00
Sasha Aickin
4d08914985 Fix for #10388. Renames renderToStream to renderToNodeStream. (#10425) 2017-08-10 12:23:00 -07:00
Brian Vaughn
8b1b0720cc Wrap warning() calls in a DEV check for RN_* builds too (#10428)
* Wrap warning() calls in a DEV check for RN_* builds too.
* Wrapped several warning() imports and calls in if-DEV checks.
* Removed a useless variable (allTypesByEventName) and loop from ReactNativeBridgeEventPlugin.
2017-08-10 08:41:51 -07:00
Dominic Gannaway
e97143cca5 Use Closure Compiler for UMD/Node bundles instead of Uglify (#10236)
* Use GCC instead of Uglify for UMD/NODE bundles

* Prettier run

* Fixes fixtures that were alterated by Pretter and trailing function commas

* prettier on prettier

* updated prettier config

* altered prettier config slightly

* Reverted prettier changes

* updated results.json
2017-08-10 11:12:29 +01:00
Dominic Gannaway
b9e92c6747 Moved around package dependencies fixes #10335 (#10424) 2017-08-09 18:47:52 +01:00
Mateusz Burzyński
9166cf9b8d Add test for duplicate events with nested dispatch 2017-08-09 09:30:08 -05:00
Brian Vaughn
c3718c48f0 16 beta 5 version bump and results JSON 2017-08-08 10:25:25 -07:00
Brian Vaughn
9ebd0c9e9a Updated packages and results JSON for 16 beta 4 2017-08-08 09:08:17 -07:00
Dan Abramov
327d126392 Move PooledClass to Stack folder (#10386) 2017-08-04 19:10:07 +01:00
Brandon Dail
755724a24c Implement event-specific pooling for SyntheticEvent (#10237)
* Remove PooledClass from FallbackCompositionState

The only module that uses FallbackCompositonState is BeforeInputEventPlugin. The way its structured means there can only be a single instance of FallbackCompositionState at any given time (stored in a local variable at the top-level) so we don't really need pooling here at all. Instead, a single object is now stored in FallbackCompositionState, and access (initializing, reseting, getting data) is gaurded by the exported helper object.

* Use new FallbackCompositionState API in BeforeInputEventPlugin

* Implement event-specific pooling in SyntheticEvent

* Remove PooledClass from TopLevelCallbackBookKeeping

* Update results.json

* Add pooled event test fixtures (#1)

* Fix fixture lint
2017-08-04 18:24:48 +01:00
Devedse
25894e82c2 Wop optimized this repository (#10374)
The Web Optimization Project optimized this repository. This commit contains the optimized files in this repository.
2017-08-04 14:41:38 +01:00
Brian Vaughn
230d41218e Built 16.0.0 beta 3. Updated versions, results.json, and error codes 2017-08-03 16:05:28 -07:00
Dan Abramov
c1833b4b7e Fix CI maybe 2017-08-03 00:59:40 +01:00
Dan Abramov
fc86ef0f3d Use single entry point for SSR via browser field (#10362)
* Use single entry point for SSR via browser field

* Add server.browser entry point and smoke tests

* Tweak bundle naming

* Fix import

* Re-record

* Fix the robot nits

* Add resetModules for some extra isolation
2017-08-03 00:41:09 +01:00
Brian Vaughn
630afb3186 Wrap contents of if-DEV condition in an IIFE (#10361)
This avoids strict mode conflicts for certain browsers wrt functions being defined within an if-block.
Also re-added the if-DEV condition for the ReactNative renderer since it was removed for this reason.
2017-08-02 14:24:43 -07:00
Brian Vaughn
f3e502c613 FB bundles wrap warning() calls in __DEV__ (#10314)
FB bundles wrap warning() calls in __DEV__

Split dev-mode transforms into separate parts:
1) umd+cjs+fb: Wrap warning calls with process.env checks
2) umd+cjs: Replace error messages with minified codes

Also updated transforms to use __DEV__ since it transforms to smaller code after stripEnvVariables is run.

Also renamed 'scripts/error-codes/dev-expression-with-codes.js' -> 'scripts/error-codes/replace-invariant-error-codes.js'
2017-08-02 14:14:26 -07:00
Michał Pierzchała
73217a74a0 Fix error-codes not updating correctly (#10348)
* Fix error-codes not updating correctly

* Revert changes to codes.json
2017-08-02 10:38:27 +01:00
Dan Abramov
a2ed7a6d96 Make unexpected console.warn() calls fail tests (#10341)
* Make console.warn() calls fail tests

* Replace matchers with a more straightforward cleanup
2017-08-01 19:53:37 +01:00
Dominic Gannaway
ca46c5278f Move line to within DEV block (#10316)
* move line to within DEV block

* addressed code review feedback
2017-07-27 17:31:34 -07:00
Dan Abramov
138224f6b3 16.0.0-beta.2 2017-07-27 18:06:26 +01:00
Keyan Zhang
3abbcc48a5 Fix ReactPartialRenderer in production (#10300) 2017-07-27 10:19:05 +01:00
Brian Vaughn
834d2c6954 Updated package versions and Rollup results 2017-07-26 12:55:31 -07:00
Brian Vaughn
52849c94a7 Updated error codes (after merging in missing code from 15 stable) (#10290) 2017-07-26 12:18:02 -07:00
Brian Vaughn
8d5f2c4324 Regenerate error codes and update bundle size stats (#10287) 2017-07-26 11:21:43 -07:00
Brian Vaughn
e2d1bc8a71 Update pre-release instructions for generating error-codes (#10286) 2017-07-26 11:18:32 -07:00
Andrew Clark
6c66d38d25 Remove feature test from invokeGuardedCallbackDev (#10283)
The critical semantics are resilient to browser flakiness, so we don't
need this feature test.

Also added comments explaining how invokeGuardedCallback dev works.
2017-07-26 10:01:31 -07:00
Dan Abramov
66065115dc Update sizes 2017-07-26 12:27:29 +01:00
Andrew Clark
812cf1c6a3 [invokeGuardedCallback] Handle nested errors across separate renderers (#10270)
invokeGuardedCallback is a function we use in place of try-catch
statement. It accepts a function, and if the function throws, it
captures the error. In production, the implementation is a normal try-
catch. In development, we swap out the prod implementation for a special
version designed to preserve "Pause on all exceptions" behavior of the
browser DevTools.

invokeGuardedCallbackDev works by dispatching an event to a dummy DOM
node and calling the provided function inside a handler for that event.
We also attach an error event handler to the window object. If the
function throws, the global event handler is called and we can access
the error.

The global event handler is added and removed right before and after the
fake event is dispatched. But if invokeGuardedCallbackDev is nested --
 that is, if it's invoked inside the body of another
invokeGuardedCallbackDev -- multiple error event handlers will attached
simultaneously. We only want the handler that corresponds to the deepest
level to handle the error. So we keep track of a depth counter, and
within the event handler, we only handle the error if the current depth
matches the depth at the time the function was invoked.

The problem that we discovered, and that this PR fixes, is that the
depth counter is local to each renderer. So if you nest separate copies
of invokeGuardedCallback from separate renderers, each renderer will
have its own depth counter, and multiple error handlers will fire for a
single, nested error.
2017-07-25 09:44:43 -07:00
Brian Vaughn
171149a4b0 Fix failing Prettier command (#10268)
* Ran prettier over non-modified files to change them
* Fixed output of failing Prettier message to show invalid files
* Failing Prettier command now suggests 'yarn prettier-all'
2017-07-24 13:59:16 -07:00
Brian Vaughn
8d2fdc8e76 Don't add dangling commas to functions for packaging fixtures (#10264) 2017-07-24 09:09:40 -07:00
Andrew Clark
4fcc25a229 Support throwing null (#10213)
* Support throwing null

In JavaScript, you can throw values of any type, not just errors. That
includes null. We currently rely on null checks to determine if a user-
provided function has thrown. This refactors our error handling code to
keep track of an explicit boolean flag instead.

* Add DOM fixture test case for break on exception behavior

* preventDefault error events during feature test

We call invokeGuardedCallbackDev at startup as part of a feature test.
But we don't want those errors to log to the console.

* Add throwing null test case

* Use ReactFeatureFlags instead of ReactDOMFeatureFlags

React ART uses this, too.

* Non-errors in error logger

If a non-error is thrown, we'll coerce the value to a string and use
that as the message.
2017-07-21 15:34:41 -07:00
Andrew Clark
0a24255475 ReactDOM.activeUpdates (#10225)
ReactDOM.flushSync(batch)
2017-07-21 13:22:11 -07:00
Flarnie Marchan
1f74eca993 Add warning for rendering into container that was updated manually (#10210)
* RFC Add warning for rendering into container that was updated manually

RFC because we still need to tidy this up and verify that all tests
pass.

**what is the change?:**
We want to warn when users render into a container which was manually
emptied or updated outside of React. This can lead to the cryptic error
about not being able to remove a node, or just lead to silent failures
of render. This warning should make things more clear.

Note that this covers the case where the contents of the root container
are manually updated, but does not cover the case where something was
manually updated deeper in the tree.

**why make this change?:**
To maintain parity and increase clarity before releasing v16.0 beta.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

last item under the '16 beta' checklist.

* Add test and tweak check for rendering into manually updated container

STILL TODO: figure out how to skip this warning when the component
renders to a portal.

Unfortunately 'ReactPortal.isPortal(children)' returns false, even in
the failing test where we are rendering to a portal.

**what is the change?:**
- added a test for the case where we call 'ReactDOM.render' with a new
  container, using a key or a different type, after the contents of the
  first container were messed with outside of React. This case throws,
  and now at least there will be an informative warning along with the
  error.
- We updated the check to compare the parent of the 'hostInstance' to
  the container; this seems less fragile
- tweaked some comments

**why make this change?:**
Continue improving this to make it more final.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Stub our `console.error` in one of the portal tests

**what is the change?:**
See title

**why make this change?:**
See comment in the code

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Skip warning in 'ReactDOMFiberEntry' when mounting to Comment node

**what is the change?:**
We have a warning for cases when the container doesn't match the parent
which we remembered the previously rendered content being rendered into.

We are skipping that warning when you render into a 'comment' node.

**why make this change?:**
Basically, if you render into a 'comment' node, then the parent of the
comment node is the container for your rendered content. We could check
for similarity there but rendering into a comment node seems like a
corner case and I'd rather skip the warning without knowing more about
what could happen in that case.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Improve warning message, remove dedup check, and unmock console.error

**what is the change?:**
Various changes to get this closer to being finished;
- Improved warning message (thanks @spicyj!!!)
- Removed dedup check on warning
- Remove mocking of 'console.error' in portals test

**why make this change?:**
- warning message improvement: communicates better with users
- Remove dedup check: it wasn't important in this case
- Remove mocking of 'console.error'; we don't want to ignore an
  inaccurate warning, even for an "unstable" feature.

**test plan:**
`yarn test` -> follow-up commits will fix the remaining tests

**issue:**
issue #8854

* Possible fix for issue of incorrect warning for portal re-render

**what is the change?:**
Add a property to a container which was rendered into using
`ReactDOM.unstable_createPortal`.

**why make this change?:**
We don't want to warn for mismatching container nodes in this case - the
user intentionally rendered into the portal container instead of the
original container.

concerns;
- will this affect React Native badly?
- will this add bloat to the portal code? seems small enough but not
  sure.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Fix logic for checking if the host instance container is a portal

**what is the change?:**
When focusing on fixing the warning to not check when we are using
portals, I missed checking for the existence of the host instance parent
before checking if it was a portal. This adds the missing null checks.

**why make this change?:**
To fix a bug that the previous commit introduced.

**test plan:**
`yarn test`
-> follow-up commits fix more of the test failures

**issue:**
https://github.com/facebook/react/issues/8854

* Clean up new tests in ReactDOMFiber-test

**what is the change?:**
- removed extra single quotes, downgrade double quotes to single
- update expected warning message to match latest warning message
- fix indentation

**why make this change?:**
- get tests passing
- code maintainability/readability

**test plan:**
`yarn test`
follow up commits will fix the remaining tests

**issue:**
https://github.com/facebook/react/issues/8854

* Add 'unmountComponentAtNode' call in test for reconciling pre-rendered markup

**what is the change?:**
We have a test that verifies React can reconcile text from pre-rendered
mark-up. It tests React doing this for three strings and three empty
strings.

This adds a call to 'unmountComponentAtNode' between the two
expectations for strings and empty strings.

**why make this change?:**
We now warn when someone messes with the DOM inside of a node in such a
way that removes the React-rendered content. This test was doing that. I
can't think of a situation where this would happen with server-side
rendering without the need to call 'unmountComponentAtNode' before
inserting the server-side rendered content.

**test plan:**
`yarn test`

Only one more failing test, will fix that in the next commit.

**issue:**
https://github.com/facebook/react/issues/8854

* ran prettier

* remove unused variable

* run scripts/fiber/record-tests

* Fix type error and improve name of portal container flag

**NOTE:** I am still looking for a good place to move this flag
assignment to, or a better approach. This does some intermediate fixes.

**what is the change?:**
- fixed flow error by allowing optional flag on a DOMContainer that
  indicates it was used as a portal container.
- renamed the flag to something which makes more sense

**why make this change?:**
- get Flow passing
- make this change make more sense

We are still not sure about adding this flag; a follow-up diff may move
it or take a different approach.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Add flag to portalContainer on mount instead of in `createPortal`

**what is the change?:**
We add a flag to the container of a 'portal' in the 'commit work' phase
in Fiber. This is right before we call `appendChildToContainer`.

**why make this change?:**
- Sometimes people call `ReactDOM.render(... container)`, then manually
clear the content of the `container`, and then try to call another
`ReactDOM.render(... container)`.
- This leads to cryptic errors or silent failure because we hold a
  reference to the node that was rendered the first time, and expect it
  to still be inside the container.
- We added a warning for this issue in `renderSubtreeIntoContainer`, but
  when a component renders something returned by
  `ReactDOM.unstable_createPortal(<Component />, portalContainer);`,
  then the child is inside the `portalContainer` and not the `container,
  but that is valid and we want to skip warning in that case.

Inside `renderSubtreeIntoContainer` we don't have the info to determine
if a child was rendered into a `portalContainer` or a `container`, and
adding this flag lets us figure that out and skip the warning.

We originally added the flag in the call to
`ReactDOM.unstable_createPortal` but that seemed like a method that
should be "pure" and free of side-effects. This commit moves the
flag-adding to happen when we mount the portal component.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Force an 'any' type for the `hostInstance.parentNode` in warning check

**what is the change?:**
This is awful. :(
I'm not sure how else to let Flow know that we expect that this might be
a sort of `DOMContainer` type and not just a normal `Node` type.

To at least make the type information clear we added a comment.

**why make this change?:**
To get `flow` passing. Looks like we have `any` types sprinkled
throughout this file. phooey. :(

**test plan:**
`yarn flow`

**issue:**
https://github.com/facebook/react/issues/8854

* Ignore portals in `DOMRenderer.findHostInstance`

**what is the change?:**
We want to ignore portals when firing a certain warning.

This allows us to get the host instance and ignore portals.

Also added a new snapshot recording while fixing things.

**why make this change?:**
Originally we had added a flag to the DOM node which was used for

rendering the portal, and then could notice and ignore children rendered
into those nodes.

However, it's better to just ignore portals in
`DOMRenderer.findHostInstance` because
 - we will not ignore a non-portal second child with this approach
 - we meant to ignore portals in this method anyway (according to a
   'TODO' comment)
 - this change only affects the DOM renderer, instead of changing code
   which is shared with RN and other renderers
 - we avoid adding unneeded expandos

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Ran prettier

* Remove error snapshot test

I think there is a bug where an empty snapshot is treated as an 'outdated snapshot'.

If I delete the obsolute snapshot, and run ReactDOMFiber-test.js it generates a new snapshot.
But then when I run the test with the newly generated snapshot, it says "1 obsolete snapshot found",
At some point I will file an issue with Jest. For now going to skip the snapshot generation for the error message in the new test.

* Remove expando that we were adding to portal container

**what is the change?:**
see title

**why make this change?:**
this is part of an old approach to detecting portals, and we have
instead added a check in the `findHostInstance` method to filter out
portals.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854

* Fork `findHostInstance` to make `findHostInstanceWithNoPortals`

**what is the change?:**
We need to get host instances, but filter out portals. There is not
currently a method for that.

**why make this change?:**
Rather than change the existing `findHostInstance` method, which would
affect the behavior of the public `findDOMNode` method, we are forking.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854
2017-07-21 08:48:46 -07:00
Andrew Clark
ae430b7913 React.unstable_AsyncComponent (#10239)
Alternative to using the static class property unstable_asyncUpdates.
Everything inside <AsyncComponent /> has async updates by default. You
can also extend it like PureComponent or Component.
2017-07-20 18:00:53 -07:00
Dan Abramov
240b84ed8e Remove PooledClass from isomorphic build (#10227)
* Inline traverseAllChildren into ReactChildren

* Remove ForEachBookKeeping

* Inline traversal pooling logic into ReactChildren

* Reuse emptyFunction for dummy callback

* Move code around

* Record sizes
2017-07-20 15:56:49 +01:00
Sebastian Markbåge
7b9f64307d Fix lint (#10222) 2017-07-19 11:12:47 -07:00
Sebastian Markbåge
9011182c55 Configure Jest with Stack and Fiber as separate projects (#10214)
* Disable Fiber specific test run in CI

This disables the comparison against previously recorded test. Instead,
we'll rely on jest failures to fail tests.

* Extract jest config into two separate projects for Fiber and Stack

Allows us to run both in the same jest run. The setupMocks file is forked into
specific environment configuration for each project. This replaces the
environment variable.

I used copy pasta here to make it clear. We can abstract this later. It's clear
to me that simply extracting shared stuff is not the best way to abstract this.
setupMocks for example didn't need all the code in both branches.

I think that some of the stuff that is shared such as error message extracting
etc. should probably be lifted out into a stand-alone jest project instead of
being shared.

* Fix class equivalence test

There's a behavior change when projects are used which makes
setupTestFrameworkScriptFile not override the normal config.

This test should probably just move to a separate CI script or something
less hacky.

* Only run Fiber tests with scripts/fiber/record-tests
2017-07-19 10:35:45 -07:00
Jason Quense
acd9818b90 Move input valueTracker to DOM nodes (#10208)
* Move input valueTracker to DOM nodes

This moves the storage of the input value tracker to the DOM node
instead of the wrapperState. This makes it easier to support both Stack
and Fiber without out a lot of ugly type casting and logic branches.

related: #10207

* run prettier

* remove instance accepting methods

* rm unused trst method

* address feedback

* fix naming

* fix lint
2017-07-19 12:10:13 -04:00
Dominic Gannaway
357925a84e Move DEV only module requires into __DEV__ blocks (#10185)
* modulesToStub cleaned up and DEV only modules put into __DEV__ blocks

* prettier run

* Prettier + new build run for bundle sizes
2017-07-19 17:28:55 +02:00
Dan Abramov
9254ce27a8 Split markup generation from DOM property management (#10197)
* Replace SSR unit test with integration test

* Remove unit test that is already covered by integration suite

* Replace unit tests for boolean attrs with integration tests

* Replace unit test for aria attrs with integration test

* Replace unit tests for numeric 0 with integration tests

* Remove unit test covered by integration tests

* Replace unit test for injection with integration test

It still touches internals but it tests both renderers.

* Fork DOMPropertyOperations into DOMMarkupOperations

* Trim down DOMPropertyOperations and DOMMarkupOperations

* Record SSR sizes

* Record them tests

* Fix false positive warning for overloaded booleans when passing numbers

* Remove stray import

* Replace CSS markup tests with public API tests

Some of these are handy as integration tests so I moved them there.
But some test markup specifically so I changed them to use DOMServer.

* Make CSSPropertyOperations client-only

I forked createMarkupForStyles() into ReactDOMComponent and ReactPartialRenderer. Duplication is fine because one of them will soon be gone (guess which one!)

The warnInvalidStyle helper is used by both server and client, unlike other client-only stuff in CSSPropertyOperations, so I moved it to a separately module used in both.

* Record server bundle size

* Add an early exit to validation

* Clarify what is being duplicated
2017-07-19 14:06:53 +01:00
Sebastian Markbåge
12d5c7a842 Upgrade jest to 20.1.0-delta.1 (#10211)
* Upgrade jest to 20.1.0-delta.1

This includes multi-project support.

* Use isSpy polyfill that is not available in jest 20

* Remove use of jasmine.createSpyObj

We don't really need this and it's not in jest 20.

* Upgrade record-tests script to use the new jest 20 APIs
2017-07-18 17:24:54 -07:00
Andrew Clark
71f591501b Fix scheduler control flow (#10015)
* Use performFailedUnitOfWork

instead of beginFailedWork and completeUnitOfWork separately. Also, we
unwind the context stack *before* beginning work again.

* Only use error loop directly after a commit

We have a special, forked version of work loop that checks if a fiber is
in a failed state (needs to be unmounted). This is only relevant right
after a commit -- begin phase errors are handled differently, by
unwinding the stack.

Also renamed findNextUnitOfWork to resetNextUnitOfWork and made it a
void function to signal that it's impure.

* Reset nextUnitOfWork after every commit

* Include the error boundary when unwinding a failed subtree

Also added a warning to the error boundary to show that it failed.

* Push context providers in beginFailedWork to avoid push/pop mismatch

Added a test that demonstrates how an error boundary that is also a
context provider could pop its context too many times if you neglect
to push it in beginFailedWork. This happens because we've already
popped the context once in unwindContext.

The solution is a code smell. I don't like how we push/pop context in
so many places. Shouldn't they all happen in the same location?

* Refactor work loop

- Optimizes the normal, non-error path by reducing the number of checks
needed to begin performing work.
- Prevents control flow from oscillating between fast normal loop and
slower error loop.

* Improve context unwinding test

Tests that we correctly unwind an error boundary that is also a
context provider.

* Triangle tester should assert the tree is consistent after every action

...not just at the end.

* Better implementation of infinite loop error

Infinite loops should only be possible if a while loop never terminates.
Now that we've refactored to avoid oscillation between different
work loops, we can count updates local to each loop.

The two loops that could infinite loop are the sync work loop and the
loop that surrounds the body of the render phase catch block. The
async loop could also fall into an infinite loop if the deadline never
terminates, but we'll assume that it always eventually does.

This change also creates better error stack traces because the error is
thrown from inside the first setState that exceeds the limit.

Added a test case for an error boundary whose parent remounts it
on recovery.

* Use invokeGuardedCallback in DEV
2017-07-18 16:31:49 -07:00
Dan Abramov
c2ed1b87dc Record sizes 2017-07-18 20:06:17 +01:00
Dan Abramov
9043ad6b9d Fix crash on master introduced during the radio bugfix (#10207)
* Add a regression test that passes in Stack but fails in Fiber

The failure happens because trackValueOnNode() can exit early if it detects an existing descriptor on node, or if it sees a "broken" Safari descriptor (which is how we encountered this bug in the wild).

As a result, the tracker field was not set, and subsequent updateValueIfChanged() call went into the branch that initializes the tracker lazily. That branch has a bug in Fiber mode where it passes the wrong type.

We did not see this issue before because that branch is relatively hard to hit (you have to either run it in Safari or define a custom DOM value descriptor which is what I did in the test).

In the future, we will likely remove the lazy branch altogether since if we bailed out of setting up the tracker once, we will likely bail out every time. But for now I'm just focused on a minimal fix to unbreak master.

* Fix updateValueIfChanged() lazy path to work with DOM argument

* Slightly reorder lines for clarity and record tests

* Also test the change event code path

This makes it go through the Fiber argument code path.
2017-07-18 16:31:04 +01:00
Sebastian Markbåge
3b5e3b5a23 Refactor Debug Frames to Enable Renderers to Provide Custom Logic (#10105)
* Extract the top element frame from ReactDebugCurrentFrame

This is part of a larger refactor to decouple stack addendums. All
renderers have their own way of getting the stack of the currently
executing components.

There is one special case in Element Validator that adds an additional line
for the element being validated. This commit moves that special case in
into the validator.

There is another case where it looked like this was used in shallow
renderer but this is actually something different. It is part of the
component stack. It just happens to be that shallow renderer has a simpler
implementation of the component stack that just happens to be a single
element.

This will let us decouple the implementation to get a stack from
ReactDebugCurrentFrame and put that in each renderer.

* Stop using ReactComponentTreeHook for Fiber

Currently we fall back to ReactCurrentOwner in ReactComponentTreeHook for
stack addendums. We shouldn't need to because we should use
ReactDebugCurrrentFiber.

Ensure we always set both ReactDebugCurrentFiber and ReactDebugCurrentFrame
so that we can rely on these for all stacks.

* Make ReactDebugCurrentFrame implementation independent

Introduced ReactDebugCurrentStack for the Stack renderer which does the
same thing as ReactDebugCurrentFiber.

ReactDebugCurrentFrame no longer keeps track of the current fiber/debug id.
That's handled by the individual renderers.

Instead, it is now used to keep track of the current *implementation* of
the current stack frame. That way it is decoupled from the specifics of
the renderers. There can be multiple renderers in a context. What matters
is which one is currently executing a debuggable context (such as a render
function).

* Add debug frames to ReactPartialRenderer (ssr)

Basic functionality.

* Add shared modules to shallow renderer

This is now needed because we share describeComponentFrame.
2017-07-14 15:36:24 -07:00
Andrew Clark
4dabdd2a30 Limit the number of nested synchronous updates (#10178)
* Limit the number of nested synchronous updates

In Stack, an infinite update loop would result in a stack overflow. This
gives the same behavior to Fiber.

Conceptually, I think this check belongs in findNextUnitOfWork, since
that is what we call right before starting a new stack. I've put it
in scheduleUpdate for now so I have access to the component that
triggered the nested update. But we could track that explicitly instead.

I've chosen 1000 as the limit rather arbitrarily. Most legit use cases
should really have a much smaller limit, but a smaller limit could break
existing code. For now I'm only concerned with preventing an infinite
loop. We could add a warning that fires at the smaller limit.

* Move check to findNextUnitOfWork

Including the name of the component in the message probably isn't
necessary. The JS stack will include either componentDidUpdate or
componentWillUpdate. And the component that's updating won't
necessarily be the component whose lifecycle triggered it.

So let's move the infinite loop check to findNextUnitWork as I
originally wanted to.
2017-07-13 15:56:02 -07:00
Dan Abramov
0070925a4f Don't use Stack-only helper in new SSR (#10174) 2017-07-13 19:55:48 +01:00
Dan Abramov
7dd7c1702b Remove dependency to event system on the server (#10173)
I do this by splitting ReactDOMInjection into generic and client-only injection.
2017-07-13 19:32:27 +01:00
Flarnie Marchan
309412d8b6 Improve error message thrown in Fiber with multiple copies of React (#10151)
* WIP Improve error message thrown in Fiber with multiple copies of React

**what is the change?:**
Adding an 'invariant' with detailed error message for the problem that
occurs when you load two copies of React with the Fiber reconciler.

WIP:
 - Is there any other likely cause for this error besides two copies of
   React?
 - How can we make the message more clear?

Still TODO:
 - Write a unit test
 - Write a documentation page and create the link to the page, similar
   to https://facebook.github.io/react/warnings/refs-must-have-owner.html

It would also be nice to have a page with instructions on how to fix
common cases of accidental double-loading of React, but we can open a
separate issue on that and let the community do it.

**why make this change?:**
This error comes up relatively often and we want to make things clear
when it happens in v16.0+

**test plan:**
WIP

**issue:**
Fixes #9962

* Add improved warning and docs for 'refs must have owner' in Fiber

**what is the change?:**
 - Added warning in the place where this error is thrown in Fiber, to
   get parity with older versions of React.
 - Updated docs to mention new error message as well as old one.

I started to write a new docs page for the new error, and realized the
content was the same as the old one. So then I just updated the existing
error page.

**why make this change?:**
We want to avoid confusion when this error is thrown from React v16.

**test plan:**
- manually inspected docs page
- manually tested in a CRA to trigger the error message

(Flarnie will insert screenshots)

**issue:**
Fixes #9962
Related to #8854

* Add test for the informative warning around multiple react copies

@gaearon debugged the test for this and now it works!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)

**what is the change?:**
We now test for the warning that the previous commits add in Fiber, and
also test for the old warning in the stack reconciler.

**why make this change?:**
This is an especially important warning, and we want to know that it
will fire correctly.

**test plan:**
`yarn test src/renderers/__tests__/multiple-copies-of-react-test.js`
`REACT_DOM_JEST_USE_FIBER=1 yarn test src/renderers/__tests__/multiple-copies-of-react-test.js`

* Fix up test for 'multiple copies of react'

**what is the change?:**
refactor test for 'multiple copies of React' to be simpler and remove
some copypasta

* run prettier

* Fix conditionals in 'multiple copies of react' test

**what is the change?:**
When moving the 'fiber' and 'non-fiber' conditions from two assertions
into one, we copy pasted the wrong message into the 'fiber' condition.

This wasn't caught because we were using an outdated name for the
'fiber' constant when running the tests locally with fiber enabled.

This fixes the copy-paste error and we now are actually running the
tests with fiber enabled locally.

* Run scripts/fiber/record-tests
2017-07-13 10:41:32 -07:00
Brian Vaughn
5495e495de Remove conditional __DEV__ wrapper from RN bundles (#10171)
This causes an error with the older version of JSC packaged for Android.
2017-07-13 09:26:45 -07:00
Garrett McCullough
50d905b083 change the argument passed to CallbackQueue.getPooled (#10101)
* change the argument passed to CallbackQueue.getPooled

* remove undefined from function call

* add test for ReactNativeReconcileTransaction

* update log of tests

* change test to one that operates on setState

* added new tests and fixed another instance of the bug

* run prettier

* update names of tests and minor clean up

* remove arg from CallbackQueue and update tests
2017-07-12 18:49:13 +01:00
Brandon Dail
d04618b28b Run all fixtures through Prettier (#10157)
* Include fixtures in prettier default pattern

* Run all fixtures through Prettier
2017-07-12 11:19:24 -05:00
Peter Ruibal
cff012fc16 Add react-dom-unstable-native-dependencies (#10138)
* Add react-dom-unstable-native-dependencies

react-native-web and react-primitives currently access a few internals
for shimming DOM events into native ones.  Changes in react@16 packaging
hide these internals completely.  This change adds a submodule to react-dom,
unstable-native-dependencies that includes the necessary modules to
continue enabling that method of dom-native event injection.

* Update ResponderEventPlugin to use "public" interfaces for test

In order to get some sort of smoke testing on
react-dom-unstable-native-dependencies, update ResponderEventPlugin-test
to use the "public" interfaces provided by react-dom and the new
react-dom/unstable-native dependencies

Also adds the missing references in package.json as well as missing
files required for unittests to do imports correctrly

Also exports injectComponentTree() which is required for the unittests
to re-set the shared component state between runs.

* Tweak bundle comment

* Bundle content updates from exporting injectComponentTree

* Added FB_DEV, FB_PROD to bundle types

* Run yarn prettier for -unstable-native-dependencies updates
2017-07-12 02:27:26 +01:00
Dheeraj Kumar
5ac6209599 Fix shallow renderer callbacks (#10106)
* Add failing test to show that shallow test renderer doesn't call setState's callback arg
* Record tests
* Fix shallow renderer's setState/replaceState/forceUpdate to execute any callbacks passed. (#10089)
* Ensure shallow renderer callbacks are called with the correct  binding.
2017-07-10 14:41:50 -07:00
Eli White
5bc25cb186 Fixing typo in ReactDOMComponent test name (#10132) 2017-07-09 19:34:39 -04:00
Andrew Clark
f9af9aacd3 Down-prioritize children of hidden host components
To make sure we don't reset the priority of a down-prioritized fiber,
we compare the priority we're currently rendering at to the fiber's
work priority. If the work priority is lower, then we know not to reset
the work priority.
2017-06-30 18:39:04 -07:00
Andrew Clark
de08c2af15 Ignore incremental tests that assert on work reuse
it -> xit

The diff looks messier than it actually is because of Prettier.
2017-06-30 18:39:04 -07:00
Sebastian Markbåge
e6f1d29f07 Warn for inline style mismatches (#10084)
I use the technique of generating a style string and comparing that against the
attribute.
2017-06-30 18:24:04 -07:00
Sebastian Markbåge
8d61138186 Warn When The HTML Mismatches in DEV (#10026)
* Warn for text content

* Warn for different attributes/properties values

Warns if there are unknown extra attributes in the hydrated node.

It also tries to compare the existing property or attribute against the
expected value. It does this by reading the property and comparing it to
the prop. Except it's not that simple because multiple prop values can
yield the same output. For this we pass an extra expected value that is
a hint as to which one was used. This is a bit weird but I'm not sure the
alternatives were much better.

* Warn when there is an insertion or deletion during hydration

This warns if there is ever an insertion or deletion due to hydration
failing to find a match.

Currently we can't warn for insertions required into the root because
that's how we do all non-hydrating renders atm. Left a todo.

This strategy is a bit unfortunate that it leads to so much plumbing code.
And we have to add three extra methods to the HostConfig that are only used
in DEV and not for anything else. I don't really have a better idea.

* Don't try to delete children of a textarea

Textareas are special cases. The initial mount inserts children
as the default value, but we should leave that untouched. This is the same
as the special case where we set text content of children so I'll use that
mechanism.

* Change expected format for text differences

In Stack this is presented as HTML which needs to have normalized escaping
rules. In Fiber it is currently not presented as HTML but a raw string
so we don't escape it.

* Unmount component in between tests

In Fiber, the second warning isn't issued because it's considered an update
not a new initial render and we don't fire the warning for those.

* Change expectation of white space text behavior in Fiber

In Fiber we don't expect empty strings to be different from rendering null.
In fact, in a follow up I plan on formalizing this by never creating text
Fibers for empty strings.

* Warn for different dangerouslySetInnerHTML

We can't just compare the raw innerHTML value because it will have been
normalized. Instead, we'll create another element, set its innerHTML and
read it back.

Since there can be custom elements registered with this document, we want
to avoid any side-effects they might cause. So I do this in a fresh new
document.

I'm not sure how this would affect controlled components and other stuff
that could have changed after runtime. I think for those cases maybe we
just need a general way of opting out of the diff.
2017-06-29 19:47:44 -07:00
Nathan Hunzaker
9d13557244 Add test to ensure extra zeros are covered by tests (#10033)
* Add test to ensure extra zeros are covered by tests

* Add DOM test fixture for trailing zeros

* Drop quotes to improve clarity
2017-06-29 12:44:05 -05:00
Ben Alpert
21df484f25 Don't build ReactDOMNodeStream for FB (#10065)
require('stream') doesn't work for us right now.
2017-06-28 16:13:58 -07:00
Ben Alpert
864ae8fa98 Support comment node as a mount point (#9835)
This means you don't need an extra wrapper div for each component root you need. Rendered stuff is inserted before the comment you pass in.
2017-06-27 17:22:07 -07:00
Sebastian Markbåge
52a2365f19 Fix mount and unmount warnings in Fiber (#10056)
* Warn if unmounting a non-container

* Warn if the 2nd+ child is a "root" element but not first

This triggers our non-reuse mode. This is covered by ReactMount already but
the test doesn't pass yet without also landing #10026.
2017-06-27 17:15:53 -07:00
Sebastian Markbåge
90b7facd52 Don't use the render callback with promises (#10050)
This covers up errors that are thrown in Fiber, because callback gets
fired *and* an error is thrown. Created a follow up #10049 to reevaluate
these semantics.

# Conflicts:
#	scripts/fiber/tests-passing-except-dev.txt
#	scripts/fiber/tests-passing.txt
2017-06-27 08:24:31 -07:00
Sasha Aickin
411e04bd71 Add ReactDOMNodeStream, adding streaming rendering. (#10024)
* Add ReactDOMNodeStream, adding ability to stream generated HTML.

* Forgot to rename a documentation page.

* Tests are passing locally but failing on CI; attempt to fix that with this tweak.

* Adding some debugging info to try to track down CI problem.

* More debugging of CI. Yay for printf debugging.

* More printf debugging of CI to figure out what is going on with includes during tests.

* I made a truly stupid error with my printf debugging statements for CI. Fixing that.

* And another dumb copy and paste typo.

* The node-stream.js stub for tests wasn't being added because of .gitignore.

* Fix for code review coment https://github.com/facebook/react/pull/10024#discussion_r123606138 . Thanks to @razh for helping me out.

* Removing all the console.logs I put in to debug the build problems on the CI server.

* Fix for code review coment https://github.com/facebook/react/pull/10024#discussion_r123628227 . Thanks to @aweary for the suggestion.

* Response to code review comment https://github.com/facebook/react/pull/10024#discussion_r123649131 . Thanks, @gaearon.

* Responding to code comments https://github.com/facebook/react/pull/10024#pullrequestreview-46104491 , https://github.com/facebook/react/pull/10024#pullrequestreview-46104616 , and https://github.com/facebook/react/pull/10024#pullrequestreview-46104822 . Thanks to @sebmarkbage for the help.

* Attempt to tweak spacing to see if it makes the prettier build step happy.

* Found a prettier bug that wasn't being reported by npm run prettier for some reason.

* Fixed a small prettier issue
2017-06-24 22:31:42 -07:00