Use Rollup legacy mode for www builds#11469
Merged
gaearon merged 1 commit intofacebook:masterfrom Nov 6, 2017
Merged
Conversation
Ethan-Arrowood
pushed a commit
to Ethan-Arrowood/react
that referenced
this pull request
Dec 8, 2017
elas7
added a commit
to elas7/react
that referenced
this pull request
Aug 9, 2018
The `legacy` option was added to the Rollup build system (for www builds) in facebook#11469 because the internal transforms break on getters. As of version 0.60.0 of Rollup, `legacy` support is removed ([source](rollup/rollup#2141), [changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md#0600)). This PR adds a custom Rollup plugin to replicate the `legacy` behaviour. Note that the `legacy` option preformed several transformations to support IE8. The custom Rollup plugin only replicates the replacement of getters ([original code here](https://github.com/rollup/rollup/blob/349677ceee9d4bbccb5b2f72e653270cb2b0ce51/src/ast/variables/NamespaceVariable.ts#L63)). Also note that getters are only generated in a very specific case by Rollup. That is, when doing namespace imports (`import * as name from 'origin'`) and one of the imported variables is reassigned at some point (an example of this can be found in the [old Rollup tests](https://github.com/rollup/rollup/tree/349677ceee9d4bbccb5b2f72e653270cb2b0ce51/test/form/samples/legacy-getter)). At this time, the only getter generated by React code is `ReactDOMEventListener._enabled`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns out our internal transforms break on getters.
Let's just not emit them in www bundles.
Diff: https://gist.github.com/gaearon/9f79b3d2e177013292f3a20a83207f03/revisions