Open Chris1234567899 opened 5 years ago
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!
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.
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.
@fionawhim, awesome we didn't know about mathjs/number
. We're open to PRs if you want to submit! :-)
Also, open to PRs updating our dependencies like Chris suggested!
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?