MeetmeLeave / ng-canvas-gauges

Angular2 component wrapper for the canvas-gauges library written by @Mikhus(https://github.com/Mikhus/canvas-gauges).
MIT License
38 stars 23 forks source link

ng build --prod does not work for ng-canvas-gauges (AOT compilation) #3

Closed kuenstl closed 7 years ago

kuenstl commented 7 years ago

When using the example "gauge-demo" of this repository (MeetmeLeave/ng-canvas-gauges/example), and building the example for producation the Angular CLI throws the following error:

Cmd: ng build --prod

Output:

ERROR in Unexpected value 'LinearGaugeComponent in ng-canvas-gauges-master/example/node_modules/ng-canvas-gauges/lib/linear-gauge.d.ts' declared by the module
 'AppModule in ng-canvas-gauges-master/example/src/app/app.module.ts'. Please add a @Pipe/@Directive/@Component annotation.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in ng-canvas-gauges-master\example\src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts
andregomars commented 7 years ago

Me too! got same error when following script is executed: ng build --prod -vc false -oh none

Needs help!

MeetmeLeave commented 7 years ago

It seems that this issue is generic for the AOT, I spent some time looking into the source and the possible solutions and it seems it will remain for some time.

There is the same issue opened on the Angular repo - https://github.com/angular/angular/issues/15890 I will keep looking for that thread until people will find the ability to resolve it.

JuliaRakitina commented 7 years ago

Same issue :( ng build --prod fails.... Any news?

Also cant add internalization throws same error ./node_modules/.bin/ng-xi18n

MeetmeLeave commented 7 years ago

Finally, this is fixed with latest library release, to bypass AOT compilations I had to wrap components into the ng module, so this release contains breaking changes. The example project lists how to properly add components to project now.

marcossapp commented 6 years ago

Are you sure it's solved?

marcossapp commented 6 years ago

I reproduced this steps and the example project did not worked properly as you said.

pmeems commented 6 years ago

I had the same error during run-time. I solved it by deleting the node_modules folder inside \node_modules\ng-canvas-gauges\

erickyi2006 commented 6 years ago

sharing my workaround to build in production under angular5

1) change component.js

old exports.GaugesModule = require('./lib/gauges-module').GaugesModule; new

exports.RadialGaugeComponent = require('./lib/radial-gauge').RadialGaugeComponent;
exports.LinearGaugeComponent = require('./lib/linear-gauge').LinearGaugeComponent;

2) when build, in production mode, use the following option ng build --prod --aot=false

Probably, there is a better way, but this is my work around.