Skip to content

Conversation

@simon04
Copy link
Contributor

@simon04 simon04 commented Sep 30, 2025

Attempt to resolve #9814

@Maxel01
Copy link

Maxel01 commented Oct 7, 2025

Hey, I have seen your progress.
I tested a single component (Popup) with treeshaking.
First of all, there is a need to use the Leaflet.js as the entry file LeafletWithGlobals registers the modules directly which does not really make sense. see #9880

The problem with Popup is still the static part with this.setDefaultOptions which is a side effect. I found an experimental option in rollup: experimentalLogSideEffects: true.
This logs the first sideEffect of every file and could help to identify the problems.
I proposed to use mixins or some kind of plugin system in #9814, in my opinion it could be a little bit overkill to add mixins to all the control and map handlers as they are used anyway (Control.Layers is a good example for the usage of mixins as it is a rather big file and is not always used). In control/index.js these components are used anyway:

Control.Layers = Layers;
Control.Zoom = Zoom;
Control.Scale = Scale;
Control.Attribution = Attribution;

but the components are registered in LeafletWithGlobals which increases the complexity without any benefit (at the moment as they are not treeshakeable yet). Primarily, this means that the shortcut Control.* shouldn't be available anymore (or add it in the register function if possible).

static register() {
    Control.Layers = Layers
    ....
}

Let me know if I can assist you in any way.

@Maxel01 Maxel01 mentioned this pull request Oct 14, 2025
4 tasks
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.

Treeshaking not working

2 participants