hungtcs / mxgraph-type-definitions

mxgraph type definitions
https://www.npmjs.com/package/mxgraph-type-definitions
Apache License 2.0
20 stars 8 forks source link

Not Working when Doing a ng build --prod #10

Closed FredBesterwitch closed 4 years ago

FredBesterwitch commented 4 years ago

Hi Thanks for create these types for mxgraph, much appreciated. You have done a good job..

It works perfectly in ng serve in dev, but when we deploy the buuild that was generated by ng build --prod, it does not work, it says mxGraphModel does not exist

any help would be appreciated..

Thank You

hungtcs commented 4 years ago

Hi @FredBesterwitch!, Do you install via npm install --save-dev mxgraph-type-definitions? npm package is not perfect at present, please use git submodule, you can fork this project first, then add as a submodule in your project, I am currently using this method, working on Angular

git submodule add https://github.com/hungtcs/mxgraph-type-definitions.git src/types/mxgraph-type-definitions

If you find some types missing, you can modify your submodule and push to your fork, and then make a pull request.

FredBesterwitch commented 4 years ago

Thanks for your quick response, i did using npm I will try using as a sub module Just put it in a folder under the app and use the import?

hungtcs commented 4 years ago

@FredBesterwitch mxGraph is not support es module, you can't import it.Here is a simple example https://github.com/hungtcs/angular-with-mxgraph

FredBesterwitch commented 4 years ago

Thank You , much appreciated

hungtcs commented 4 years ago

very glad if this helped.

FredBesterwitch commented 4 years ago

Can't run the sample you sent, is there something i'm missing? Thanks

ERROR in src/app/app.component.ts:9:18 - error TS2304: Cannot find name 'mxGraph'.

9 private graph: mxGraph;


src/app/app.component.ts:15:22 - error TS2304: Cannot find name 'mxGraph'.

15     this.graph = new mxGraph(this.container.nativeElement);
hungtcs commented 4 years ago

@FredBesterwitch please check the src/types/mxgraph-type-definitions folder, is it empty? clone with --recursive or exec git submodule init && git submodule update

tbouffard commented 4 years ago

Hello guys just in case, I would like to let you know that some wrapper exist around mxGraph to adress integration issues

According to https://github.com/asual/mxgraph-factory/issues/9#issuecomment-613234148

The main goal of this project was to provide the required Webpack configuration that turns mxGraph into a CommonJS compatible package. The type definitions were added just for convenience and can be easily dropped if there is a better alternative.

The above wrapper is not using the @hungtcs type definitions lib

tbouffard commented 4 years ago

@FredBesterwitch @hungtcs this repo which is also using Angular with mxgraph-type-definitions (via npm deps) may be interesting for you: https://github.com/ivamax9/angular-mxgraph-demo