I'm using StealJS to load the Openlayers library. It seems to be loading the debugging - unbuilt version of openlayers differently than the built version.
When using the built version, it works correctly and returns the actual ol object. When using the debug version, it returns a wrapper object containing ol. This breaks all of the calls to ol.map, etc..
I am importing the ol file like this:
import ol from 'openlayers';
This is the ol-debug.js object returned using console.log in chrome:
{
CLOSURE_NO_DEPS: true
COMPILED: false
goog: Object
module: undefined
ol: Object //this is the object I want
__proto__: Object
}
Using the built version, the object is the actual ol object containing animation, map, layer, etc.
Using npm config:
"npmIgnore": [
"openlayers"
],
"paths": {
"openlayers": "node_modules/openlayers/dist/ol-debug.js"
},
"meta": {
"openlayers": {
"format": "global"
}
},
Its really difficult to debug apps without the debug version of the file. And switching to the debug version breaks all of the widgets because ol.map now needs to become ol.ol.map since ol is nested inside a parent object.
The solution was to add a exports property:
"meta": {
"openlayers": {
"format": "global",
"exports": "ol"
}
},