Summary:
Release note: Adds experimental React functional component folding optimizations
This PR is stacked upon PRs #1118 and #1117. Thus, those PRs should be merged before this PR is merged to reduce noise in the diff.
This PR adds a new React Reconciler into Prepack's serialization process, so that React components trees can be folded/inlined into a single component at build time. To fold a component tree, it must be explicitly done via `__registerReactComponentRoot(nameOfComponent)`.
This PR only attempts to fold React functional components, not React ES2015 class components (that will come in another PR at a later date). Furthermore, the `props` parameter on a root component must contain Flow type annotations (otherwise we will have no idea what the values might be). Support flow `propTypes` might also be an addition, but not for this PR.
If the reconciler comes across a component that it cannot fold/inline, it will "bail-out" and try and continue the process without that particular component being folded into the tree.
An example of how this all works (input):
```jsx
function App(props: {title: string}) {
return (
<div>
<ChildComponent title={props.title} />
</div>
);
}
function ChildComponent(props) {
return (
<span>
<SubChildComponent {...props} />
</span>
);
}
function SubChildComponent(props) {
return <span>{props.title.toString()}</span>
}
__registerReactComponentRoot(App);
global.App = App;
```
Output:
```jsx
(function () {
"use strict";
var _$1 = this;
var _0 = function (props) {
var _$0 = props.title;
return <div><span><span>{_$0}</span></span></div>;
};
_$1.App = _0;
}).call(this);
```
Closes https://github.com/facebook/prepack/pull/1120
Differential Revision: D6237333
Pulled By: trueadm
fbshipit-source-id: b58c7d8979ca79a766bb2ee2eb01a380d37c3101
Summary:
Update Flow and fix errors found by new version.
I'm none to sure the changes to the code are desirable. Perhaps the flow types for babel-types need to be updated?
Closes https://github.com/facebook/prepack/pull/1127
Differential Revision: D6222475
Pulled By: hermanventer
fbshipit-source-id: 208b89787914fc7d1e322cb14a6ff2374cd24b9a
Summary:
Release note: none
This PR adds the React/Jest testing infrastructure to Prepack and is stacked on the PR https://github.com/facebook/prepack/pull/1117. Thus, that PR should be merged before this PR is merged to reduce noise in the diff.
This will allow us to test various runtime outputs of React 16 when running original source vs Prepacked source to see if there are any issues/differences that might have an impact on applications. The primary reason for this is to track regressions for the component folding PRs that will land in the future.
Please note, this PR does not contain any reconciler changes, thus `__registerReactComponentRoot(App);` has been commented out of tests to ensure they don't prematurely fail. A follow up PR will enable them once the other React functional component folding PRs get landed.
This PR also adds some mock React globals to be used within tests (and maybe to be further integrated into folding at a future point too). The mocks include `React.Component` and `React.cloneElement` for now.
Furthermore, a `utils/json.js` utility file exists to help normalize the results from the React test renderer so that adjacent JSON text nodes get merged, which is something that may exist because of how the reconciler (once the PR lands) handles inlining of child nodes.
The command to run React tests is `yarn test-react`.
Closes https://github.com/facebook/prepack/pull/1118
Reviewed By: cblappert
Differential Revision: D6208263
Pulled By: trueadm
fbshipit-source-id: d54f3b0e1cc3240e1f142d3da08bc279e4153889
Summary:
Release note: none
Issue: #907
- Mock UI as a CLI to communicate with the adapter
- Starter code for the debugger adapter with an initialize request
Closes https://github.com/facebook/prepack/pull/1088
Differential Revision: D6108024
Pulled By: JWZ2018
fbshipit-source-id: 506ec039dcb1ff540872cb2e1a87a165cfd22e4d
Summary: Adds new `test-coverage-all` command to `package.json` which will run and compose all test coverage information into one html.
Reviewed By: hermanventer
Differential Revision: D6052366
fbshipit-source-id: 208259fa79185267f6c7a51ca8baf08ffb707e97
Summary: Bump version number for new alpha
Reviewed By: cblappert
Differential Revision: D6079917
fbshipit-source-id: b7f640001a830813a1b2343efc4ccfeac9810679
Summary:
Release notes:
Generate code for uncaught exceptions at the top level
Adds JSX and ReactElement evaluation/serialization support
Avoid duplicate nested function bodies
Reviewed By: cblappert
Differential Revision: D6079861
fbshipit-source-id: e80e813469def0b98b1799edb79217f45980f911
Summary:
Bump version for new release:
1. Enhance Additional Functions testing and functionality.
2. Enhance factorifyObjects() for delay initializations code block.
3. Fix a bug that Prepack may generate invalid syntax for abstract model with special characters in binding name.
4. Support exceptions that are thrown, inside a try-catch, based on an abstract condition.
5. Allow Map, Set, WeakMap and WeakSet to be used inside branches of abstract conditionals.
6. Allow use of arguments.caller property in non strict mode.
Reviewed By: hermanventer
Differential Revision: D6024226
fbshipit-source-id: 99cfcbe6071d4d5820edd8ba838c209586f4fa71
Summary:
Major commits include:
* Change error message when evaluating PossiblyNormalCompletion
* Added --omitInvariants option to prevent invariants from being included in generated code.
* Print out call stack in default error handler
* More simplifications
* Add missing check for invalid use of Map
* Simplify if conditions
Reviewed By: cblappert
Differential Revision: D5965959
fbshipit-source-id: e8eb8e053d9a121d2b4de352658269a5ec856f43
Summary: New alpha after version bump
Reviewed By: yinghuitan
Differential Revision: D5913655
fbshipit-source-id: 9207bc43896b0688b17d6042b3330477d7e538b7
Summary: Basic expression simplification and refinement with path conditions. Various small improvements.
Reviewed By: yinghuitan
Differential Revision: D5913534
fbshipit-source-id: efb259347d5300abae0ce50d0267134aaeeab853
Summary:
Currently works for all test cases except `noconflict-existantobject.js`.
There are a couple things that are dubious in the current implementation that I will address as I iterate on it:
* We don't visit things correctly in the visitor or the serializer -- we should be visiting only:
* generator entries in effects
* Bindings, PropertyBindings in effects not relating to CreatedObjects
* There is currently no way to emit to the main body after the main generator has been serialized -- we may need to if a value is only reachable from one of the additional functions.
* More thought needs to go into how this interacts with
* speculative initialization
* require optimization
* inlining
Closes https://github.com/facebook/prepack/pull/912
Differential Revision: D5859741
Pulled By: cblappert
fbshipit-source-id: 9fe7bd4429ad53629582f9fb7154a28971159554
Summary:
In this part, the code for creating an abstract value that results from a binary operator is centralized into AbstractValue.createFromBinaryOp. As part of this, TypeDomain and ValuesDomain now have transfer functions for computing the domain values that result from binary operations.
If this pattern is acceptable, I'll extend it to the other operators.
Closes https://github.com/facebook/prepack/pull/937
Differential Revision: D5734009
Pulled By: hermanventer
fbshipit-source-id: 0e775116b86df5de5da805de241436ecdc575605
Summary: New alpha after version bump
Reviewed By: hermanventer
Differential Revision: D5673084
fbshipit-source-id: c11532139841988e036a71470c7443ea3fc1a91e
Summary:
Introspection errors no longer show up as completions, so any time we evaluate a node that might cause an introspection error, we should expect to catch and handle a FatalError.
Also tweaked package.json to allow longer stack traces when running test-serializer and tweaked test-internal to output error messages that do not have associated source locations. (The latter should not happen in practice but could happen when things go wrong.)
Closes https://github.com/facebook/prepack/pull/866
Differential Revision: D5563965
Pulled By: hermanventer
fbshipit-source-id: e2a74ec19314703526ebd35f7b8e694c19d82ab0
Summary:
There were two instances of the pattern and the second contained an omission that broke it. Factored out the pattern and made sure it works in both cases now.
Closes https://github.com/facebook/prepack/pull/851
Differential Revision: D5523645
Pulled By: hermanventer
fbshipit-source-id: 086cf9aadb1e31279ae11b512f367daddf726d55
Summary:
Update Babylon and adjust expected pass count to match what I see on my laptop.
The difference was due to my version of Babylon (which is the latest for some or other reason I don't understand) giving a syntax error that did not occur with the version on the CI machine. Updating the yarn lock file gets the CI machine in sync with my laptop with respect to those tests.
Note that some String.prototype tests only pass with recent versions of Node.
Closes https://github.com/facebook/prepack/pull/831
Differential Revision: D5489742
Pulled By: hermanventer
fbshipit-source-id: 5732e47718c53d9f20de04fd64c1389524f33309
Summary:
After adding this plugin, you just need to install https://github.com/AtomLinter/linter-eslint Atom package to surface ESLint errors(including prettier errors) in Nuclide linter UI. You also got auto-fix support in the Nuclide UI. Similarly, in VSCode, you can install https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint plugin to surface ESLint error in VSCode UI.
One caveat is that, eslint-plugin-prettier uses its own version of prettier(1.3.1) which may diverge from what we want. If we really found a file that diverge in formatting, we may have to add it into .eslintignore to ignore from UI/linter.
Closes https://github.com/facebook/prepack/pull/816
Differential Revision: D5444642
Pulled By: yinghuitan
fbshipit-source-id: 1670129d62e5e799a50c53d78387b5ded4c2c964
Summary:
Enables source map for scripts folder so that we can debug test runners.
Closes https://github.com/facebook/prepack/pull/819
Differential Revision: D5444607
Pulled By: yinghuitan
fbshipit-source-id: ac80516dfb9f91e469cfc2d4a0c8c3108f78d83e
Summary:
Report errors rather than throw IntrospectionErrors. Added test cases to get 100% coverage of ForOfStatement.js. Fixed a few bug that came to light because of the new tests.
Closes https://github.com/facebook/prepack/pull/803
Differential Revision: D5411294
Pulled By: hermanventer
fbshipit-source-id: 818a5fb4c8112fc33c8531602eee5c0f6ecf25cb
Summary: bump to new alpha version after npm release
Reviewed By: hermanventer, NTillmann
Differential Revision: D5394775
fbshipit-source-id: 24d09f8240b552d5deeb63c0dcf9341193692a8f
Summary:
This supersedes #760.
Additional changes over #760:
Pinning Prettier version to get some formatting always. (Different prettier versions were responsible for the observed flip-flopping of StringPrototype.js.)
Print output of prettier in wrapper script for better diagnosis / experience. (TODO: How to just pipe through console output? Couldn't get it to work.)
Updating problematic .js file for the last time.
Closes https://github.com/facebook/prepack/pull/787
Differential Revision: D5382336
Pulled By: NTillmann
fbshipit-source-id: 95ed988ef3f091493d2fb509b5481753d56901cd
Summary:
Per discussion in #729, this sets up prettier but doesn't actually run it on the codebase.
Closes https://github.com/facebook/prepack/pull/759
Reviewed By: Kishore-B-Rao
Differential Revision: D5343135
Pulled By: NTillmann
fbshipit-source-id: 638740d48b6fa797fa79b8b5fd3c032497cb0132
Summary: after release, bump version number to new alpha for prepack
Reviewed By: NTillmann
Differential Revision: D5292338
fbshipit-source-id: 09248f7193e2dd58c8584a1cb9a23d636f2ba67f
Summary: Change version number, yarn.lock in preparation of publishing new npm package
Reviewed By: NTillmann
Differential Revision: D5292317
fbshipit-source-id: d91edcbdbbcfe9a0e7ad2530700899e3ef3cfb60
Added interface for reporting compilation/evaluation errors with relevant metadata
The new interface is used in a single location as a proof-of-concept
* Cleaning up the interface for handling recoverable errors
* more general recoverable error
* Addressed review comments
* Addressed review comments + added basic tests
* Address review comments #2
* Addressed CR comment about errorHandler in Options
* Fixing typo in import
* Address more review comments
* Fix linter errors
* Fix more linter errors
* Adjust test runners to run the new test