8000 Connecting complex 3rd party libraries · Issue #2837 · angular/angular-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Connecting complex 3rd party libraries #2837
Closed
@YonatanKra

Description

@YonatanKra

OS?

Windows 10

Versions.

angular-cli: 1.0.0-beta.17
node: 6.3.1
os: win32 x64

Repro steps.

I've tried to setup a 3rd party library (cesiumjs). There are many errors during the "serve" process.

  1. npm install cesium --save
  2. In angular-cli.json file:
"styles": [
        "styles.css",
        "../node_modules/cesium/Build/Cesium/Widgets/widgets.css"
      ],
      "scripts": [
        "../node_modules/cesium/Build/Cesium/Cesium.js"
      ],
  1. Created a simple component:
    ng g component cesium-component
  2. Inside the component used the Cesium global that's supposed to be available:
constructor(public element: ElementRef) {
    Cesium.BingMapsApi.defaultKey = 'AroazdWsTmTcIx4ZE3SIicDXX00yEp9vuRZyn6pagjyjgS-VdRBfBNAVkvrucbqr';
    window.CESIUM_BASE_URL = '/assets';
  }

ngOnInit() {
this.viewer = new Cesium.Viewer(this.element.nativeElement);
}

5) There are errors during the `ng serve` process (see the errors section).
6) The app does load, and Ceisum gives an error it cannot find files.
7) I copy Cesium into the app's assets dir, and set: `window.CESIUM_BASE_URL = '/assets/Cesium';` (as in the code example above)
8) I get errors during the `serve` process (see below).

### The log given by the failure.
> '''
ERROR in [default] D:\development\edu\ngCli\my_first_cli_project\src\app\cesium-component\cesium-component.component.ts:11:4 
Cannot find name 'Cesium'.

ERROR in [default] D:\development\edu\ngCli\my_first_cli_project\src\app\cesium-component\cesium-component.component.ts:12:11 
Property 'CESIUM_BASE_URL' does not exist on type 'Window'.

ERROR in [default] D:\development\edu\ngCli\my_first_cli_project\src\app\cesium-component\cesium-component.component.ts:16:9 
Property 'viewer' does not exist on type 'CesiumComponentComponent'.

ERROR in [default] D:\development\edu\ngCli\my_first_cli_project\src\app\cesium-component\cesium-component.component.ts:16:22 
Cannot find name 'Cesium'.
'''


### Mention any other details that might be useful.
My main question is:
Is there a way to connect the Cesium assets without copying them to the app itself? (make the app get them from node modules?) What would be best practice here?

Another small thing - why do the errors appear during the `serve` phase, while the app itself seems to be working correctly (I can see Cesium and it's running properly in my component).

> ---------------------------------------------------------------
Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0