-
Notifications
You must be signed in to change notification settings - Fork 0
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
Bundle doesn't seem fully side-effect free #3
Comments
Yes you're right thought that this should be ok... As all sideeffects are isolated for that file. But looks like I'm wrong will fix this. You can try It exports see Branch https://github.com/EC-Nordbund/Leaflet-Builder/tree/plugins |
No you get full TreeShaking! As we don't have |
Unluckily putting BTW: I was able to fix the issue above by using: import {
IconDefault,
} from '@ec-nordbund/leaflet/src/layer/marker/Icon.Default';
Icon.Default = IconDefault; But then another issue appeared (this time about the CRS). Probably my Leaflet env is too complex. In any case: it worthed a try! Thanks! |
Oh I found the problems: For example: Map.addInitHook('addHandler', 'boxZoom', BoxZoom); We can say there are Sideeffect free as that is only needed when we use that part of leaflet. Only some problems (lice the Icons) will appear. When you provide a full code snippet like your above I will add it to the bundle so all needed code is loaded. The more I read the leaflet code I want to rewrite it for modern Browsers (, with typescript) and better code style that is treeshakeable... The hole not useing class syntax is really bad and what has to run today in IE10 or below? Just thinking: [EDIT]: Just tinking I can collect all the |
Yeah, I hope to see a fully ES6+ Leaflet 2.0 someday 🤷♂️ |
(moving discussion there to not annoying people in the Leaflet/Leaflet#7055).
I finally fixed every plugin and packages of my bundle using @ec-nordbund/leaflet.
Everything was working properly in development mode, but as soon as I moved to production I found a new issue.
Long story short: the leaflet bundle is marked as side-effects free but probably isn't.
In my code I have these lines:
The meaning of these lines are related to a SO question about changing the default icon.
When I build my code for production (
mode='production'
in webpack mode) any reference toIcon.Default
isundefined
.So I spent some time trying to identify which change from development to production mode introduced the issue.
If I switch-off optimization.sideEffects in my production build (this flag is automatically put to
true
in production mode) the issue disappear but obviously I loose every benefit from using the custom Leaflet bundle.BTW: Not 100% this is an issue of the custom bundle
The text was updated successfully, but these errors were encountered: