always expose window.L for plugins #2941
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As it currently stands at the next version Leaflet will only expose a global
L
variable when neither a AMD or CommonJS loader is being used. This presents a problem for plugin authors who are used to relying on the globalwindow.L
variable always being present. It looks like this was decided in #2364 but no one implemented the change.This is especially important because without this change module authors would have to wrap their code in a UMD style block like Leaflet which would significantly raise the barrier to writing a plugin. With this change if a plugin isn't wrapped in a UMD block developers will still be able to do this...
This isn't ideal (since it defeats the point of the module system) but it works and plugins would continue to function and authors could add UMD blocks and users requested them.
I am also planning on updating the Plugin guide with info from #2783 in a separate PR so we can have best practices around UMD wrappers.