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

Reduce bundle size #22

Open
timlrx opened this issue Dec 16, 2020 · 6 comments
Open

Reduce bundle size #22

timlrx opened this issue Dec 16, 2020 · 6 comments
Labels
enhancement New Request

Comments

@timlrx
Copy link
Contributor

timlrx commented Dec 16, 2020

The bundle is more than 0.5MB - yikes!
image

G6 and the other Antv packages are more than 60%. I believe lodash is because of a graphin import: https://github.com/antvis/Graphin/blob/master/packages/graphin/src/controller/layout/dataChecker.ts#L2

The full G6 bundle is also due to how Graphin is importing the full G6 library instead of the necessary components.

Let's see if Graphin 2.0 reduces the bloat

@CodesAreHonest
Copy link
Contributor

Screenshot 2020-12-21 at 11 27 14 AM

react-icons contribute to large size of bundle, might need to look for alternatives such as @material-ui/icons or reuse ant design's icon as we already have @ant-design/icons imported.

Unpacked Size of Icons Libraries

Name Unpacked Size
react-icons 36.5 MB
@material-ui/icons 10.2MB
@ant-design/icons 13.7MB

@timlrx
Copy link
Contributor Author

timlrx commented Dec 21, 2020

Hmm, strange that your bundle is quite different from mine. react-icons should have tree-shaking such that only the required icons are imported and not everything. Might want to take a look to see if there's any stray import * around

@CodesAreHonest
Copy link
Contributor

Hmm, strange that your bundle is quite different from mine. react-icons should have tree-shaking such that only the required icons are imported and not everything. Might want to take a look to see if there's any stray import * around

Did not find any stray with import * in the entire codebase. I analyse the bundle size with npm run build and npm run analyze, not sure we are using the same way to analyse the bundle.

@timlrx
Copy link
Contributor Author

timlrx commented Dec 21, 2020

Yes, I re-run it and get the same as my first post. Might be leftovers from the previous builds? Can you try deleting the old dist and re-building?

@CodesAreHonest
Copy link
Contributor

Removed the old dist/, perform rebuild and run bundle analyser, it still the same.

@CodesAreHonest
Copy link
Contributor

Removed the old dist/, perform rebuild and run bundle analyser, it still the same.

Remove node_modules and rebuild with npm install solve the problems. At the same time, I wrongly upload the screenshot from port 8888 and caused misunderstanding.

@timlrx timlrx added the enhancement New Request label Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New Request
Projects
None yet
Development

No branches or pull requests

2 participants