rubenCodeforges / ng-gapi

ng-gapi a Google api module for Angular 6+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ivy compatability

ocket8888 opened this issue · comments

I just updated to Angular 9 and I'm seeing this error:

ERROR in node_modules/ng-gapi/lib/GoogleApiModule.d.ts:2:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (ng-gapi) which declares GoogleApiModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

2 export declare class GoogleApiModule {

my version is 0.0.73

the same issue happens to me. Is this library expected to be compatible with Ivy?

this is related to #93

and #83

I've just updated the library and it stills printing that error. I've tried removing ng_modules folder, cleaning cache, everything.

node_modules/ng-gapi/lib/GoogleApiModule.d.ts:2:22 - error NG6003: Appears in the NgModule.exports of AppModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class. This likely means that the library (ng-gapi) which declares GoogleApiModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy

Am I doing anything wrong?

@darroyos check you version , latest is 0.0.91
i had a bug in 0.0.90 fixed it a hour ago.

I'm using 0.0.91. I'm also using last Angular and TypeScript version.

Thanks.

@darroyos try removing it from node modules and reinstall

@rubenCodeforges I've already done it, making sure I'm using last version. I've also checked tsconfig.json. I removed the whole node_modules folder also and reinstalled everything. The error came up when I updated this library and Angular. Before updating both packages everything works fine.

I don't know if this helps, but these are my dependencies:

"dependencies": {
    "@agm/core": "^1.0.0-beta.7",
    "@angular-material-extensions/google-maps-autocomplete": "^3.2.1",
    "@angular/animations": "^9.1.4",
    "@angular/cdk": "^9.2.1",
    "@angular/common": "^9.1.4",
    "@angular/compiler": "^9.1.4",
    "@angular/core": "^9.1.4",
    "@angular/flex-layout": "^9.0.0-beta.29",
    "@angular/forms": "^9.1.4",
    "@angular/material": "^9.2.1",
    "@angular/platform-browser": "^9.1.4",
    "@angular/platform-browser-dynamic": "^9.1.4",
    "@angular/router": "^9.1.4",
    "@kolkov/angular-editor": "^1.1.2",
    "@types/googlemaps": "^3.39.3",
    "angular-animations": "0.0.10",
    "dotenv": "^8.2.0",
    "file-saver": "^2.0.2",
    "material-community-components": "^6.0.1",
    "ng-gapi": "0.0.91",
    "ng-pick-datetime": "^7.0.0",
    "ngx-color": "^5.1.1",
    "ngx-pagination": "^5.0.0",
    "rxjs": "^6.5.5",
    "tslib": "^1.11.1",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.4",
    "@angular/cli": "^9.1.4",
    "@angular/compiler-cli": "^9.1.4",
    "@angular/language-service": "^9.1.4",
    "@types/jasmine": "^3.5.10",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^13.13.4",
    "@typescript-eslint/eslint-plugin": "^2.30.0",
    "@typescript-eslint/parser": "^2.30.0",
    "codelyzer": "^5.2.2",
    "eslint": "^6.8.0",
    "eslint-config-google": "^0.14.0",
    "jasmine-core": "^3.5.0",
    "jasmine-spec-reporter": "^5.0.2",
    "karma": "^5.0.3",
    "karma-chrome-launcher": "^3.1.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "^3.1.1",
    "karma-jasmine-html-reporter": "^1.5.3",
    "prettier": "^2.0.5",
    "protractor": "^5.4.4",
    "ts-node": "^8.9.1",
    "tslint": "^6.1.2",
    "typescript": "^3.8.3"
  }

I have the same issue. Removed node_modules, cleaned cache, etc.

Me too

I have the same issue as well. When I disable Ivy, the following comes up instead

ERROR in Error during template compile of 'AppModule' Function calls are not supported in decorators but 'GoogleApiModule' was called.

Ok guys ive pinpointed the issue , will prepare a new build asap

Ok guys ive pinpointed the issue , will prepare a new build asap

Thanks a lot!

I know this is related with the closed #83 and the already merged #97 PR, but I still have the same error, when trying to ng build --prod

ERROR in node_modules/ng-gapi/lib/GoogleApiModule.d.ts:2:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (ng-gapi) which declares GoogleApiModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

2 export declare class GoogleApiModule {

And if I set enableIvy to false in the tsconfig.json got the error

ERROR in Error during template compile of 'AppModule'
  Function calls are not supported in decorators but 'GoogleApiModule' was called.
Unexpected value 'undefined' imported by the module 'AppModule in '.../gapi-test/src/app/app.module.ts'
Error during template compile of 'AppModule'
  Function calls are not supported in decorators but 'GoogleApiModule' was called.

My ng version as a little context

Angular CLI: 9.1.7
Node: 12.16.1
OS: darwin x64

Angular: 9.1.9
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: No

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.7
@angular-devkit/build-angular     0.901.7
@angular-devkit/build-optimizer   0.901.7
@angular-devkit/build-webpack     0.901.7
@angular-devkit/core              9.1.7
@angular-devkit/schematics        9.1.7
@angular/cli                      9.1.7
@ngtools/webpack                  9.1.7
@schematics/angular               9.1.7
@schematics/update                0.901.7
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0
ng-gapi                           0.0.91

This is still not working. We are stuck on Angular 9.1. Please can you take another look at this?

If you need it urgent you can manually copy the module into your app and it work

please provide a solution for this issue @rubenCodeforges .. we are struggling a lot to fix this, with aot and build-optimizer set as false during build, it is building properly, but it is not the right way i guess.

@hariraghupathy @davidecampello @bendg25 @salazarr-js and all others , please update to latest version and see if it now works for you . npm version 0.0.93

Still not working for me
image

version 0.0.93, angular 9, ts 3.9.4

@AlbertoMontalesi this is a working project https://github.com/rubenCodeforges/ng-gapi/tree/master/examples

Maybe try removing node modules and npm i

@rubenCodeforges - the problem that ngcc (and so ivy) is having with this library is that the package.json is not valid:

Note that the typings property points to a non-existent file:

"typings": "./lib/index.d.ts",

And also so does the main property:

"main": "./lib/index.js",

But also for ngcc the main property should point to a UMD or CommonJS format. The distributed format in this library is ES2015, so rather than a main property you should be providing a module property.

Finally, it appears that you have built this library with ivy enabled, wihich means that you are shipping ivy code (i.e. ɵɵdefineNgModule) to npm, which is not supported, since this is private API and could change between versions of the Angular framework.

The best way to support ivy in this library is to package it using the ng-packagr tool, which will ensure that the correct bundle formats are built and that the package.json has the correct properties.

Your example app circumnavigates these issues by "deep-importing" into your library and having the code including ivy instructions, which is why it appears to work. But if you tried to run ngcc on this library gives the errors that are being reported; also if you tried to import from the main entry-point, i.e. import from "ng-gapi";.

@petebacondarwin thanks for the hint , i wont have much time until next week , so prs are welcomed, after all its open sourced lib

Keen for a fix on this. Is there anything I can do to assist?

@vaughnmuirhead look at @petebacondarwin comment , he did described the issue well , PRs are welcomed

@vaughnmuirhead look at @petebacondarwin comment , he did described the issue well , PRs are welcomed

Thanks @rubenCodeforges. The fix here seems to be out of my depth of Angular experience. For the moment it looks like I can only provide moral support. ;) Happy to help test if a fix is on the way though.

@rubenCodeforges I have a fix for this issue (and #103) but cannot push my branch to github. Maybe you have to add me to the project so I can push the fix and create a pull request?

@Psycholive the normal procedure is to make a fork of the project, push your branch to your fork, and make the Pull Request from your fork into this repository.

I am new to Github. I hope I did things right this time. Thanks @ocket8888

commented

Any update on this?

"ng-gapi": "0.0.93",
"@types/gapi": "0.0.39",
"@types/gapi.analytics": "0.0.3",

@rochapablo the pr that fixes this issue is merged
i will soon publish it to npm

Has it been published to npm.? I'm trying to set up a Stackblitz sample project and I keep getting :
"Cannot find module 'ng-gapi' or its corresponding type declarations."

@rubenCodeforges still waiting for you to publish a new version ;)

its comming

Haha, just got here, nice work with the module @rubenCodeforges, i'm waiting for the new version with the others(i wanna use it in a code challenge).

One question not related to the topic: this module is for one-time code flow??

@mtejedorwolox if you are asking about server-side code for refresh token exchange flow, then no, this is purely client-side authentication.

@rubenCodeforges Nice.
On unrelated note, it might be a good idea to fix dependency warnings you get when running yarn install in the project dir. I think it should look like this:

{
  "dependencies": {
    "@types/gapi": "^0.0.39",
    "@types/gapi.auth2": "^0.0.52",
    "tslib": "^2.0.1"
  },
  "devDependencies": {
    "@angular/animations": "^10.1.2",
    "@angular/common": "^10.1.2",
    "@angular/compiler": "^10.1.2",
    "@angular/compiler-cli": "^10.1.2",
    "@angular/core": "^10.1.2",
    "@angular/platform-browser": "^10.1.2",
    "@types/node": "^14.11.2",
    "ng-packagr": "^10.1.0",
    "rxjs": "^6.6.3",
    "tslint": "~6.1.3",
    "typescript": "~3.9.7",
    "zone.js": "~0.10.3"
  }
}

@hakimio thanks , PRs are welcomed

@rubenCodeforges This issue and #103 can be closed now :)

@rubenCodeforges , On latest version and clean angular 10 project, still have this problem:

 ERROR in node_modules/ng-gapi/GoogleApiModule.d.ts:2:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

    This likely means that the library (ng-gapi/GoogleApiModule) which declares GoogleApiModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

@rubenCodeforges , Angular 16, using ng-gapi version 0.0.94, still got the problem

'GoogleApiModule' does not appear to be an NgModule class.(-996002) GoogleApiModule.d.ts(2, 43): This likely means that the library (ng-gapi) which declares GoogleApiModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.