Skip to content

Use correct name for Leaflet global#10027

Merged
jonkoops merged 1 commit into
Leaflet:mainfrom
jonkoops:fix-umd-rollup
Dec 29, 2025
Merged

Use correct name for Leaflet global#10027
jonkoops merged 1 commit into
Leaflet:mainfrom
jonkoops:fix-umd-rollup

Conversation

@jonkoops

@jonkoops jonkoops commented Dec 25, 2025

Copy link
Copy Markdown
Collaborator

Changes the Rollup configuration to expose the Leaflet global as L instead of leaflet, and ensures the AMD loader works correctly with the same name as the package (leaflet). The various distributions can be tested using the files located in the debug/tests directory (specifically dist-esm.html, dist-amd.html and dist-global.html).

This also removes the custom logic to expose the global and instead defers this to Rollup, this also means the ESM version no longer exposes a global variable, which is the correct behavior for that distribution.

@jonkoops

Copy link
Copy Markdown
Collaborator Author

@simon04 FYI

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Leaflet build configuration to expose the library's global variable as L instead of leaflet, aligning with standard Leaflet conventions. It removes the custom global exposure logic in LeafletWithGlobals.js and delegates this responsibility to Rollup's UMD format configuration, while also ensuring the AMD module is correctly registered with the package name.

  • Changes the Rollup UMD output configuration to use L as the global name instead of leaflet
  • Removes LeafletWithGlobals.js which contained custom global exposure and noConflict logic
  • Adds AMD configuration to register the module with the name leaflet for RequireJS compatibility
  • Adds three test HTML files to verify ESM, global, and AMD distribution methods work correctly

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/LeafletWithGlobals.js Deleted file that previously handled custom global exposure and noConflict functionality
build/rollup-config.js Updated input to use Leaflet.js directly, changed global name from 'leaflet' to 'L', added AMD configuration, and added noConflict option
package.json Added requirejs dev dependency for AMD testing
package-lock.json Lock file updates for requirejs dependency
debug/tests/dist-global.html New test file for verifying global distribution using the L global variable
debug/tests/dist-esm.html New test file for verifying ESM distribution via import statements
debug/tests/dist-amd.html New test file for verifying AMD distribution with RequireJS

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread debug/tests/dist-global.html
Comment thread build/rollup-config.js
Comment thread debug/tests/dist-amd.html
Comment thread build/rollup-config.js
Comment thread build/rollup-config.js
@jonkoops jonkoops force-pushed the fix-umd-rollup branch 2 times, most recently from 66be5a0 to 27077d0 Compare December 25, 2025 16:17
@jonkoops

jonkoops commented Dec 25, 2025

Copy link
Copy Markdown
Collaborator Author

The tests are failing because the ESM version no longer has a default export. I think we should get rid of it anyways, marking this as a draft for now.

Comment thread spec/suites/core/GeneralSpec.js Outdated
Signed-off-by: Jon Koops <jonkoops@gmail.com>
@jonkoops jonkoops marked this pull request as ready for review December 29, 2025 12:17
@jonkoops

Copy link
Copy Markdown
Collaborator Author

I was able to resolve the blockers for this PR by merging #10028 and #10029. I'm merging this one based on previous approval. If there are any lingering comments, let me know, and I will handle them in a follow-up PR.

@jonkoops jonkoops merged commit b341c30 into Leaflet:main Dec 29, 2025
16 checks passed
@jonkoops jonkoops deleted the fix-umd-rollup branch December 29, 2025 12:20
@jonkoops jonkoops linked an issue Jan 5, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global L is exported via ESM

3 participants