-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Leaflet 1.9 breaks Leaflet.heat #8451
Comments
@jonkoops can you look into this? |
Sure, I'll take a look 👍 |
I've created this example project which reproduces the issue using Vite. The issue comes from the way Leaflet is imported: import * as L from 'leaflet' Since this imports all of the named exports from Leaflet, but not the global I managed to fix this issue by importing the default export instead: -import * as L from 'leaflet'
+import L from 'leaflet' Alternatively, you can even omit naming the import as Leaflet is exposed globally. import 'leaflet'
const map = L.map('map') // Still works |
This is still a backwards compatibility issue however, although I don't think there is a way we can fix this elegantly. The only way I can see this working is by removing the module entry point. There is no way to augment the namespaced import from a module that imports it. |
The way I see it we can resolve this two ways:
I'm leaning towards the first, even though it's a breaking change for users of namespaced import. The reason for this is that it allows a migration path to the next major version, which will drop support for other module systems. However, other core team members might feel differently. Especially if this ends up impacting too many users. @mourner @Malvoz @Falke-Design WDYT? |
Yeah, I think it makes sense. The plugins working with a namespaced import is already a hack that shouldn't have been working in the first place, and gives the illusion of proper ES with tree-shaking even though it doesn't tree-shake at all. I'd move the ESM changelog item under "Breaking changes" and add a note about plugin compatibility. But I don't really know how much of a pain point this would be so let's wait for other opinions. |
I see a little bit the problem with unmaintained plugins. What if we publish to sources like before with |
Ahh, as in plugins that might be using the namespaced import method already? Yeah, those could indeed exist, but I have no idea how many. A lot of existing 'legacy' plugins all seem to rely on the global |
Is there a good way to search through Github for imports? I would do it but I'm currently working on the Event Hotfix and need to go in 40 minutes |
Should we do a quick v1.9.1 with the |
https://github.com/search?q=%22import+*+as+L+from+%27leaflet%27%3B%22&type=code "import * as L from 'leaflet';" --> 12,945 code results 😶 |
Yes I think that would be good. |
Yeah, let's do a quick release before we decide what to do here. Sounds good to me. |
v1.9.1 released. |
@Sergiobop could you verify that the fixes I mentioned above also work for you? I'd like to make sure that it's not just 'works on my machine'. |
Hey @jonkoops Option 1: My IDE and app complains:
Option 2: My IDE and app complains when i use L.
|
Thanks for checking @Sergiobop. So the first problem is likely issue due to the fact that You might be able to work around this by following the instructions in #8467 (comment). |
Same with GeometryUtil from leaflet-draw |
We could revert this work in a patch release and then re-introduce it in 2.0. It looks like this is creating too much fallout. |
@jonkoops Can we expect the patch release sooner? |
@cyrilirudayaraj we're bundling multiple issues that need a resolution (see the milestone). |
@jonkoops do you want to do the v1.9.2 release some time soon? |
Yeah, I'd like to do it ASAP. I don't have time to get to it today, so if someone wants to go ahead now feel free. Just make sure all the critical stuff is cherry-picked on |
Not suggesting a change of approach here, just noting other options that some of us have resorted to. For me, to get 1.9.x working, I searched on the error and came up with workaround: Best explained at: Other possibly relevant discussions: |
Checklist
Steps to reproduce
First of all, thanks for your work!
The steps to reproduce the issue is just updating leaflet to 1.9 and use the leaflet.heat package. (https://github.com/Leaflet/Leaflet.heat)
I also use the @types/leaflet and @types/leaflet-heat packages.
Expected behavior
This worked before 1.9.0:
Current behavior
The app breaks and produces the following error:
Minimal example reproducing the issue
No response
Environment
The text was updated successfully, but these errors were encountered: