question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

modules, globals, and plugins

See original GitHub issue

It looks like 0.8 will not expose a global if a module system (i.e. Node or AMD) is present. This is definitely a good thing, but it will make it a bit trickier to integrate Leaflet plugins that don’t have a UMD wrapper. Without the global, said plugins will not have anything to attach to (even when using e.g. a RequireJS shim config).

What do you think about recommending (but not requiring) that all Leaflet plugins have a UMD wrapper? Proj4leaflet and Leaflet.zoomslider could be good base examples.

The two concrete steps I have in mind are:

  • Update the plugin authoring guide to (briefly) discuss the two main module systems and recommend adding a UMD wrapper for compatibility with both
  • Update all of the “official” plugins (in @Leaflet) to have UMD wrappers

I am willing to take action on these as I have time, but thought it would be good to start by determining an overall strategy.

(I should note that I personally avoid compatibility issues by manually adding AMD wrappers to every third party library I work with that doesn’t have one. Needless to say that isn’t a very scalable approach.)

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
Vanuancommented, Mar 11, 2017

With ES modules being around the corner to be shipped to browsers, would it make sense to reconsider?

0reactions
jperellicommented, Oct 12, 2017

@tmcw Maybe I wasn’t specific enough (non-native english), I didn’t want to say ALL major browsers but SOME, although 44% seems a lot to me. Also take a count for react/vue user base that use babel. My point was that this is happening, I know that it is not going to be used by all leaflet users right now, but I think it is important to be noted. It was just an “update” comment to emphasize that module support is imminent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Global: Plugin - TypeScript
A global plugin is global code that changes the shape of some global. As with global-modifying modules, these raise the possibility of runtime...
Read more >
rollup-plugin-external-globals - npm
Transform external imports into global variables like output.globals. ... Start using rollup-plugin-external-globals in your project by ...
Read more >
eight04/rollup-plugin-external-globals - GitHub
This module exports a single function. createPlugin. const plugin = createPlugin( globals: Object ...
Read more >
The Global Object Pattern - Python Design Patterns
If Python modules were not separate namespaces, you would be unable to read or write Python code by keeping your attention focused on...
Read more >
Divi Global Modules, Rows & Sections - Elegant Themes
Back To Divi Builder Plugin Documentation. Divi Global Modules, Rows & Sections ... You can add a single global module to multiple pages....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found