Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

decrease size of the bundles #155

Open
romanown opened this issue Mar 4, 2021 · 14 comments
Open

decrease size of the bundles #155

romanown opened this issue Mar 4, 2021 · 14 comments

Comments

@romanown
Copy link
Contributor

romanown commented Mar 4, 2021

when i import any component from root example import { Button } from "svelte-materialify"; increased size of the bundles (js and css). +200kb css and 30kb js. how i can decrease its size? when i used import Button from "svelte-materialify/src/components/Button"; size is fine but work is wrong. use import MaterialApp from "svelte-materialify/src/components/MaterialApp"; to wrap my app is wrong.
REPL
https://svelte.dev/repl/7cefe135751c4b089be75713c869b53c?version=3.35.0

@romanown romanown changed the title decreasing size of the bundles decrease size of the bundles Mar 4, 2021
@Florian-Schoenherr
Copy link
Collaborator

Okay, this is a bit of a problem with our setup.
The REPL isn't doing what advanced install does, so in the REPL you can only import from "svelte-materialify".
But on your local machine, you can do "Advanced Install" and then import { Button } from "svelte-materialify/src"; and wrap it in MaterialApp. That should decrease the bundle size.

@romanown
Copy link
Contributor Author

romanown commented Mar 4, 2021

i to tryed it in the my hosting. same result.

@romanown
Copy link
Contributor Author

romanown commented Mar 4, 2021

importing wrapper MaterialApp gived 150kb css bundle.
import MaterialApp from "svelte-materialify/src/components/MaterialApp";

@Florian-Schoenherr
Copy link
Collaborator

yup
Wow, you're right.
@TheComputerM

@Florian-Schoenherr
Copy link
Collaborator

@romanown I've made a change which should cut out some amount of css helpers and thereby removing a lot of bloat.
Next release you can use MaterialAppMin.

@romanown
Copy link
Contributor Author

romanown commented Mar 4, 2021

thank You. help me please to decrease size to use only used components. i am to wait.

@romanown
Copy link
Contributor Author

romanown commented Mar 4, 2021

how a long time it may be?

@Florian-Schoenherr
Copy link
Collaborator

Florian-Schoenherr commented Mar 4, 2021

I just asked @TheComputerM, he will update it tomorrow. For now, you could try this.
You don't need to try it now, you can wait for tomorrow and build out your site instead.
We will obviously solve the bloat.

@romanown
Copy link
Contributor Author

romanown commented Mar 4, 2021

thank You and thank @TheComputerM very match.

@romanown
Copy link
Contributor Author

romanown commented Mar 5, 2021

thank You. i tryed it. css is very good decrease. but js is more then before update and use min version.
image
i use only button, textfield and select elements.

@Florian-Schoenherr
Copy link
Collaborator

@TheComputerM only this works and I think that's bad:
image
image
Everything else gave me huge bundles, like @romanown has shown.

@gjovanov
Copy link

gjovanov commented Apr 8, 2021

indeed tree shaking (reduced bundle size) only works if used like this:
import MaterialApp from 'svelte-materialify/src/components/MaterialApp/MaterialApp.svelte'

Any plan/timeline to support tree-shaking work like this?

import { MaterialApp } from 'svelte-materialify'

or

import { MaterialApp } from 'svelte-materialify'/src

Thanks.

@romanown
Copy link
Contributor Author

romanown commented Apr 8, 2021

can also use import { MaterialAppMin } from 'svelte-materialify'/src https://svelte-materialify.vercel.app/components/material-app/#remove-css-helpers-defaults-and-typography
but even so the file size remains larger than desired

@gjovanov
Copy link

gjovanov commented Apr 8, 2021

For me this:
import { MaterialAppMin } from 'svelte-materialify/src'

doesn't work.

It pulls also many components that are not used by our app (Tabs etc).

It's not tree-shaking at all.

Unfortunately, the only way to pull components one by one (A la carte or tree-shaking) is via this pattern:

import MaterialApp from 'svelte-materialify/src/components/MaterialApp/MaterialApp.svelte'

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

No branches or pull requests

3 participants