prepack/package.json
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

120 lines
5.6 KiB
JSON

{
"name": "prepack",
"version": "0.2.11-alpha.0",
"description": "Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.",
"homepage": "https://github.com/facebook/prepack",
"repository": {
"type": "git",
"url": "git://github.com/facebook/prepack.git"
},
"bugs": {
"url": "https://github.com/facebook/prepack/issues"
},
"files": [
"LICENSE",
"PATENTS",
"bin/",
"lib/"
],
"bin": {
"prepack": "bin/prepack.js",
"prepack-repl": "bin/prepack-repl.js"
},
"main": "lib/prepack-node.js",
"browser": "lib/prepack-standalone.js",
"scripts": {
"build": "babel src --out-dir lib --source-maps && yarn build-bundle",
"build-scripts": "babel scripts --out-dir lib --source-maps",
"build-bundle": "webpack",
"watch": "babel src scripts --out-dir lib --watch --source-maps",
"lint": "eslint src scripts",
"flow": "flow check",
"test-residual": "babel-node scripts/test-residual.js",
"test-residual-with-coverage": "./node_modules/.bin/istanbul cover ./lib/test-residual.js --dir coverage.residual && ./node_modules/.bin/remap-istanbul -i coverage.residual/coverage.json -o coverage-sourcemapped.residual -t html",
"test-serializer": "babel-node --stack_trace_limit=200 --stack_size=10000 scripts/test-runner.js",
"test-serializer-with-coverage": "./node_modules/.bin/istanbul cover ./lib/test-error-handler.js --dir coverage.error && ./node_modules/.bin/istanbul cover ./lib/test-runner.js && ./node_modules/.bin/remap-istanbul -i coverage.error/coverage.json -i coverage/coverage.json -o coverage-sourcemapped -t html",
"test-sourcemaps": "babel-node scripts/generate-sourcemaps-test.js && bash < scripts/test-sourcemaps.sh",
"test-test262": "babel-node scripts/test262-runner.js",
"test-test262-nightly": "NIGHTLY_BUILD=true babel-node -- scripts/test262-runner.js",
"test-internal": "babel-node --stack_size=10000 --stack_trace_limit=200 --max_old_space_size=16384 scripts/test-internal.js",
"test-error-handler": "babel-node scripts/test-error-handler.js",
"test-error-handler-with-coverage": "./node_modules/.bin/istanbul cover ./lib/test-error-handler.js --dir coverage.error && ./node_modules/.bin/remap-istanbul -i coverage.error/coverage.json -o coverage-sourcemapped.error -t html",
"test-node-cli-mode": "bash < scripts/test-node-cli-mode.sh",
"test-std-in": "bash < scripts/test-std-in.sh",
"test-react": "jest scripts/test-react",
"test": "yarn test-residual && yarn test-serializer && yarn test-sourcemaps && yarn test-error-handler && yarn test-std-in && yarn test-test262 && yarn test-react && yarn test-internal",
"test-coverage-most": "./node_modules/.bin/istanbul --stack_size=10000 --max_old_space_size=16384 cover ./lib/multi-runner.js --dir coverage.most && ./node_modules/.bin/remap-istanbul -i coverage.most/coverage.json -o coverage-sourcemapped -t html",
"test-all-coverage": "./node_modules/.bin/istanbul --stack_size=10000 --max_old_space_size=16384 cover ./lib/multi-runner.js --dir coverage.most && ./node_modules/.bin/istanbul --stack_size=10000 --max_old_space_size=16384 cover -- ./lib/test262-runner.js --timeout 50 --singleThreaded && ./node_modules/.bin/remap-istanbul -i coverage/coverage.json -i coverage.most/coverage.json -o coverage-sourcemapped -t html",
"repl": "node lib/repl-cli.js",
"prepack": "node lib/prepack-cli.js",
"prepack-prepack": "node --stack_size=10000 --max_old_space_size=8096 ./bin/prepack.js ./lib/prepack-cli.js --out ./lib/prepack-cli.prepacked.js --compatibility node-cli --mathRandomSeed rnd",
"validate": "yarn build && yarn build-scripts && yarn lint && yarn depcheck && yarn flow && yarn test",
"prepublish": "yarn build",
"depcheck": "babel-node scripts/detect_bad_deps.js",
"prettier": "node ./scripts/prettier.js write-changed",
"prettier-all": "node ./scripts/prettier.js write"
},
"dependencies": {
"babel-core": "^6.26.0",
"babel-generator": "^6.8.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-template": "^6.9.0",
"babel-traverse": "^6.9.0",
"babel-types": "^6.9.0",
"babylon": "^6.18.0",
"base62": "^1.1.2",
"queue-fifo": "^0.2.3",
"seedrandom": "^2.4.2",
"source-map": "^0.5.6",
"vscode-debugadapter": "^1.24.0",
"vscode-debugprotocol": "^1.24.0"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-eslint": "^7.1.1",
"babel-helper-function-name": "^6.8.0",
"babel-helper-get-function-arity": "^6.8.0",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-preset-env": "^1.4.0",
"babel-preset-react": "^6.5.0",
"chalk": "^1.1.3",
"eslint": "^3.8.1",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-flow-header": "^0.1.1",
"eslint-plugin-flowtype": "^2.20.0",
"eslint-plugin-header": "^1.0.0",
"eslint-plugin-prettier": "^2.1.2",
"flow-bin": "^0.58.0",
"graceful-fs": "^4.1.11",
"invariant": "^2.2.0",
"istanbul": "^0.4.5",
"jest": "^21.2.1",
"js-yaml": "^3.6.1",
"jsdom": "^9.2.1",
"kcheck": "^2.0.0",
"madge": "^1.6.0",
"minimist": "^1.2.0",
"prettier": "1.5.2",
"react": "^16.0.0",
"react-test-renderer": "^16.0.0",
"remap-istanbul": "^0.9.1",
"source-map-support": "^0.4.6",
"uglify-js": "^2.6.2",
"webpack": "^2.3.3"
},
"engines": {
"node": ">=6.1.0"
},
"keywords": [
"prepack"
],
"license": "BSD-3-Clause",
"author": "Facebook",
"jest": {
"testMatch": [
"**/scripts/test-react.js"
]
}
}