geoblaze icon indicating copy to clipboard operation
geoblaze copied to clipboard

Very large bundle size

Open Chris1234567899 opened this issue 5 years ago • 5 comments

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?

Chris1234567899 avatar Sep 26 '19 15:09 Chris1234567899

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!

DanielJDufour avatar Sep 26 '19 17:09 DanielJDufour

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.

fionawhim avatar Oct 03 '19 15:10 fionawhim

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.

Chris1234567899 avatar Oct 03 '19 19:10 Chris1234567899

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

DanielJDufour avatar Oct 03 '19 21:10 DanielJDufour

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

DanielJDufour avatar Oct 03 '19 21:10 DanielJDufour