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

feat!: extract advanced layers & sources into separate bundle #515

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

silvester-pari
Copy link
Collaborator

@silvester-pari silvester-pari commented Dec 12, 2023

This PR splits up OpenLayers formats, layers and sources to include only the most basic ones, while advanced ones can be added as a separate plugin. This is in order to reduce the bundle size for the most common use cases.

Before

image
image

After

image
image

Included in the base bundle:

  • Formats: GeoJSON, MVT
  • Layers: Group, Image, Tile, Vector, VectorTile,
  • Sources: ImageWMS, OSM, Tile, TileWMS, Vector, VectorTile, WMTS, XYZ

Usage

In order to use all formats, layers and sources provided by OpenLayers, import the plugin as well:

import "@eox/map/dist/eox-map-advanced-layers-and-sources.js"
import "@eox/map/dist/eox-map.js"
<eox-map [... GeoTIFF sources, STAC layers etc ...]></eox-map>

If the developer forgets to import the bundle but tries to use an advanced format, layer or source, a console error is thrown:
image

Closes #495

@silvester-pari silvester-pari changed the title feat: extract advanced layers & sources into separate bundle feat!: extract advanced layers & sources into separate bundle Dec 12, 2023
@silvester-pari silvester-pari marked this pull request as ready for review December 12, 2023 15:21
Copy link
Member

@StefanBrand StefanBrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting technique. I'm curious to find out if this directly affects the bundle size of the AgriApp, one of our downstream applications.

@silvester-pari silvester-pari merged commit 2ad7893 into main Dec 13, 2023
3 checks passed
@silvester-pari silvester-pari deleted the map/feature/advanced-layers-sources branch December 13, 2023 11:47
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

Successfully merging this pull request may close these issues.

Improve bundle size using optional layer types/sources
2 participants