Convert current build system to Rollup and adopt flat bundles #9327

Merged
merged 194 commits into from Apr 5, 2017

Conversation

Projects
None yet
@trueadm
Contributor

trueadm commented Apr 4, 2017

The current build process for React (using Gulp, Grunt and Browserify) is cumbersome and overly-complicated. It doesn't allow us to unify our external open-source and our internal Facebook processes very well. This PR introduced an entirely new system that replaces the old build system.

We now leverage the creation of flat bundles, that force users to work with a single point of entry. This allows us to make better optimizations, improve our bundle size, improve the DEV/PROD experience and allows us to control how people use the APIs offered by React and the various different React renderers.

Supersedes #4927. Fixes #6351.

  • Set up a basic build process @trueadm
  • Add forwarding modules @trueadm
  • Fix ReactPerf circular dependency with ReactGKJSModule @gaearon
  • Fix CurrentOwner exception
  • Fix "addComponentAsRefTo(...): Only a ReactOwner can have refs." @trueadm
  • Figure out a fix for Rollup flat bundle breaking www @trueadm rollup/rollup-plugin-commonjs#176
  • Fix dynamic injection breaking because forwarding modules don't know which bundle to refer to @gaearon
  • Clean up before build and add a shortcut for building one bundle type @trueadm
  • Fix all missing static resources @gaearon
  • Figure out how to inject feature flags into the bundle correctly @gaearon
  • Figure out how to inject error utils and Fiber error dialog @gaearon
  • Add a ReactART build @gaearon
  • Add a ReactDOMServer build @trueadm
  • Rebase www now that Sebastian landed the sync @gaearon
  • CommonJS bundles shouldn't contain DEV code (for prod) or process.env.NODE_ENV checks since those are slow. We should have separate CommonJS builds for development and production, and switch based on NODE_ENV between them. @trueadm
  • Fork addons internally @gaearon
  • Make build handle NPM packages, facebook-www and UMD dist @trueadm
  • Remove -core indirection internally @gaearon
  • Figure out a plan for responder/tap plugins, reactComponentExpect etc where we'd still like to be the source of truth
  • Fix KB profiler not to rely on internals @trueadm
  • Figure out how to remove ReactPerf and ReactTestUtils (especially shallow renderer) from www bundles in prod mode
  • Check for duplicated output and do some initial profiling @trueadm
  • Ensure we have license headers both for our code and object-assign in all bundles @trueadm
  • Delete examples, move examples/fiber to fixtures, and check docs for links to examples
  • Figure out the plan for ReactDOMServer bundle
  • Fix DOM fixtures and fiber debugger
  • Fix ART UMD build
  • Add ReactDOMServerStack CommonJS entry point to react-dom/server
  • Do initial work for RN flat bundle (the rest is follow up)
  • Figure out the plan for TapEventPlugin and friends
  • Remove dependency on Node 7 (we only have Node 4 on devservers)
  • Ensure packages contain PATENTS and other relevant files as they did before
  • Update www sync script

trueadm and others added some commits Mar 7, 2017

Use -core suffix for all bundles
This makes it easier to override things in www.
Add a lazy shim for ReactPerf
This prevents a circular dependency between ReactGKJSModule and ReactDOM
Change forwarding modules to import from -fb
This is another, more direct fix for ReactPerf circular dependency
Revert "should improve console output"
This breaks the FB bundles.

This reverts commit 65f11ee.
Externalize feature flags
This lets www specify them dynamically.
Remove forwarding modules with implementations
Instead I'm adding them to react-fb in my diff.
Revert "Hack around to fix RN bundle"
We'll do this later.

This reverts commit 59445a6.
@AshebirGetuBelete

This comment has been minimized.

Show comment
Hide comment
@AshebirGetuBelete

AshebirGetuBelete Apr 4, 2017

Real pull requiest

Real pull requiest

@gaearon

gaearon approved these changes Apr 5, 2017

@trueadm trueadm merged commit 4b2eac3 into facebook:master Apr 5, 2017

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@gaearon gaearon deleted the trueadm:rollup branch Apr 5, 2017

@gaearon

This comment has been minimized.

Show comment
Hide comment
@gaearon

gaearon Apr 5, 2017

Member

Epic.

Member

gaearon commented Apr 5, 2017

Epic.

@nhunzaker

This comment has been minimized.

Show comment
Hide comment
@nhunzaker

nhunzaker Apr 5, 2017

Collaborator

Oh my oh my

Collaborator

nhunzaker commented Apr 5, 2017

Oh my oh my

This was referenced Apr 5, 2017

@trueadm trueadm referenced this pull request Apr 5, 2017

Closed

Build distinct dev / prod & min builds #7242

0 of 4 tasks complete
@yasserkaddour

This comment has been minimized.

Show comment
Hide comment
@yasserkaddour

yasserkaddour Apr 5, 2017

Congrats 🎉, should close #6656 too.

Congrats 🎉, should close #6656 too.

@maxdeviant

This comment has been minimized.

Show comment
Hide comment
@maxdeviant

maxdeviant Apr 5, 2017

Contributor

Nice work @trueadm and @gaearon 🎉

Contributor

maxdeviant commented Apr 5, 2017

Nice work @trueadm and @gaearon 🎉

@robrichard robrichard referenced this pull request in facebook/relay Apr 6, 2017

Open

Adopt flat bundles #1590

@rohmanhm

This comment has been minimized.

Show comment
Hide comment
@rohmanhm

rohmanhm Apr 7, 2017

This article make me understand why did you choose Rollup over webpack.
Nice works
https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c

rohmanhm commented Apr 7, 2017

This article make me understand why did you choose Rollup over webpack.
Nice works
https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c

@fxfactorial

This comment has been minimized.

Show comment
Hide comment
@fxfactorial

fxfactorial Apr 7, 2017

Contributor

Is there a specific reason why devservers only have node 4?

Contributor

fxfactorial commented Apr 7, 2017

Is there a specific reason why devservers only have node 4?

@gaearon

This comment has been minimized.

Show comment
Hide comment
@gaearon

gaearon Apr 7, 2017

Member

Not really, we just update slower than others because we don't use Node much.

Member

gaearon commented Apr 7, 2017

Not really, we just update slower than others because we don't use Node much.

@wayou

This comment has been minimized.

Show comment
Hide comment
@wayou

wayou Apr 9, 2017

rollup 🎉

wayou commented Apr 9, 2017

rollup 🎉

@liuliangsir

This comment has been minimized.

Show comment
Hide comment
@liuliangsir

liuliangsir Apr 14, 2017

@wayou i has seen your blog since a year ago
it sounds great, for example a blog article("chrome-console-tips-and-tricks")

liuliangsir commented Apr 14, 2017

@wayou i has seen your blog since a year ago
it sounds great, for example a blog article("chrome-console-tips-and-tricks")

@thiamsantos thiamsantos referenced this pull request in flitbit/diff Apr 20, 2017

Closed

Change module system of the main file #92

@debloper debloper referenced this pull request in fabric8-ui/fabric8-planner May 23, 2017

Open

[Tracker] Switch to a better build system #1920

0 of 1 task complete

@thiamsantos thiamsantos referenced this pull request in thiagommedeiros/bus-promise Jul 14, 2017

Merged

Usar rollup #34

@trueadm trueadm restored the trueadm:rollup branch Aug 16, 2017

@gaearon gaearon deleted the trueadm:rollup branch Nov 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment