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

bundle size #12

Closed
nativanando opened this issue May 24, 2021 · 7 comments
Closed

bundle size #12

nativanando opened this issue May 24, 2021 · 7 comments

Comments

@nativanando
Copy link

nativanando commented May 24, 2021

Hi, I've been using phosphor-react in some projects and I identified some bundle size problems.. Analysing the bundle I could realize that phosport-react is using almost 60% of the space used.

I don't know it's the expected behavior so I opened this issue to report this situation!

bundle-size-phosport

@rektdeckard
Copy link
Member

The react library fully supports tree-shaking, so it likely comes down to your bundler configuration or the way you're importing the icons. In apps bootstrapped with create-react-app, or when using most modern bundlers, simply using destructuring imports should work fine:

import { Smiley, Rainbow } from "phosphor-react";

Screenshot from 2021-05-24 23-28-51

Using the default import, import Phosphor from "phosphor-react"; or importing everything import * as Icons from "phosphor-react"; may or may not import the entire contents of the library, so try not to do that.

Screenshot from 2021-05-24 23-28-27

If you need to, you can import icons directly from the bundled source:

import Smiley from "phosphor-react/dist/icons/Smiley.esm.js";

@nativanando
Copy link
Author

nativanando commented May 26, 2021

Thanks for the explanation, I was using destructuring imports and the bundle was still big.. But, Happily the problem was in the lib version I was using (1.0.0) I've just updated to 1.2.1 and, great news, problem solved!! 😄

@dnsking
Copy link

dnsking commented Apr 7, 2022

This is still happening in [1.4.1]

@Adam-Collier
Copy link

Same here using 1.4.0!

@JoTrdl
Copy link

JoTrdl commented Nov 29, 2022

I confirm, still happening in 1.4.1

@lmichailian
Copy link

Some news on this ?

@rektdeckard
Copy link
Member

@lmichailian can you provide details on your environment, bundler, and usage? As stated before, the current version of this package is tree-shakeable, but that does not mean your bundler can do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants