-
Notifications
You must be signed in to change notification settings - Fork 46.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Closure Compiler to compile to ES5 instead of Babel #18449
Conversation
be6aa3e
to
6fc2e25
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2979cee:
|
Details of bundled changes.Comparing: 9b88b78...2979cee react-dom
react-flight-dom-webpack
react-test-renderer
react-native-renderer
react-flight-dom-relay
react-refresh
react-art
react-server
react-is
jest-react
react-noop-renderer
react-reconciler
react-client
ReactDOM: size: 0.0%, gzip: -0.0% Size changes (stable) |
Details of bundled changes.Comparing: 9b88b78...2979cee react-dom
react-flight-dom-webpack
react-test-renderer
react-flight-dom-relay
react-refresh
react-art
react-native-renderer
react-noop-renderer
react-server
react-is
react-reconciler
jest-react
react-client
ReactDOM: size: -0.5%, gzip: 🔺+0.2% Size changes (experimental) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Symbol stuff looks hacky, but I guess is fine for now. Can we reach out, like we have in the past, to the GCC folks and get them to help us out?
There are newer versions but they don't yet have corresponding releases of google-closure-compiler-osx.
Provides a little better output.
6fc2e25
to
2979cee
Compare
While trying to do some static compilation refactoring, I noticed that Closure Compiler uses particularly
let
vsconst
to do optimization. We're better off leaving the code as ES2015 and letting Closure Compiler compile it down to ES5.Unfortunately it tries to also compile calls to native functions to runtime polyfills. There's an option to opt out of that but it has a bug with Symbols. I had to work around Symbols a bit. We'll have to be careful with that as we add new ES2015 library calls (Object.assign and Array.from seems fine).
I also used a different Babel config for builds than the general project one which is also used for running tests. We should try to keep this config limited.
Maybe one day we can skip Babel all together.
Diff of the build output. sebmarkbage/react-builds@a63c7ee