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

perf(v2): use @babel/runtime plugin to reduce codesize #2035

Merged
merged 1 commit into from
Nov 24, 2019
Merged

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Nov 23, 2019

Motivation

Utilize https://babeljs.io/docs/en/babel-plugin-transform-runtime/

WHY ?

Babel uses very small helpers for common functions such as _extend. By default this will be added to every file that requires it. This duplication is sometimes unnecessary, especially when your application is spread out over multiple files.

This is where the @babel/plugin-transform-runtime plugin comes in: all of the helpers will reference the module @babel/runtime to avoid duplication across your compiled output. The runtime will be compiled into your build.

See https://babeljs.io/docs/en/babel-plugin-transform-runtime/#why for more details.

Also checked CRA, Razzle and Gatsby. They are using it too.
See test plan for benefits

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

Before
Parsed Size: All 1.28mb main 221.62kb
before-all1 28mb-main221 62kb

Gzipped Size: All 409.58kb main 69.98kb
before-all409 58kb-main69 98kbgzipped

After
Parsed Size: All 1.2mb main 206.94kb
after-all1 25mb-main206 94kb

Gzipped size: All 399.19kb main 64.63kb
after-all399 19kb-main64 63kbgzipped

@endiliey endiliey added the pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. label Nov 23, 2019
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 23, 2019
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 75f3fb2

https://deploy-preview-2035--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 75f3fb2

https://deploy-preview-2035--docusaurus-preview.netlify.com

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

Good perf win :)

@yangshun yangshun merged commit baabe1f into master Nov 24, 2019
@yangshun yangshun deleted the endi/runtime branch November 24, 2019 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants