diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8bb3d90f3..39c99341e 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -113,7 +113,7 @@ jobs:
cache: npm
- name: Run Node.js SSR script
- run: node ./spec/ssr/ssr_node.mjs
+ run: node ./spec/ssr/ssr_node.js
- name: Set up Deno
uses: denoland/setup-deno@v1
diff --git a/PLUGIN-GUIDE.md b/PLUGIN-GUIDE.md
index fa8a6654a..7a1d4f329 100644
--- a/PLUGIN-GUIDE.md
+++ b/PLUGIN-GUIDE.md
@@ -221,40 +221,6 @@ file to make sure the minified files are not versioned, and an
[empty `.npmignore`](https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package)
to ensure that they are published to NPM.
-## Module Loaders
-
-Module loaders such as [RequireJS](http://requirejs.org/) and [Browserify](http://browserify.org/) implement module systems like AMD (Asynchronous Module Definition) and CommonJS to allow developers to modularize and load their code.
-
-You can add support for AMD/CommonJS loaders to your Leaflet plugin by following this pattern based on the [Universal Module Definition](https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js)
-
-```js
-(function (factory, window) {
-
- // define an AMD module that relies on 'leaflet'
- if (typeof define === 'function' && define.amd) {
- define(['leaflet'], factory);
-
- // define a Common JS module that relies on 'leaflet'
- } else if (typeof exports === 'object') {
- module.exports = factory(require('leaflet'));
- }
-
- // attach your plugin to the global 'L' variable
- if (typeof window !== 'undefined' && window.L) {
- window.L.YourPlugin = factory(L);
- }
-}(function (L) {
- var MyLeafletPlugin = {};
- // implement your plugin
-
- // return your plugin when you are done
- return MyLeafletPlugin;
-}, window));
-```
-
-Now your plugin is available as an AMD and CommonJS module and can be used in module loaders like Browserify and RequireJS.
-
-
## Adding to the plugins list
Once your plugin is published, it is a good idea to add it to the [Leaflet plugins list](http://leafletjs.com/plugins.html). To do so:
diff --git a/build/docs.mjs b/build/docs.js
similarity index 100%
rename from build/docs.mjs
rename to build/docs.js
diff --git a/build/integrity.mjs b/build/integrity.js
similarity index 100%
rename from build/integrity.mjs
rename to build/integrity.js
diff --git a/build/rollup-config.mjs b/build/rollup-config.js
similarity index 89%
rename from build/rollup-config.mjs
rename to build/rollup-config.js
index 2913997f6..ad6893e52 100644
--- a/build/rollup-config.mjs
+++ b/build/rollup-config.js
@@ -15,16 +15,7 @@ const config = {
input: 'src/LeafletWithGlobals.js',
output: [
{
- file: pkg.main,
- format: 'umd',
- name: 'leaflet',
- banner,
- sourcemap: true,
- freeze: false,
- esModule: false
- },
- {
- file: pkg.module,
+ file: pkg.exports['.'],
format: 'es',
banner,
sourcemap: true,
diff --git a/debug/map/canvas.html b/debug/map/canvas.html
index 62c66d549..0d52534b8 100644
--- a/debug/map/canvas.html
+++ b/debug/map/canvas.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/control-layers.html b/debug/map/control-layers.html
index b0ebeb1d0..8398c2240 100644
--- a/debug/map/control-layers.html
+++ b/debug/map/control-layers.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/controls.html b/debug/map/controls.html
index c19bafe04..640039429 100644
--- a/debug/map/controls.html
+++ b/debug/map/controls.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/geolocation.html b/debug/map/geolocation.html
index bcb02fdeb..f3b67a15f 100644
--- a/debug/map/geolocation.html
+++ b/debug/map/geolocation.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/grid.html b/debug/map/grid.html
index bb7603028..4d6c472a8 100644
--- a/debug/map/grid.html
+++ b/debug/map/grid.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/iframe-map.html b/debug/map/iframe-map.html
index 55d7961ae..c073ff3b0 100644
--- a/debug/map/iframe-map.html
+++ b/debug/map/iframe-map.html
@@ -10,7 +10,7 @@
diff --git a/debug/map/iframe.html b/debug/map/iframe.html
index 7d7164aaf..b1fab075a 100644
--- a/debug/map/iframe.html
+++ b/debug/map/iframe.html
@@ -7,7 +7,7 @@
diff --git a/debug/map/image-overlay.html b/debug/map/image-overlay.html
index 5ada38b99..2e61a859d 100644
--- a/debug/map/image-overlay.html
+++ b/debug/map/image-overlay.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/layer-remove-add.html b/debug/map/layer-remove-add.html
index 14cd06d9b..73eca8652 100644
--- a/debug/map/layer-remove-add.html
+++ b/debug/map/layer-remove-add.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/map-mobile.html b/debug/map/map-mobile.html
index 157904272..4fa27ef99 100644
--- a/debug/map/map-mobile.html
+++ b/debug/map/map-mobile.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/map-popup.html b/debug/map/map-popup.html
index ea03e6d4d..330103107 100644
--- a/debug/map/map-popup.html
+++ b/debug/map/map-popup.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/map-scaled.html b/debug/map/map-scaled.html
index 36424c896..dee04cb5b 100644
--- a/debug/map/map-scaled.html
+++ b/debug/map/map-scaled.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/marker-autopan.html b/debug/map/marker-autopan.html
index 921f5ee0c..3a62e7e51 100644
--- a/debug/map/marker-autopan.html
+++ b/debug/map/marker-autopan.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/markers.html b/debug/map/markers.html
index 5ca216b63..1ccf5b8f1 100644
--- a/debug/map/markers.html
+++ b/debug/map/markers.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/max-bounds-bouncy.html b/debug/map/max-bounds-bouncy.html
index a2dbfc348..f1fe75125 100644
--- a/debug/map/max-bounds-bouncy.html
+++ b/debug/map/max-bounds-bouncy.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/max-bounds-infinite.html b/debug/map/max-bounds-infinite.html
index ae05e73da..6b7375261 100644
--- a/debug/map/max-bounds-infinite.html
+++ b/debug/map/max-bounds-infinite.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/max-bounds.html b/debug/map/max-bounds.html
index 881b776e3..ce5b6ba38 100644
--- a/debug/map/max-bounds.html
+++ b/debug/map/max-bounds.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/opacity.html b/debug/map/opacity.html
index 9890eaed1..313ef3242 100644
--- a/debug/map/opacity.html
+++ b/debug/map/opacity.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/popup-keep-in-view.html b/debug/map/popup-keep-in-view.html
index eeeb3f889..51e8eb56c 100644
--- a/debug/map/popup-keep-in-view.html
+++ b/debug/map/popup-keep-in-view.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/popup.html b/debug/map/popup.html
index f865d820b..32b56760a 100644
--- a/debug/map/popup.html
+++ b/debug/map/popup.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/scroll.html b/debug/map/scroll.html
index 45596006b..13fcb3f5a 100644
--- a/debug/map/scroll.html
+++ b/debug/map/scroll.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/simple-proj.html b/debug/map/simple-proj.html
index f7628ee9e..1258ad714 100644
--- a/debug/map/simple-proj.html
+++ b/debug/map/simple-proj.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/svg-overlay.html b/debug/map/svg-overlay.html
index e81c03e8d..08b45bee4 100644
--- a/debug/map/svg-overlay.html
+++ b/debug/map/svg-overlay.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/tile-opacity.html b/debug/map/tile-opacity.html
index fd37f39e7..3adcde4b0 100644
--- a/debug/map/tile-opacity.html
+++ b/debug/map/tile-opacity.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/tile.html b/debug/map/tile.html
index 5e7365f3c..e15b00f0d 100644
--- a/debug/map/tile.html
+++ b/debug/map/tile.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/tooltip.html b/debug/map/tooltip.html
index d426d14f7..40326284b 100644
--- a/debug/map/tooltip.html
+++ b/debug/map/tooltip.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/video-overlay.html b/debug/map/video-overlay.html
index aed2ace3e..644e2d016 100644
--- a/debug/map/video-overlay.html
+++ b/debug/map/video-overlay.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/wms.html b/debug/map/wms.html
index 058de4f22..e873176c6 100644
--- a/debug/map/wms.html
+++ b/debug/map/wms.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/zoom-delta.html b/debug/map/zoom-delta.html
index 865d9a844..816097e1c 100644
--- a/debug/map/zoom-delta.html
+++ b/debug/map/zoom-delta.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/zoom-levels.html b/debug/map/zoom-levels.html
index 1eae46060..071793402 100644
--- a/debug/map/zoom-levels.html
+++ b/debug/map/zoom-levels.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/zoom-pan.html b/debug/map/zoom-pan.html
index dadea0b18..50dfb8e73 100644
--- a/debug/map/zoom-pan.html
+++ b/debug/map/zoom-pan.html
@@ -9,7 +9,7 @@
diff --git a/debug/map/zoom-remain-centered.html b/debug/map/zoom-remain-centered.html
index 99037add5..87d166ede 100644
--- a/debug/map/zoom-remain-centered.html
+++ b/debug/map/zoom-remain-centered.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/add-remove-layers.html b/debug/tests/add-remove-layers.html
index fef1421a6..0dacd30e3 100644
--- a/debug/tests/add-remove-layers.html
+++ b/debug/tests/add-remove-layers.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/canvas-loop.html b/debug/tests/canvas-loop.html
index f2b03b05e..3faf19465 100644
--- a/debug/tests/canvas-loop.html
+++ b/debug/tests/canvas-loop.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/click-on-canvas.html b/debug/tests/click-on-canvas.html
index ac3d19312..c64da3bc8 100644
--- a/debug/tests/click-on-canvas.html
+++ b/debug/tests/click-on-canvas.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/custom-panes.html b/debug/tests/custom-panes.html
index 704acef2e..87e6f13cc 100644
--- a/debug/tests/custom-panes.html
+++ b/debug/tests/custom-panes.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/detached-dom-memory-leak.html b/debug/tests/detached-dom-memory-leak.html
index d18d7772b..55c1c1e69 100644
--- a/debug/tests/detached-dom-memory-leak.html
+++ b/debug/tests/detached-dom-memory-leak.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/dragging-and-copyworldjump.html b/debug/tests/dragging-and-copyworldjump.html
index 88413232a..dbfcba6a0 100644
--- a/debug/tests/dragging-and-copyworldjump.html
+++ b/debug/tests/dragging-and-copyworldjump.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/dragging-cursors.html b/debug/tests/dragging-cursors.html
index c4bb90f1d..8627e2335 100644
--- a/debug/tests/dragging-cursors.html
+++ b/debug/tests/dragging-cursors.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/esm.html b/debug/tests/esm.html
index 7a8011f29..fd1d6f26a 100644
--- a/debug/tests/esm.html
+++ b/debug/tests/esm.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/event-perf-2.html b/debug/tests/event-perf-2.html
index 329762403..f75419351 100644
--- a/debug/tests/event-perf-2.html
+++ b/debug/tests/event-perf-2.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/mousemove-on-polygons.html b/debug/tests/mousemove-on-polygons.html
index ebd08db14..342229f0e 100644
--- a/debug/tests/mousemove-on-polygons.html
+++ b/debug/tests/mousemove-on-polygons.html
@@ -40,7 +40,7 @@
diff --git a/debug/tests/opacity.html b/debug/tests/opacity.html
index 07db58961..223474e46 100644
--- a/debug/tests/opacity.html
+++ b/debug/tests/opacity.html
@@ -14,7 +14,7 @@
diff --git a/debug/tests/popup-context-menu-clicks.html b/debug/tests/popup-context-menu-clicks.html
index a2cb46770..a696834c7 100644
--- a/debug/tests/popup-context-menu-clicks.html
+++ b/debug/tests/popup-context-menu-clicks.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/popup-offset.html b/debug/tests/popup-offset.html
index 728ac4854..3690a471a 100644
--- a/debug/tests/popup-offset.html
+++ b/debug/tests/popup-offset.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/popup-resize.html b/debug/tests/popup-resize.html
index 4006ead06..41edfeb26 100644
--- a/debug/tests/popup-resize.html
+++ b/debug/tests/popup-resize.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/remove-while-dragging.html b/debug/tests/remove-while-dragging.html
index 99b84c23b..a1160251f 100644
--- a/debug/tests/remove-while-dragging.html
+++ b/debug/tests/remove-while-dragging.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/reuse-popups.html b/debug/tests/reuse-popups.html
index cdd2a5385..bf2857ff0 100644
--- a/debug/tests/reuse-popups.html
+++ b/debug/tests/reuse-popups.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/rtl.html b/debug/tests/rtl.html
index 59465d727..cdfb97a09 100644
--- a/debug/tests/rtl.html
+++ b/debug/tests/rtl.html
@@ -14,7 +14,7 @@
diff --git a/debug/tests/rtl2.html b/debug/tests/rtl2.html
index 4d966b76b..cdd27eead 100644
--- a/debug/tests/rtl2.html
+++ b/debug/tests/rtl2.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/svg-clicks.html b/debug/tests/svg-clicks.html
index 3389f15ce..b2d7c2a0f 100644
--- a/debug/tests/svg-clicks.html
+++ b/debug/tests/svg-clicks.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/text-selection.html b/debug/tests/text-selection.html
index a69554afd..d71ebd9c0 100644
--- a/debug/tests/text-selection.html
+++ b/debug/tests/text-selection.html
@@ -9,7 +9,7 @@
diff --git a/debug/tests/tile-bounds.html b/debug/tests/tile-bounds.html
index 8e42c1577..72c2c36a1 100644
--- a/debug/tests/tile-bounds.html
+++ b/debug/tests/tile-bounds.html
@@ -16,7 +16,7 @@
diff --git a/debug/tests/tile-events.html b/debug/tests/tile-events.html
index d7d38a900..1f9667b54 100644
--- a/debug/tests/tile-events.html
+++ b/debug/tests/tile-events.html
@@ -31,7 +31,7 @@
diff --git a/debug/vector/blanket.html b/debug/vector/blanket.html
index c7a3e1062..c6ec55938 100644
--- a/debug/vector/blanket.html
+++ b/debug/vector/blanket.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/bounds-extend.html b/debug/vector/bounds-extend.html
index e4bc79fde..1c1cf06ac 100644
--- a/debug/vector/bounds-extend.html
+++ b/debug/vector/bounds-extend.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/feature-group-bounds.html b/debug/vector/feature-group-bounds.html
index 018b145b7..b89e202fd 100644
--- a/debug/vector/feature-group-bounds.html
+++ b/debug/vector/feature-group-bounds.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/geojson.html b/debug/vector/geojson.html
index d6dc6c6c5..7800a210c 100644
--- a/debug/vector/geojson.html
+++ b/debug/vector/geojson.html
@@ -36,7 +36,7 @@
diff --git a/debug/vector/inherit-dash-array.html b/debug/vector/inherit-dash-array.html
index 44adad011..2f35ab691 100644
--- a/debug/vector/inherit-dash-array.html
+++ b/debug/vector/inherit-dash-array.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/moving-canvas.html b/debug/vector/moving-canvas.html
index 010317ad8..91bd13159 100644
--- a/debug/vector/moving-canvas.html
+++ b/debug/vector/moving-canvas.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/rectangle.html b/debug/vector/rectangle.html
index 579996754..d73f7ae93 100644
--- a/debug/vector/rectangle.html
+++ b/debug/vector/rectangle.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector-bounds.html b/debug/vector/vector-bounds.html
index 0c1657c2d..00ebae6cc 100644
--- a/debug/vector/vector-bounds.html
+++ b/debug/vector/vector-bounds.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector-canvas.html b/debug/vector/vector-canvas.html
index 4f9082780..d352fcea7 100644
--- a/debug/vector/vector-canvas.html
+++ b/debug/vector/vector-canvas.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector-drift.html b/debug/vector/vector-drift.html
index 4789f46a9..3210005b0 100644
--- a/debug/vector/vector-drift.html
+++ b/debug/vector/vector-drift.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector-mobile.html b/debug/vector/vector-mobile.html
index 562bce696..bd8759a84 100644
--- a/debug/vector/vector-mobile.html
+++ b/debug/vector/vector-mobile.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector-simple.html b/debug/vector/vector-simple.html
index b64170dff..875bf49d6 100644
--- a/debug/vector/vector-simple.html
+++ b/debug/vector/vector-simple.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector.html b/debug/vector/vector.html
index 7686c091c..de4d9bed1 100644
--- a/debug/vector/vector.html
+++ b/debug/vector/vector.html
@@ -9,7 +9,7 @@
diff --git a/debug/vector/vector2.html b/debug/vector/vector2.html
index ef5a51f9f..55bfe393a 100644
--- a/debug/vector/vector2.html
+++ b/debug/vector/vector2.html
@@ -9,7 +9,7 @@
diff --git a/eslint.config.mjs b/eslint.config.js
similarity index 98%
rename from eslint.config.mjs
rename to eslint.config.js
index 4101dd278..d5d828a17 100644
--- a/eslint.config.mjs
+++ b/eslint.config.js
@@ -6,7 +6,7 @@ import globals from 'globals';
export default [
...config,
{
- files: ['*.js', '*.mjs', '*.cjs'],
+ files: ['*.js', '*.cjs'],
},
{
ignores: [
diff --git a/package.json b/package.json
index a6ba717a1..82acf6c49 100644
--- a/package.json
+++ b/package.json
@@ -32,8 +32,10 @@
"uglify-js": "^3.19.1",
"ui-event-simulator": "^2.0.0"
},
- "main": "dist/leaflet-src.js",
- "module": "dist/leaflet-src.esm.js",
+ "type": "module",
+ "exports": {
+ ".": "./dist/leaflet-src.js"
+ },
"style": "dist/leaflet.css",
"files": [
"dist",
@@ -44,14 +46,14 @@
],
"scripts": {
"debug": "http-server -c-1",
- "docs": "node ./build/docs.mjs && node ./build/integrity.mjs",
- "test": "karma start ./spec/karma.conf.js",
- "coverage": "karma start ./spec/karma.conf.js --coverage --single-run",
+ "docs": "node ./build/docs.js && node ./build/integrity.js",
+ "test": "karma start ./spec/karma.conf.cjs",
+ "coverage": "karma start ./spec/karma.conf.cjs --coverage --single-run",
"build": "npm run rollup && npm run uglify",
"lint": "eslint .",
"lintfix": "npm run lint -- --fix",
- "rollup": "rollup -c build/rollup-config.mjs",
- "watch": "rollup -w -c build/rollup-config.mjs",
+ "rollup": "rollup -c build/rollup-config.js",
+ "watch": "rollup -w -c build/rollup-config.js",
"uglify": "uglifyjs dist/leaflet-src.js -c -m -o dist/leaflet.js --source-map filename=dist/leaflet.js.map --source-map content=dist/leaflet-src.js.map --source-map url=leaflet.js.map --comments",
"bundlemon": "bundlemon --subProject js --defaultCompression none && bundlemon --subProject js-gzip --defaultCompression gzip",
"serve": "cd docs && bundle exec jekyll serve",
diff --git a/spec/context.html b/spec/context.html
index 3eff17a92..452eb7525 100644
--- a/spec/context.html
+++ b/spec/context.html
@@ -12,7 +12,7 @@ Reloaded before every execution run.