Can't get Leaflet not to load

Hi,

I have to create a script that is eval’d in an environment where window.L is already present.

I need the following npm packages

  • leaflet
    • leaflet.Editable
    • leaflet.path.drag

The following code loads Leaflet twice

  import L from 'leaflet';
  import 'leaflet.Editable';
  import 'leaflet.path.drag';

which causes all kinds if conflicts

Now I want to try to convince leaflet.Editable and leaflet.path.drag to use the global window.L
So far no success.

Also, I have not been successful in telling build.js not to use my npm leaflet package. If I don’t install it the build fails.
Here’s my latest attempt.

var stealTools = require('steal-tools');

stealTools.build({
        config: __dirname + '/package.json!npm'
    },
    {
        bundleSteal: true,
        minify: false,
        meta: {
            "leaflet": {
                bundle: false
            }
        }
    }
);

Also in package.json I’ve tried all kinds of variations. Latest:

"envs": {
  "window-production": {
    "map": {
      "leaflet": "@empty"
    }
  }
}

Why are you importing the main leaflet package? Isn’t it available on the window object already?

If you want your code to use the imported version of leaflet instead of the global one I guess you could use:
http://leafletjs.com/reference-1.2.0.html#noconflict

On a second thought, you might also be able to use steal-conditional for this.

https://stealjs.com/docs/steal-conditional.html

import 'leaflet#?should-load-leaflet'

then you have a module called should-load-leaflet that does something like:

export default !window.L;

The build will include leaflet but it will only be loaded on runtime if window.L is falsy.