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

builld is too big #67

Open
m4rcTr3y opened this issue Aug 30, 2021 · 6 comments
Open

builld is too big #67

m4rcTr3y opened this issue Aug 30, 2021 · 6 comments

Comments

@m4rcTr3y
Copy link

m4rcTr3y commented Aug 30, 2021

when project is built in nuxt, the mdijs bundle is big its about 1.+MBs .. how do i reduce it

@therufa
Copy link
Owner

therufa commented Aug 30, 2021

hi @m4rcTr3y,

to me it seems that you import all the icons, but sadly the bundler can't shake off unused ones. In order to reduce the build, you could include only the specific icons you use in your build. A bit less convenient, but to my knowledge, it's the only way to deal with this issue in this setup.

so instead of going with:

import * as mdijs from '@mdi/js'

// .....

createApp(App).use(mdiVue, {
  icons: mdijs
})

you could try this:

import {
   mdiPlayStation,
   mdiAccount,
   mdiAccessPoint
   // etc ...
} from '@mdi/js'

// .....

createApp(App).use(mdiVue, {
  icons: {
	mdiPlayStation,
	mdiAccount,
	mdiAccessPoint,
	// and so on
  }
})

I hope this solves your issues regarding build size, convenience-wise there's little I can do right now.

@loxK
Copy link

loxK commented Nov 15, 2021

@therufa Hi. So what is the point of importing at createApp stage ? Isn't it better to import in each component where the icons are used to take advantage of features like code splitting ?

@therufa
Copy link
Owner

therufa commented Nov 15, 2021

Hi @loxK, The main reason to moving everything to the init state was to reduce the build size of this package. Before we were close to 20Mb which I didn't feel comfortable with (even though this wouldn't translate to the end product) serving several thousand times a month.
The explicit import serves the sake of code splitting, since the @mdi/js lib is basically just one large file with all the paths for all the icons of the mdi library.

I hope this clarifies some of your questions. As with everything I'm open for recommendations regarding improvement, every contribution is welcome ;)

@Zony-Zhao
Copy link

image
I still have a huge mdi bundle. Is there anything I'm missing?
image

@nadirabbas
Copy link

@Zony-Zhao When you build the project, it will be smaller.

@crhistianramirez
Copy link

@therufa I think your concern is valid but misplaced. Developers are going to opt for the path of least resistance which is to pull in the entire icon set and that is going to cause bigger bundle sizes on production builds. That should be more concerning than a large bundle size on a library that is going to be largely tree shaken away. It also runs counter to the strategy that @mdi/js takes which is to offer a route where by default code is tree shakeable.

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