I'm trying out a few OL demo apps, and finding I can't combine two of the demo scripts provided in the documentation into one script, because there appear to be conflicts between the imports.
This is very easy to reproduce, import OL into a npm workspace, and then the following code:
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import TileArcGISRest from 'ol/source/TileArcGISRest.js';
import OSM from 'ol/source/OSM.js';
The last two libraries are the ones which conflict with each other. However remove either of the last two (doesn't matter which one) and it works fine.
In OL, another way of calling the import for the last two lines is to combine them as follows:
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import {OSM, TileArcGISRest} from 'ol/source.js';
Which is actually shown here in the demo script:
https://openlayers.org/en/latest/examples/arcgis-tiled.html
Both methods result in an error, but as I say, removing either of them and leaving just one, and it runs fine.
The error I get is:
Uncaught TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
at inherits (util.js:28)
at Object.parcelRequire.233.../util.js (epsg3857.js:63)
at newRequire (main.3e0ff667.js:48)
at localRequire (main.3e0ff667.js:54)
at Object.parcelRequire.93../sphere.js (proj.js:59)
at newRequire (main.3e0ff667.js:48)
at localRequire (main.3e0ff667.js:54)
at Object.parcelRequire.168.../util.js (Geometry.js:9)
at newRequire (main.3e0ff667.js:48)
I am running my app as recommended here exactly:
https://openlayers.org/en/latest/doc/tutorials/bundle.html
Any help to explain why I can't use these two components of the OL library together would be really appreciated.