When generating the dist files, we use the LeafletWithGlobals file. This causes the ESM module to add the global L to the window object. Should we change the export configs?
- UMD -> LeafletWithGlobals.js (with global L)
- ESM -> Leaflet.js (without global L)
|
input: 'src/LeafletWithGlobals.js', |
|
output: [ |
|
{ |
|
file: pkg.exports['.'], |
|
format: 'es', |
|
banner, |
|
sourcemap: true, |
|
freeze: false |
|
}, |
|
{ |
|
file: './dist/leaflet-global-src.js', |
|
name: 'leaflet', |
|
format: 'umd', |
|
banner, |
|
sourcemap: true, |
|
freeze: false, |
|
esModule: false |
|
} |
|
], |
|
import * as L from './Leaflet.js'; |
|
export * from './Leaflet.js'; |
|
|
|
export default L; |
|
|
|
const oldL = getGlobalObject().L; |
|
getGlobalObject().L = L; |
|
getGlobalObject().L.noConflict = function () { |
|
getGlobalObject().L = oldL; |
|
return this; |
|
}; |
|
|
|
function getGlobalObject() { |
|
if (typeof globalThis !== 'undefined') { return globalThis; } |
|
if (typeof self !== 'undefined') { return self; } |
|
if (typeof window !== 'undefined') { return window; } |
|
if (typeof global !== 'undefined') { return global; } |
|
|
|
throw new Error('Unable to locate global object.'); |
|
} |
https://plnkr.co/edit/7wAJePQI44QmAedQ
@mourner, @IvanSanchez, @jonkoops, @simon04
When generating the dist files, we use the
LeafletWithGlobalsfile. This causes the ESM module to add the global L to the window object. Should we change the export configs?Leaflet/build/rollup-config.js
Lines 15 to 33 in cbe2d0a
Leaflet/src/LeafletWithGlobals.js
Lines 1 to 20 in cbe2d0a
https://plnkr.co/edit/7wAJePQI44QmAedQ
@mourner, @IvanSanchez, @jonkoops, @simon04