Skip to content
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

Consolidate build process with GCC #11483

Merged
merged 3 commits into from
Nov 8, 2017
Merged

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 7, 2017

This completely gets rid of Uglify in our build process. GCC provides better DCE for the FB bundles (e.g. the persistence path is now dead code eliminated in www, and mutation path is eliminated in CS). And this unifies our build process with how we already build UMD/CJS.

I forked GCC to add google/closure-compiler#2707. Hopefully this gets merged but if not, it’s a pretty simple change to maintain. Then I recompiled the google-closure-compiler-js package and pointed Yarn lockfile to my fork (easier than forking another dependency layer up from there). I verified with Yarn folks it’s a supported (although a bit unobvious) way to point dependency to a fork (and this is pretty much what custom registry support relies on).

GCC doesn't preserve whitespace so I added Prettier after it for FB/RN bundles.

I also took an opportunity to clean up how we apply Rollup plugins in general, and set up a single chain instead of switches. This should make bundles more uniform across the build targets.

Some DEV sizes decreased because I started dropping per-file license headers. FB PROD sizes decreased because of better DCE and less whitespace.

RN DEV sizes increased because I did not add Closure to them whereas in the past they did use Uglify (for DEV). I'm not sure why it was desirable and it seemed better to make them un-Closure'd just like FB_DEV builds are. But I can change that if you want to. Mainly I just want to keep DEV bundles with comments, and Closure can't preserve them.

And that's about it! I hope to test and maybe land this on Thursday after shipping 16.1.

@gaearon gaearon changed the title [WIP] Replace Uglify with (forked) GCC Replace Uglify with (forked) GCC for FB/RN builds Nov 8, 2017
@gaearon gaearon force-pushed the fork-gcc-2 branch 3 times, most recently from f3b06ea to 59287b6 Compare November 8, 2017 01:17
@gaearon gaearon changed the title Replace Uglify with (forked) GCC for FB/RN builds Consolidate build process with GCC Nov 8, 2017
Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all the node bundle sizes for production all seem to have regressed. Is this expected?

const shims = Modules.getShims(bundleType, entry, featureFlags);
const plugins = [
const isProduction = isProductionBundleType(bundleType);
const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure this is the best name. Maybe isUMDBundle?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be more bundle types where top-level things are declared in global scope. In theory. :-)

);
return plugins;
}),
].filter(Boolean);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure this is super obvious as to what’s happening?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, seems like a common pattern with plugin systems?

screen shot 2017-11-08 at 08 11 31

Happy to change to something explicit if you prefer.

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 8, 2017

Almost all the node bundle sizes for production all seem to have regressed

I only see a ~20 byte difference. If that's what you're referring to, yes, it's expected because we no longer try to compress the license header, and it's consistent for DEV and PROD bundles.

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 8, 2017

Added a second commit that doesn't change the build output, but breaks out the bundle header/footer logic into a separate file, and restructures it to be more explicit. This makes build.js really focused.

It is easier to understand if we just explicitly type them out.
Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaearon gaearon merged commit c83596d into facebook:master Nov 8, 2017
@gaearon gaearon deleted the fork-gcc-2 branch November 8, 2017 22:37
Ethan-Arrowood pushed a commit to Ethan-Arrowood/react that referenced this pull request Dec 8, 2017
* Consolidate build process with GCC

* Record sizes

* Refactor header and footer wrapping

It is easier to understand if we just explicitly type them out.
@0xdevalias 0xdevalias mentioned this pull request Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants