Commit Graph

97 Commits

Author SHA1 Message Date
Dominic Gannaway
810056d1ec Add React functional component folding
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
2017-11-06 05:07:36 -08:00
Dominic Gannaway
e63daa5585 Add React/Jest testing infrastructure
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
2017-11-02 04:40:33 -07:00
Simon Jensen
0a3e23eeb0 Support running tests in inferior JavaScript repl.
Summary:
Define two new flags for test-runner.js:
 --repl <path> : If present the, the prepack sources of test are evaluated
using by piping to the process instead of in a new node context.
--es5 : run babel on tests, used if the repl does not support es6.

To further deal with es6 a new test header flag is introduced, es6. If a test is
not relevant in a non es6 world, the test is skipped if the es5 flag is also set.
This flag has been added to some tests.

Running subprocess for each test is obviously more expensive so the default
behavior is unchanged and still uses a new context.
Closes https://github.com/facebook/prepack/pull/1103

Differential Revision: D6192670

Pulled By: simonhj

fbshipit-source-id: 35e4b819d863634f3273a4da7984c7a71d8c4fb9
2017-10-30 17:29:46 -07:00
Herman Venter
80b0757f67 Allow required modules to throw conditionally
Summary:
Instead of delaying modules that throw conditionally, let the exception bubble up to the require call and then forget it (after emitting a warning). This allows more global state to be optimized and should be OK if it is understood that throwing an unhandled exception in module initialization code is not a supported scenario.

Probably, the temporal point where the require call happens should contain a conditional throw statement, which would be equivalent to current behavior. For now, this causes invariants to fire in the serializer, probably because of bugs in how the state at the time of the exception is restored and presented to the throw statement.

It is also an option to let the exception escape the require call itself and possibly bubble all the way to the top level. This would be more correct than the current behavior since it should match the runtime behavior of the unprepacked code. This too is currently buggy. It also a bit of performance concern because it uses much more saved state.
Closes https://github.com/facebook/prepack/pull/1104

Differential Revision: D6189032

Pulled By: hermanventer

fbshipit-source-id: 71c6352eddca4d88ae030fdcbfb76e7a39839e73
2017-10-30 13:00:01 -07:00
Herman Venter
d7a60ebd35 Fix prettier and lint failures
Summary:
Fix build.
Closes https://github.com/facebook/prepack/pull/1098

Differential Revision: D6122926

Pulled By: hermanventer

fbshipit-source-id: 3cf74746fa5db5b6fdf84fb923cb87af0c2e19f5
2017-10-23 00:00:47 -07:00
Chris Blappert
37fa45bf12 New code coverage step
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
2017-10-19 17:58:26 -07:00
Dominic Gannaway
cfc6993e9c Basic JSX/ReactElement support
Summary:
Release notes: adds JSX and ReactElement evaluation/serialization support

This adds JSX/ReactElement support to the Prepack serializer so `ReactElement` "like" objects can correctly be converted back to JSX syntax. Example:

```jsx
'use strict';

const externalThing = __abstract('function', 'externalThing');

function Test() {
  return <div>{ externalThing() }</div>
}

global.test = Test;
```

Becomes:
```jsx
'use strict';

var _$0 = this;

var _0 = function () {
  return <div>{_1()}</div>;
};

var _1 = externalThing;
_$0.test = _0;
```

I've also added a JSXElement -> ReactElement evaluator.
Closes https://github.com/facebook/prepack/pull/1051

Differential Revision: D6053275

Pulled By: trueadm

fbshipit-source-id: 7c31545751ceedba55cdd4581bc6de51a98b412a
2017-10-13 12:18:35 -07:00
Herman Venter
b0e977136c Emit code for exceptions that make it to the top level.
Summary:
Release note: Generate code for uncaught exceptions

This is a high priority fix for a land blocking issue. Please review ASAP.

Exceptions that (conditionally or unconditionally) propagate to the top level program used to cause Prepack to fail.

The new behavior is to generate top level code that will (conditionally) throw the exceptions at runtime.
Closes https://github.com/facebook/prepack/pull/1083

Differential Revision: D6050038

Pulled By: hermanventer

fbshipit-source-id: 666c058befdebf2ed5f97bed74818db57b86f34b
2017-10-12 23:41:33 -07:00
Herman Venter
1cbdfa2022 Make "caller" a restricted property in strict mode.
Summary:
This seems to have been added to the standard since the last time a looked. Re-enable a test that was already looking for it. Mask "caller" for non strict functions, lest more tests fall over.
Closes https://github.com/facebook/prepack/pull/1049

Differential Revision: D5984228

Pulled By: hermanventer

fbshipit-source-id: 430a5c85b211cb0c5cfb8429c2713246892bebb5
2017-10-04 22:09:09 -07:00
Eric Wright
f68335998a Added --omitInvariants option to prevent invariants from being included in generated code.
Summary:
Fixes #992.
Closes https://github.com/facebook/prepack/pull/1038

Differential Revision: D5959825

Pulled By: Eric-Wright

fbshipit-source-id: 4eb3f5cd24ed2a6f4ba26be321042e3a864de498
2017-10-02 23:07:58 -07:00
Herman Venter
336236d85b Create tasks for TODOs
Summary:
Updated todo comments with task numbers.

Not included in this list:
1) node related todos: Sebastian should do that
2) serializer related todos: Nikolai should do that
3) partial evaluator todos: I should do that, but it will take some time.
Closes https://github.com/facebook/prepack/pull/1024

Differential Revision: D5950510

Pulled By: hermanventer

fbshipit-source-id: 131601c18115d5bf8c1a4e1f6a87e45619acc0ba
2017-09-30 16:25:32 -07:00
Chris Blappert
cd3821ab7e Serialize independent functions
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
2017-09-25 16:53:45 -07:00
Joseph Zhou
8a63ed58b9 Check undefined in addPriorityEffect and add max stack depth
Summary:
Issue: #520

Check if components of priorEffects are null when referenced.
Add a maximum stack depth with a default value of 225 and check stack size against this.
Allow the stack depth to be customizable via the command line.

Reran all tests via yarn validate.
Closes https://github.com/facebook/prepack/pull/960

Differential Revision: D5810838

Pulled By: JWZ2018

fbshipit-source-id: e676c3600d936411d9e82b2849912e60f6729eb9
2017-09-12 12:58:14 -07:00
Nikolai Tillmann
6ca6df1e3a Slight improvement to factorifyObject
Summary:
Treat `void 0` (and similar patterns) as a simple value that factorifyObject can operate on.

This slightly reduces code size with no adverse effects.
Closes https://github.com/facebook/prepack/pull/909

Differential Revision: D5675928

Pulled By: NTillmann

fbshipit-source-id: 399de8bc71e18ee4aa5aada8ca6e093bcb839fc5
2017-08-25 12:53:39 -07:00
Herman Venter
be0bed968c Handle syntax errors
Summary:
Set up an evaluation environment before parsing since the parse helper expects to be able to turn syntax errors into runtime errors.

Catch such errors and report them via handleError when not running eval.

Fixes issue: #900
Closes https://github.com/facebook/prepack/pull/916

Differential Revision: D5689361

Pulled By: hermanventer

fbshipit-source-id: b43a5c6b30e3e93d9e8fb3cc746cbb11f7951bae
2017-08-23 18:09:12 -07:00
Nikolai Tillmann
af73d3f6dc Changing default of --singlePass (and renaming option)
Summary:
Internal data indicates that doing two passes to eliminate unneeded identifiers does not help performance or code size at the bytecode level.
Therefore, I swap the default, and rename the option.
--singlePass is no longer an option, and instead, the old two-pass behavior can be triggered via
--inlineExpressions.

Tweaked test runner to run all serialization tests with inline expressions and without,
marked one test that required inline expressions for its test objective.

This addresses #848.
Closes https://github.com/facebook/prepack/pull/894

Differential Revision: D5650410

Pulled By: NTillmann

fbshipit-source-id: 81d79ac042598d7fdc080a0f1798f68d97f8288b
2017-08-17 21:41:51 -07:00
Herman Venter
3fabe89bf3 Add --debugNames flag to test-runner
Summary:
I needed this for an investigation and it seems like a useful thing to have.
Closes https://github.com/facebook/prepack/pull/896

Differential Revision: D5637604

Pulled By: hermanventer

fbshipit-source-id: 0abbc56ad3e84ac696a625b8d438c5ff4d8f45d7
2017-08-15 19:40:15 -07:00
Christopher Blappert
be70144220 Add option to not emit invariants for model functions
Summary:
FunctionValues should not be compared with `===` from the model. Add an option to disable this invariant.
Closes https://github.com/facebook/prepack/pull/881

Differential Revision: D5626447

Pulled By: cblappert

fbshipit-source-id: 3f0bb71cd6dd0b556e46df85658c715798fa0204
2017-08-15 15:28:26 -07:00
yinghuitan
208c7ab07f Allow Prepack CLI to prepack multiple source files
Summary:
By allowing prepack CLI to prepack multiple files, user can specify separate model file together with source file. Also, it can allow pre-bundled files to be prepacked together.
I also removed prepackString() API to prefer prepackSources() because they are almost identical logic while prepackSources() API supports multiple files.
Closes https://github.com/facebook/prepack/pull/865

Differential Revision: D5566968

Pulled By: yinghuitan

fbshipit-source-id: ce00087e444b5cdf34b5cfb6913062fc0ee440b7
2017-08-14 22:41:24 -07:00
Sangboak Lee
1bbba378d2 Clean up options and fix test code
Summary:
- Clean up options and create new `prepack-options.js` file
- Add `PartialEvaluatorOptions` type which contains only `sourceMaps`
- Fix test code related to above change

https://github.com/facebook/prepack/issues/841
Closes https://github.com/facebook/prepack/pull/878

Reviewed By: NTillmann

Differential Revision: D5605347

Pulled By: cblappert

fbshipit-source-id: 024284a9904dff765417c2c849c4642e781affb3
2017-08-11 14:55:20 -07:00
Herman Venter
ab85a0b734 Tweak test runner to see how many test actually run
Summary:
The rest runner did double counting that went awry when certain tests were either just ES5 or just ES6. I just go annoyed at the lack of precision while debugging test failures and this has been lying around on my machine for far too long.
Closes https://github.com/facebook/prepack/pull/874

Differential Revision: D5586527

Pulled By: hermanventer

fbshipit-source-id: 561743c545ec8c54b64a0b96d972b3de31807b3e
2017-08-08 16:16:55 -07:00
Herman Venter
219961b247 Fixes for prepacking new internal test
Summary:
Added more invariants calls to better enforce the global invariant requiring abstract values with non functional builders to have no arguments.

Also added a way to suppress extraneous errors that may arise while traversing additional function bodies to find read/write conflicts. Fixed the initial traversals to report errors and now pass in parameter needed to allow delayed requires inside these functions.

Fixed a bug in generator where it created an abstract value with a non functional builder and some arguments. Then fixed a bug in JSON.parse where it special cased abstract values produced the wrong way.

Added some logic to test-internal to invoke prepack with specified additional functions if the test case has a particular name. This test has to be run manually since it takes a rather long time to complete.

Added logic to populate CompilerDiagnostic objects with a callStack property so that it is easier to find the ultimate source of a prepack error.
Closes https://github.com/facebook/prepack/pull/869

Differential Revision: D5581023

Pulled By: hermanventer

fbshipit-source-id: 37d7cffe32135b95939b3da81de2a5b3c9df26c4
2017-08-07 20:11:15 -07:00
Herman Venter
50ce236f5e Catch fatal errors in visitName.
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
2017-08-04 11:20:16 -07:00
Chris Blappert
195034443e Does deduplication of pure builtin calls in generator
Summary:
`Date.now()` and `Math.random()` calls emitted into the generator now no longer get serialized if their results are not used. In principle this is safe for any pure definitions of AbstractValues emitted to the generator but that is too hard to determine for most cases.

Adds a test case verifying that extra `Date.now()` calls are eliminated.

See #543 for more detail.
Closes https://github.com/facebook/prepack/pull/822

Differential Revision: D5537430

Pulled By: cblappert

fbshipit-source-id: 4f3e12eee65fdbea7504d73399eddde5a1e93703
2017-08-03 14:10:49 -07:00
Herman Venter
ddefa60949 Specify additional functions using expressions.
Summary:
Additional functions may be properties of global objects, so just parse the option string as an expression and evaluate it in the global environment.
Closes https://github.com/facebook/prepack/pull/858

Differential Revision: D5541434

Pulled By: hermanventer

fbshipit-source-id: b0b39f2b0ff072ebafeba3e33cd2cd1365dfd4b8
2017-08-01 15:33:04 -07:00
Herman Venter
12555b9817 Detect read-write conflicts
Summary:
If one additional function reads a property that is written by another additional function, it becomes potentially dependent on the other function running before it does. Additional functions are supposed to be independent of each other, so we now detect this and report errors.
Closes https://github.com/facebook/prepack/pull/850

Differential Revision: D5529672

Pulled By: hermanventer

fbshipit-source-id: f810d27d1fbf03d6538d70e61a1d9e7c0fe55309
2017-07-31 13:28:20 -07:00
Jeffrey Tan
5b1f55d5f1 Refactor FunctionValue
Summary:
Introduce ECMAScriptFunctionValue and move many fields of FunctionValue down to ECMAScriptFunctionValue. FunctionValue becomes the abstract base class:
1. Use invariant(F instanceof ECMAScriptFunctionValue) if only ECMAScriptFunctionValue is valid in that code path to make flow happy.
2. Replace "F.getType() === FunctionValue" with Value.isTypeCompatibleWith(F.getType(), FunctionValue)
3. $ScriptOrModule may also be able to move down to ECMAScriptFunctionValue, but I am not 100% positive so leave it in FunctionValue for now.
Closes https://github.com/facebook/prepack/pull/824

Differential Revision: D5527976

Pulled By: yinghuitan

fbshipit-source-id: 017748d67c31aa121c35b28b43cef026e904a412
2017-07-31 10:55:23 -07:00
Herman Venter
d37e01846f Specify additional initialization functions to prepack
Summary:
Provide a new option to specify a number of additional functions to prepack (in addition to the global code "function", that is). These functions need to exist in the global scope, have no parameters, be well behaved (never throw an exception) and should not depend on each other (the order in which they get called should not matter).

At the moment there are checks only for existence, good behavior and no write-write conflicts. Also, the functions are not actually prepacked yet.
Closes https://github.com/facebook/prepack/pull/846

Differential Revision: D5514569

Pulled By: hermanventer

fbshipit-source-id: e2e343d9eed4772fc11810d91293facdafca8fcb
2017-07-27 18:38:18 -07:00
Nikolai Tillmann
426dac2ee3 Make delaying of initializations optional
Summary:
That will allow to determine their perf implications.

Cleaned up --help text a bit.
Change serializer test runner to run each test twice, with delaying of initialization and without.
This also effectively re-enables fixed point check, as it is currently disabled whenever the
delaying of initializations kicks in. (See issue #835.)
Closes https://github.com/facebook/prepack/pull/842

Differential Revision: D5504808

Pulled By: NTillmann

fbshipit-source-id: e470d5b7d3b48b2e44819a4e859c48983a887d74
2017-07-26 17:47:17 -07:00
Kishore B. Rao
f862ddd0b8 Updated test262 runner to have parameters
Summary: Closes https://github.com/facebook/prepack/pull/840

Differential Revision: D5503362

Pulled By: Kishore-B-Rao

fbshipit-source-id: ec2a80dfbde9cca17818603632c0bd2413acfe3e
2017-07-26 17:15:16 -07:00
Kishore B. Rao
57952f4656 Fixed bug in test-runner
Summary:
If a test case fails but there were delayedValues it was previously failing
Closes https://github.com/facebook/prepack/pull/834

Differential Revision: D5494450

Pulled By: Kishore-B-Rao

fbshipit-source-id: 4dcacaa4384dd4febb57aa191ba122fd9aa6b416
2017-07-25 17:02:45 -07:00
Herman Venter
f8bf43f673 Update yarn.lock
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
2017-07-25 14:27:51 -07:00
Nikolai Tillmann
4a6beaf285 Tweaking TODOs
Summary: Closes https://github.com/facebook/prepack/pull/836

Differential Revision: D5491776

Pulled By: NTillmann

fbshipit-source-id: 926fc1efdc1f655f9ca11cef9469858a752c96fc
2017-07-25 13:45:40 -07:00
Nikolai Tillmann
777fa225a1 Always use fast traversal function when trivially possible.
Summary:
On a large internal program, this seems to make Prepack around 15% faster overall.
Closes https://github.com/facebook/prepack/pull/826

Differential Revision: D5484863

Pulled By: NTillmann

fbshipit-source-id: 3d8b7b8504645356d7901a4e19fa2e7e1d3f14be
2017-07-24 16:39:31 -07:00
Jeffrey Tan
39ac78f3c5 Improve Test262 test runner
Summary:
Two improvements:
1. The CI has 10340 ES6 tests passing so reflect the latest status in test runner.
2. Always show test failure groups summary even in success situation. This allows us to run the test locally and compare failure groups summary to the baseline summary in CI to find out which specific test group is failing. Saving much time in troubleshooting test failure!
Closes https://github.com/facebook/prepack/pull/820

Differential Revision: D5447438

Pulled By: yinghuitan

fbshipit-source-id: 87fa62693cb6e1365978e5cb635e3732fc2ded09
2017-07-18 15:43:15 -07:00
Herman Venter
8b5f40bcad Downgrade errors to warnings if they occur inside a delayed module
Summary:
If a module get's delayed because of a prepack error, we would like to notify developers about it, but not expose this to them as errors, which would be presumed to break the build.
Closes https://github.com/facebook/prepack/pull/814

Differential Revision: D5434272

Pulled By: cblappert

fbshipit-source-id: 6be27a30706c70b43a925603e62f1750ec395b3f
2017-07-17 10:13:13 -07:00
Herman Venter
fbae09bb75 Throw FatalError after reporting generic introspection error
Summary:
Instead of throwing peculiarly behaving introspection error completions, we now report all errors via the error handler, using CompilerDiagnostic objects that are just normal host objects. Following a report, we always throw a FatalError.

Eventually all of the places where generic introspection errors are thrown will be replaced by specific errors and may have site specific error recovery logic.
Closes https://github.com/facebook/prepack/pull/812

Differential Revision: D5426046

Pulled By: hermanventer

fbshipit-source-id: c6e6121c2658b5005ea956143ea8dbdb9743165a
2017-07-14 14:58:00 -07:00
Chris Blappert
a8d935f27e Fixing output to look less like a failure on success
Summary:
running `yarn run test-std-in` no longer produces output ending in "Error: Fatal ..."
Closes https://github.com/facebook/prepack/pull/810

Differential Revision: D5420702

Pulled By: cblappert

fbshipit-source-id: 7628419dfb16597fef93a1a4b3bcb8f0d1fbd0bb
2017-07-13 16:53:40 -07:00
Herman Venter
f0808ebc36 Rename CompilerDiagnostics to CompilerDiagnostic
Summary:
An instance of this class is a single diagnostic message, so the plural just seems wrong.
Closes https://github.com/facebook/prepack/pull/811

Differential Revision: D5420522

Pulled By: hermanventer

fbshipit-source-id: c848911a27d2c445ba98ee04988f5c4afe261dc1
2017-07-13 16:53:40 -07:00
Herman Venter
ac7daf654b Error messages for for of loops
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
2017-07-12 17:10:26 -07:00
Herman Venter
2145351b38 Test separate model file and fix source maps for comments
Summary:
Adapt the test-internal script to combine separate files containing a model, a source bundle and a source map.

Also extend fixup_filenames to explicitly traverse comments because the default traverser does not do so.
Closes https://github.com/facebook/prepack/pull/789

Differential Revision: D5386836

Pulled By: hermanventer

fbshipit-source-id: da0499cd027ecf94dcde612d0ce831ea1fd4a98b
2017-07-07 23:42:17 -07:00
wdhorton
7f5ec3b43f Making Prettier a check-in gate
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
2017-07-07 11:35:32 -07:00
Sangboak Lee
1c23533c39 Change processSerializedCode func to receive error as 1st arg
Summary:
Since example code of [How to run Prepack](https://github.com/facebook/prepack#how-to-run-prepack) doesn't work(https://github.com/facebook/prepack/issues/781 )
I fixed `processSerializedCode` function to handle error as 1st argument
which follows 'error first callback' convention.
And to verify the changes I've added test code for the case of `StdIn`
Closes https://github.com/facebook/prepack/pull/784

Differential Revision: D5375275

Pulled By: NTillmann

fbshipit-source-id: ea85d0f30db4305aa7fcb5b69bf28f5998a84962
2017-07-06 12:39:48 -07:00
Nikolai Tillmann
4824b47038 Ran Prettier over codebase.
Summary: Closes https://github.com/facebook/prepack/pull/778

Differential Revision: D5367120

Pulled By: NTillmann

fbshipit-source-id: 4c8810efee816d699157e59ea9ba0c8d57950015
2017-07-03 16:29:47 -07:00
Herman Venter
d182dcda70 Allow more than one input file for Prepack
Summary:
We usually need at least two files: 1) the environmental model and 2) the bundle to be Prepacked.
In general, there is no good reason to not allow as many files as the caller wants.

To make this not be a breaking chance, I've added a new API for this: prepackSources.

Further complications result from working around a bug in Babel and not increasing the module cycle length for Flow.
Closes https://github.com/facebook/prepack/pull/776

Differential Revision: D5366190

Pulled By: hermanventer

fbshipit-source-id: 74595b1b60e8e8a6d24cb974b5be10210d745266
2017-07-03 15:08:01 -07:00
Herman Venter
934ee3619a Hook up error handling code for all prepack clients
Summary:
Except for the web site.

Also reorganized the API a bit and deprecated some calls.
Closes https://github.com/facebook/prepack/pull/763

Differential Revision: D5351215

Pulled By: hermanventer

fbshipit-source-id: c5da7f81138f7b0cb97d28da25c5e3fe8836ccb9
2017-07-03 12:08:04 -07:00
wdhorton
8c38d26d4a Implement SuperProperty.
Summary: Closes https://github.com/facebook/prepack/pull/764

Differential Revision: D5356550

Pulled By: NTillmann

fbshipit-source-id: d4b87b6645cab5ae6758a664cb7c530b6e9c64dc
2017-06-30 11:43:12 -07:00
Kishore B. Rao
a6cb03b5e6 Updated Sandcastle Tests
Summary: Sandcastle Tests now prepack a checked in version of instagram on every single diff. Of note is that to run the test-internal locally you need to put the instagram bundles in a directory called facebook/test as this is the cleanest way to run these tests internally. The buck targets are updated and still exist but are not entirely necessary right now. If people outside of prepack want to build it and use it, however, they could link up with the buck target.

Reviewed By: cblappert

Differential Revision: D5335451

fbshipit-source-id: 102cb228e0b422b399605132de96b881cd4233e7
2017-06-30 00:55:26 -07:00
wdhorton
f909b69a74 Enable Prettier and remove conflicting eslint rules.
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
2017-06-29 12:23:49 -07:00
wdhorton
50a8d90902 Implement SuperCall.
Summary:
This now works in the repl:
```
$ yarn repl
yarn repl v0.24.6
$ node lib/repl-cli.js
> class Foo { constructor() { this.x = 2 }}
undefined
> let f = new Foo()
undefined
> f
{ x: 2 }
> class Bar extends Foo { constructor() { super() } }
undefined
> let b = new Bar()
undefined
> b
{ x: 2 }
```
Closes https://github.com/facebook/prepack/pull/762

Differential Revision: D5339029

Pulled By: hermanventer

fbshipit-source-id: 6ad6b7f80b95bf5edd5ba2c5971dc8a82912dd14
2017-06-28 15:11:01 -07:00