inorganik / ngx-countUp

Animates a numerical value by counting to it - for Angular
MIT License
138 stars 25 forks source link

Error while building with --prod flag. #14

Closed Tarang closed 6 years ago

Tarang commented 6 years ago
[ ] Bug
[X] Build issue
[ ] Feature request

Version info

Version 6.0.1

Angular:
Ionic-angular 3.9.2
Angular CLI: 
countup.js-angular2: 

Description

For some reason while building I get this error. I'm not sure what it means. It only happens when the --prod flag is passed on for AoT compilation.

Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator', function calls are
not supported. Consider replacing the function or lambda with a reference to an exported function, resolving
symbol NgModule in
/Users/user/Desktop/app/node_modules/countup.js-angular2/node_modules/@angular/core/core.d.ts,
resolving symbol CountUpModule in
/Users/user/Desktop/app/node_modules/countup.js-angular2/countup.js-angular2.d.ts, resolving
symbol CountUpModule in
/Users/user/Desktop/app/node_modules/countup.js-angular2/countup.js-angular2.d.ts

I checked with the last build before the Angular 6 builds, and that one, version 1.1.1 works fine.

I believe ionic-angular 3.9.2 uses Angular 5.0 (just looking at the other threads). The usage is exactly as specified in the readme

inorganik commented 6 years ago

I can see in your error that the error originates from the node_modules folder of countup.js-angular2. That shouldn't be there. One other issue was because of that. I believe it's because you have an older version of npm, which recursively installs node_modules, instead of keeping them all in the root node_modules folder and npm now does.

On my end I cannot repro that. I am on: node: 10.4.1 npm: 6.1.0

Here's a fix:

  1. upgrade node and in turn npm. Note that this can potentially cause issues in other node projects that are counting on a certain version of node. You can use nvm and an .nvmrc file to fix that
  2. blow away your node_modules: rm -rf node_modules
  3. reinstall: npm i.

You could try yarn too:

  1. brew install yarn
  2. yarn - installs

Try that and let me know how it goes so we can resolve this issue.

Tarang commented 6 years ago

I updated to the latest versions (I was on node 0.8.11.1 & npm 5.6 so it wasnt that much of an update.

The updated versions:

> node --version
v8.11.3
> npm --version
6.1.0

The same thing happened as before:

Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator', function calls are
            not supported. Consider replacing the function or lambda with a reference to an exported function, resolving
            symbol NgModule in
            /Users/user/Desktop/app/node_modules/countup.js-angular2/node_modules/@angular/core/core.d.ts,
            resolving symbol CountUpModule in
            /Users/user/Desktop/app/node_modules/countup.js-angular2/countup.js-angular2.d.ts, resolving symbol
            CountUpModule in /Users/user/Desktop/app/node_modules/countup.js-angular2/countup.js-angular2.d.ts

I also tried with Yarn to no avail. I still find it works with 1.1.1 though (npm and yarn).

Looking at the other issue posts it seems a common issue, but the recurring pattern is the use with Ionic (which uses Angular 5.0 if its relevant)

inorganik commented 6 years ago

I'm using ng-packagr to distribute this and I've had some trouble with it; there is no prescribed workflow so how to handle dependencies is a little hazy to me.

I still can't repro but what you can do is just copy the directive .ts file from src/app/countup/countup.directive.ts and declare it in a module. Then you just need to npm i countup.js --save to get the countUp dep.

Wish I knew why angular doesn't just let you distribute typescript files, it would drastically simplify things!

inorganik commented 6 years ago

Hi, I think this is resolved, I just pushed 6.0.2 which only has angular as a peer dependency. Please try it and if you still have trouble we can reopen.