openlayers / ol-cesium

OpenLayers - Cesium integration
http://openlayers.org/ol-cesium/
BSD 2-Clause "Simplified" License
986 stars 323 forks source link

Help importing #426

Closed FallenRiteMonk closed 7 years ago

FallenRiteMonk commented 7 years ago

I have problems importing ol3-cesium into a webpack angular2 library. I managed to import ol3 and it also works. Now I wanted to extend it by cesium, but i get the following error wen running tsc: error TS2307: Cannot find module 'ol3-cesium' on the following line of code: import { OLCesium } from 'ol3-cesium'; the same import works on ol3(example line: import { Map } from 'openlayers';

Can anybody please help me and if more information is needed, just ask.

P.S.: tsconfig.json might also be interesting:

{
  "compilerOptions": {
    "noImplicitAny": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "ES5",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "declaration": true,
    "outDir": "./dist"
  },
  "files": [
    "src/index.ts"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}
gberaudo commented 7 years ago

This is probably due to the UMD wrapper found in OL3 tasks/build.js. No equivalent mechanism has been contributed to OL3-Cesium yet.

FallenRiteMonk commented 7 years ago

Are there any plans in implementing it into plc in near future? Or can you at least tell me how I can import it in the mean while?

gberaudo commented 7 years ago

I am not an expert in this.

@bartvde knows better, he wrote such a wrapper in a branch. See discussions in https://github.com/openlayers/ol3-cesium/issues/378 and code at https://github.com/bartvde/ol3-cesium/blob/npm/build/build.js#L18-L30

The function seems to detect if the library is included in the context of commonjs and inject the olcsnamespace accordingly.

I hope it helps.

bartvde commented 7 years ago

@gberaudo do I understand correctly that ol3-cesium was published without the UMD wrapper being added?

gberaudo commented 7 years ago

Yes indeed, following what we discussed in https://github.com/openlayers/ol3-cesium/issues/378.

gberaudo commented 7 years ago

OpenLayers and this project are moving towards ES6 modules. There are still lots to do and I do not have much time so I have no ETA yet. You may have a look to the jscodeshift transforms in https://github.com/openlayers/openlayers/tree/master/transforms. We also need to finish getting ride of the closure compiler library.

Please reopen if you have some ideas, feedback.