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

Very large bundle size #155

Open
Chris1234567899 opened this issue Sep 26, 2019 · 5 comments
Open

Very large bundle size #155

Chris1234567899 opened this issue Sep 26, 2019 · 5 comments

Comments

@Chris1234567899
Copy link

Importing the package as suggested (import geoblaze from 'geoblaze';), imports everything from the library, resulting in more than 1.2mb additional scripts.
At least this is what webpack bundle analyzer is telling me.

For web projects this creates a very large footprint . Maybe you could split it into smaller modules, that can be imported separately?

@DanielJDufour
Copy link
Member

Yes, great idea! We should definitely do that. We especially draw inspiration from OpenLayers who does what you suggest. Would you like the following code?

import load from 'geoblaze/load'
import identify from 'geoblaze/identify'

const georaster = await load(url);
const values = identify(georaster, point);

Thank you for the suggestion!

@fionawhim
Copy link

My quick diagnosis is that importing geoblaze in a webpack project brings in geoblaze.min.js which includes all of Geoblaze’s dependencies (which means that they can’t be de-duped if they’re used elsewhere in your app).

Additionally, Geoblaze imports the entirety of the giant mathjs library, which I think is responsible for the bulk of the size. There’s a chance that switching to the Number-only mathjs/number version of the library (which ditches matrix, complex, &c. support) would save a lot of space. I don’t know whether you’re already tree-shaking down to just parse (the only use of mathjs that I can find in this codebase) and its dependencies in your webpack config, it’s hard to tell.

@Chris1234567899
Copy link
Author

Yes the structure like @DanielJDufour mentioned would be perfect.

If the size is increased vastly by mathjs, try updating to a newer version. From 6.x on, it is as well modular and should not increase the overall size that much anymore.

@DanielJDufour
Copy link
Member

@fionawhim, awesome we didn't know about mathjs/number. We're open to PRs if you want to submit! :-)

@DanielJDufour
Copy link
Member

Also, open to PRs updating our dependencies like Chris suggested!

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

3 participants