{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/7178","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/7178/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/7178/comments","events_url":"https://api.github.com/repos/facebook/react/issues/7178/events","html_url":"https://github.com/facebook/react/pull/7178","id":163550801,"number":7178,"title":"RFC: Flat bundle using Rollup","user":{"login":"keyanzhang","id":2268452,"avatar_url":"https://avatars.githubusercontent.com/u/2268452?v=3","gravatar_id":"","url":"https://api.github.com/users/keyanzhang","html_url":"https://github.com/keyanzhang","followers_url":"https://api.github.com/users/keyanzhang/followers","following_url":"https://api.github.com/users/keyanzhang/following{/other_user}","gists_url":"https://api.github.com/users/keyanzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/keyanzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keyanzhang/subscriptions","organizations_url":"https://api.github.com/users/keyanzhang/orgs","repos_url":"https://api.github.com/users/keyanzhang/repos","events_url":"https://api.github.com/users/keyanzhang/events{/privacy}","received_events_url":"https://api.github.com/users/keyanzhang/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-03T07:12:56Z","updated_at":"2016-07-03T15:32:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react/pulls/7178","html_url":"https://github.com/facebook/react/pull/7178","diff_url":"https://github.com/facebook/react/pull/7178.diff","patch_url":"https://github.com/facebook/react/pull/7178.patch"},"body":"Not for merging -- we could consider looking more into using this in our build pipeline temporarily before Prepack lands.\r\n\r\nThis implements #6351 using Rollup. It could be used to replace our Browserify build step (i.e., it takes pre-built files from `./build/modules`) and it's pretty similar to #4230.\r\n\r\nFirstly I moved all our non-top-level requires to the top level and `__DEV__` on their usage (we only have 5 files that have that). Since we no longer have dynamic parts in our require/exports, they are pretty much ES6-compliant. Then there's a Babel pass for Rollup to firstly rewrite all require/exports to ES6 import/exports, and finally it bundles to a flat file (in UMD format). It sounds weird to transpile files from ES5 to ES6 but using this babel pass results in smaller file sizes comparing with using Rollup's CommonJS plugin.\r\n\r\nThis decreases our gzipped minified (prod) file size by ~10% and some of the benchmarks look pretty good. The bundled files can be found at [react.rollup.dev.js](https://gist.github.com/keyanzhang/8e2443b525b61cd48ac40c0f3679b433) and [react.rollup.prod.js](https://gist.github.com/keyanzhang/b8904d0c6d680606cd62e1e115e01092).\r\n\r\ncc @facebook/react-core \r\n\r\n### Size Comparison\r\n```diff\r\nRunning \"compare_size:files\" (compare_size) task\r\n     raw     gz Sizes\r\n    1199    641 build/react-dom-server.js\r\n     734    445 build/react-dom-server.min.js\r\n    1180    632 build/react-dom.js\r\n     715    436 build/react-dom.min.js\r\n  774447 173483 build/react-with-addons.js\r\n  176417  52015 build/react-with-addons.min.js\r\n  695761 157010 build/react.js\r\n+ 596893 142810 build/react.rollup.dev.js\r\n  157203  46707 build/react.min.js\r\n+ 138950  41844 build/react.rollup.prod.js\r\n```\r\n\r\n### Benchmarks\r\n(Raw benchmark data is at https://gist.github.com/keyanzhang/1e2a97faebb5fab01a40c27d26657538)\r\n```\r\nComparing master.prod.txt (control) vs rollup.prod.txt (test)\r\nSignificant differences marked by ***\r\n% change from control to test, with 99% CIs:\r\n\r\n* factory_ms_jsc_jit\r\n    % change: -35.74% [-38.44%, -33.04%]  ***\r\n    means: 17.0817 (control), 10.9784 (test)\r\n* factory_ms_jsc_nojit\r\n    % change: -34.88% [-36.30%, -33.46%]  ***\r\n    means: 15.5858 (control), 10.1497 (test)\r\n* factory_ms_node\r\n    % change: -34.78% [-36.47%, -33.09%]  ***\r\n    means: 50.007 (control), 32.6145 (test)\r\n* ssr_pe_cold_ms_jsc_jit\r\n    % change:  +0.88% [ -1.76%,  +3.52%]\r\n    means: 43.1005 (control), 43.4825 (test)\r\n* ssr_pe_cold_ms_jsc_nojit\r\n    % change:  -0.89% [ -3.53%,  +1.75%]\r\n    means: 48.4863 (control), 48.0558 (test)\r\n* ssr_pe_cold_ms_node\r\n    % change:  -1.50% [ -3.14%,  +0.13%]\r\n    means: 89.2362 (control), 87.8974 (test)\r\n```\r\n\r\n```\r\nComparing master.dev.txt (control) vs rollup.dev.txt (test)\r\nSignificant differences marked by ***\r\n% change from control to test, with 99% CIs:\r\n\r\n* factory_ms_jsc_jit\r\n    % change: -32.10% [-35.94%, -28.27%]  ***\r\n    means: 23.8355 (control), 16.1858 (test)\r\n* factory_ms_jsc_nojit\r\n    % change: -34.35% [-36.68%, -32.01%]  ***\r\n    means: 21.3096 (control), 13.9926 (test)\r\n* factory_ms_node\r\n    % change: -35.43% [-37.27%, -33.58%]  ***\r\n    means: 76.5925 (control), 49.4613 (test)\r\n* ssr_pe_cold_ms_jsc_jit\r\n    % change:  -4.89% [ -7.44%,  -2.34%]  ***\r\n    means: 208.343 (control), 198.178 (test)\r\n* ssr_pe_cold_ms_jsc_nojit\r\n    % change:  -4.33% [ -6.86%,  -1.81%]  ***\r\n    means: 269.641 (control), 257.977 (test)\r\n* ssr_pe_cold_ms_node\r\n    % change:  -4.92% [ -8.51%,  -1.33%]  ***\r\n    means: 317.876 (control), 302.3 (test)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/230159207","html_url":"https://github.com/facebook/react/pull/7178#issuecomment-230159207","issue_url":"https://api.github.com/repos/facebook/react/issues/7178","id":230159207,"user":{"login":"keyanzhang","id":2268452,"avatar_url":"https://avatars.githubusercontent.com/u/2268452?v=3","gravatar_id":"","url":"https://api.github.com/users/keyanzhang","html_url":"https://github.com/keyanzhang","followers_url":"https://api.github.com/users/keyanzhang/followers","following_url":"https://api.github.com/users/keyanzhang/following{/other_user}","gists_url":"https://api.github.com/users/keyanzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/keyanzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keyanzhang/subscriptions","organizations_url":"https://api.github.com/users/keyanzhang/orgs","repos_url":"https://api.github.com/users/keyanzhang/repos","events_url":"https://api.github.com/users/keyanzhang/events{/privacy}","received_events_url":"https://api.github.com/users/keyanzhang/received_events","type":"User","site_admin":false},"created_at":"2016-07-03T15:32:31Z","updated_at":"2016-07-03T15:32:31Z","body":"Yeah, its DCE + tree shaking is really impressive. Here's an unminified production build bundled by Rollup: https://gist.github.com/keyanzhang/1dff99f6f54bcf9d4e3cc92ab407c41e."}}
{"actor":{"display_login":"keyanzhang"}}