Summary:
Release note: none
After recent refactorings in Nuclide, we don't need to build the debugger differently anymore. We can use our transpiled code directly into Nuclide.
This undoes #1240
Closes https://github.com/facebook/prepack/pull/1274
Differential Revision: D6579982
Pulled By: JWZ2018
fbshipit-source-id: 58b487b3f1f020be27fc569c4f5219c660c1aad5
Summary:
Release note: none
The debugger needs to be built differently from the rest of Prepack to be compatible with Nuclide. This PR makes building the debugger into a separate command while still keeping the original command to build Prepack.
- make separate envs for building debugger and the rest of Prepack
- add `yarn build-debugger` command
Closes https://github.com/facebook/prepack/pull/1240
Differential Revision: D6534794
Pulled By: JWZ2018
fbshipit-source-id: 384dfbb7d77d46564e028c00a79e97b3657616b5
Summary:
This method provides an alternative way to run Test262 through a
stream of compiled test contents for each scenario (default, strict
mode), including all the necessary harness contents.
The logic to capture an execution success or failure is similar to
the original one - from scripts/test262-runner.js - and improvements
should be done as follow ups.
The filtering system is now done through a configuration yaml file,
using tests metadata and path locations. This filter is used as an
object that can be extended with further logic, but still offers a
single point to check for filtering.
The report system requires some improvements and these should also
be done as follow-ups. For now they provide a report for each
folder and the total results. Although, the results data contain
enough information to highly expand the report.
Some further improvements are expected and planned, this work
should be at least ready for an initial round for feedback review.
Closes https://github.com/facebook/prepack/pull/1122
Reviewed By: cblappert
Differential Revision: D6456700
Pulled By: hermanventer
fbshipit-source-id: ba56efcaa4eab847594cb7c1fbc908cf1fc66a80
Summary: Improvements to the debugger and the test runner for lazy objects. Miscellaneous bug fixes in the Abstract Interpreter and serializer.
Reviewed By: yinghuitan
Differential Revision: D6430111
fbshipit-source-id: c2046973871e779379da95394b986395d355b5ba
Summary:
Provides support for joining properties that have get and set methods. Also now fully support properties that are only defined in one branch of an unknown conditional.
Debugger fixes and features.
Reviewed By: cblappert
Differential Revision: D6361763
fbshipit-source-id: e3a6544ba6edc1c12a8a6d9ae13e348d5a1674ff
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
I enable this mode only on CI for now. Not to `yarn test`. Since it is
locked to a particular version of Node so we don't want to force people
to run it locally.
* Refactor the public API
This refactors the public Node API to mimic the
[Babel API](http://babeljs.io/docs/usage/api/). This is a bit more
idiomatic than "run CLI" or instantiate the full serializer object.
I'm passing a single options object instead of individual arguments. This
is a bit more managable as the option list grows.
The prepack-node file is what is exposed in Node which has a file system
API. Both synchronous and asynchronous forms. prepack-standalone is a
module for environments without access to the file system such as browsers.
I configure this to be exposed by default for such environments.
That way we can also use this in the webpack build so that our own repl
on the website can just use this public API.
* Throw an error when serialization fails
This lets any compiler flow to terminate properly by default but the error
can safely be ignored if we've already printed error messages for it such
as in the CLI.
Turn internalDebug error messages off by default but allow it to be
configured.
* Added missing realm options
Not yet exposed in the cli but available through the API.
This moves things around in a more common idiomatic folder structure / naming convention. This extracts the scripts that are only used to test the library from the source of the library itself.
/src/scripts -> /scripts
This is no longer part of the build process. Therefore we use babel-node to run the files as needed. The exception is test-runner that is just ran in plain node so that it works with the coverage reports.
The lib folder now includes only and all the library files required to use the package and no longer test runners.
Because of that I moved all the dependencies that were related only to our test scripts and website build to devDependencies. That way we minimize the required dependencies to use Prepack downstream as an npm package.
Then I configured the package.json to only list lib/ and bin/ folders as part of the package. This lets `npm publish` ignore all other files so that people installing the package don't need to include all our testing code.
I added files to bin/ and package.json which is a convention to make this package installable and usable as a command-line tool.
Renamed run_util -> prepack-cli and repl -> repl-cli to separate these from library variants.
The coverage reports now get created in the root instead of lib folder so that they don't get included in the build.
I bumped the version number to one minor above what is already on npm since we can't publish earlier than that.