# Can't get Leaflet not to load

**URL:** <https://forums.bitovi.com/t/cant-get-leaflet-not-to-load/748>\
**Category:** StealJS\
**Created:** [November 7, 2017, 4:10pm UTC](https://forums.bitovi.com/t/cant-get-leaflet-not-to-load/748 "2017-11-07T16:10:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arjen\_Haayman](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@Arjen\_Haayman](https://forums.bitovi.com/u/Arjen_Haayman)\
**Post date:** [November 7, 2017, 4:10pm UTC](https://forums.bitovi.com/t/cant-get-leaflet-not-to-load/748/1 "2017-11-07T16:10:42Z")

</div>

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"
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![m-mujica](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/m-mujica/32/116_2.png) [@m-mujica](https://forums.bitovi.com/u/m-mujica)\
**Post date:** [November 8, 2017, 6:19pm UTC](https://forums.bitovi.com/t/cant-get-leaflet-not-to-load/748/2 "2017-11-08T18:19:22Z")

</div>

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](http://leafletjs.com/reference-1.2.0.html#noconflict)

---

<div class="post-metadata">

**Author:** ![m-mujica](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/m-mujica/32/116_2.png) [@m-mujica](https://forums.bitovi.com/u/m-mujica)\
**Post date:** [November 8, 2017, 6:27pm UTC](https://forums.bitovi.com/t/cant-get-leaflet-not-to-load/748/3 "2017-11-08T18:27:26Z")

</div>

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

[https://stealjs.com/docs/steal-conditional.html](https://stealjs.com/docs/steal-conditional.html)

```auto
import 'leaflet#?should-load-leaflet'

```

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

```auto
export default !window.L;

```

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

> <https://github.com/stealjs/steal-conditional/blob/master/demo/has_raf.js#L4>
