Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After upgrade to Angular 9 get error "ERROR in Cannot read property 'length' of undefined" when building aws-amplify-angular #4681

Closed
alexAlchemy opened this issue Jan 8, 2020 · 78 comments
Labels
Angular Related to Angular 2+ bug Something isn't working

Comments

@alexAlchemy
Copy link

alexAlchemy commented Jan 8, 2020

Describe the bug
The application used aws-amplify and aws-amplify-angular. It was building as expected when on angular version 8 but after upgrade to angular version 9 the build process throws up the following error:

image

Tried uninstalling and installing the npm packages to makes sure its on latest but this didn't fix the issue.

It seems to be building the module as esm5 even though the target in tsconfig is set to es2015 which might be related but thats just a case.

Thanks in advance :-)

Update
I created a new angular 9 project and installed aws-amplify-angular and it built without error. The tsconfig.json was a little different so I copied it from the new project into my application but it didn't fix the error.

To Reproduce

package.json

{
  "name": "",
  "version": "0.0.1",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4200 --ssl",
    "buildprod": "ng build --prod --configuration=production",
    "buildstaging": "ng build --prod --configuration=staging",
    "builddev": "ng build --prod --configuration=devdeploy",
    "stats": "ng build --stats-json",
    "analyze": "webpack-bundle-analyzer dist/stats.json",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "~0.900.0-rc.7",
    "@angular/animations": "^9.0.0-rc.7",
    "@angular/cdk": "^9.0.0-rc.6",
    "@angular/common": "9.0.0-rc.7",
    "@angular/compiler": "9.0.0-rc.7",
    "@angular/core": "9.0.0-rc.7",
    "@angular/forms": "9.0.0-rc.7",
    "@angular/http": "7.2.15",
    "@angular/material": "^9.0.0-rc.6",
    "@angular/platform-browser": "9.0.0-rc.7",
    "@angular/platform-browser-dynamic": "9.0.0-rc.7",
    "@angular/router": "9.0.0-rc.7",
    "@aws-amplify/auth": "^2.1.2",
    "@aws-amplify/core": "^2.2.1",
    "@egjs/hammerjs": "^2.0.17",
    "@types/vis": "^4.21.19",
    "angular-file-uploader": "^5.0.2",
    "angular-webstorage-service": "^1.0.2",
    "aws-amplify-angular": "^4.1.2",
    "core-js": "^3.6.2",
    "jquery": "^3.4.1",
    "keycharm": "^0.3.1",
    "ngx-color-picker": "^8.2.0",
    "popper.js": "^1.16.0",
    "rxjs": "^6.5.4",
    "tslib": "^1.10.0",
    "vis-data": "^6.3.1",
    "vis-network": "^6.5.0",
    "vis-util": "^2.0.2",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular/cli": "^9.0.0-rc.7",
    "@angular/compiler-cli": "9.0.0-rc.7",
    "@angular/language-service": "9.0.0-rc.7",
    "@types/jasmine": "^3.5.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "~3.0.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "protractor": "^5.4.2",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.6.4",
    "webpack-bundle-analyzer": "^3.6.0",
    "webpack-cli": "^3.3.10"
  },
  "description": "sadf",
  "main": "index.js"
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "types": ["node"],
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "module": "esnext",
    "baseUrl": "./",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true

  }
}
Environment VS Code Angular CLI: 9.0.0-rc.7 Node: 10.16.3 OS: win32 x64 Angular: 9.0.0-rc.7 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Ivy Workspace: Yes
@alexAlchemy alexAlchemy added the to-be-reproduced Used in order for Amplify to reproduce said issue label Jan 8, 2020
@iartemiev iartemiev added the Angular Related to Angular 2+ label Jan 8, 2020
@hfahlbusch
Copy link

@alexAlchemy Have you switched your rendering engine to Ivy in Angular 9 or have you already opted for Ivy in your Angular 8 project?
At the moment there are issues with template checking and/or ivy renderer.
You could try switching off Ivy and disabling "fullTemplateTypeCheck" in your angularCompilerOptions in tsconfig.json

@ericclemmons
Copy link
Contributor

@hfahlbusch Those issues are specific to Amplify, or is there a broader issue thread or PR for fullTemplateTypeCheck?

@ericclemmons
Copy link
Contributor

I'm looking into this, but we do have a note in our docs regarding Ivy support:

Please also note that the AWS Amplify Angular components do not yet support Ivy.
https://aws-amplify.github.io/docs/js/angular#angular-6-support

@ericclemmons
Copy link
Contributor

@alexAlchemy Can you confirm if you've opted out of ivy (per @hfahlbusch's suggestion) and are still experiencing issues?

If so, then this would be a bug for us to reproduce & address. Otherwise, we can mark this as a feature request to go into #3279 for Ivy support with Angular 9.

@alexAlchemy
Copy link
Author

I did not have ivy on angular 8 and when I switched to 9 it was enabled by default.

I can confirm that by opting out of Ivy the build passed.

@hfahlbusch
Copy link

@ericclemmons The template check is root cause of multiple issues. For example this issue => #3620

Sadly there is already a PR pending since a few month, that could prevent these additional issues.
#3793

@ericclemmons
Copy link
Contributor

@hfahlbusch Thanks for cross-linking these issues/PRs! The error from @alexAlchemy is different from #3620, but given the same solution, I think the best course of action is to validate #3793 against this issue as well and finally get it merged.

Thanks again for your help on this!

@ericclemmons ericclemmons added bug Something isn't working and removed to-be-reproduced Used in order for Amplify to reproduce said issue labels Jan 9, 2020
@ericclemmons
Copy link
Contributor

(Calling this a bug, because it seems to be more of a compatibility issue than a feature request.)

@LosD
Copy link
Contributor

LosD commented Feb 4, 2020

I'm pretty sure that's not an issue with the template checker.

It seems to be an issue with the module using the spread operator and how it is pre-compiled (apparently it's targeted for old JS?), which makes the compiled module be a function instead of an array:

amplify-angular-module.ts:

@NgModule({
	imports: [CommonModule, FormsModule],
	declarations: [DynamicComponentDirective, ...components],
	entryComponents: [...components],
	providers: [],
	exports: [...components],
})
export class AmplifyAngularModule {}

Precompiled aws-amplify-angular.module.js:

var AmplifyAngularModule = /** @class */ (function () {
    function AmplifyAngularModule() {
    }
    AmplifyAngularModule.decorators = [
        { type: NgModule, args: [{
                    imports: [CommonModule, FormsModule],
                    declarations: __spreadArrays([DynamicComponentDirective], components),
                    entryComponents: __spreadArrays(components),
                    providers: [],
                    exports: __spreadArrays(components),
                },] },
    ];
    return AmplifyAngularModule;
}());
export { AmplifyAngularModule };
//# sourceMappingURL=aws-amplify-angular.module.js.map

@mpgo13
Copy link

mpgo13 commented Feb 7, 2020

Upgraded to angular 9, opting out of Ivy works for me, but would love to see Ivy support soon!

ERROR in Failed to compile entry-point aws-amplify-angular (module as esm5) due to compilation errors:
node_modules/aws-amplify-angular/dist/src/aws-amplify-angular.module.js:93:35 - error NG1010: Expected array when reading the NgModule.declarations of AmplifyAngularModule

93                     declarations: __spreadArrays([DynamicComponentDirective], components),
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/aws-amplify-angular/dist/src/aws-amplify-ionic-module.js:67:35 - error NG1010: Expected array when reading the NgModule.declarations of AmplifyIonicModule

67                     declarations: __spreadArrays(components),
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~

@ddotx
Copy link

ddotx commented Feb 7, 2020

ERROR TypeError: Cannot read property 'viewContainerRef' of undefined

at PhotoPickerComponent.push../node_modules/aws-amplify-angular/dist/src/components/storage/photo-picker-component/photo-picker.factory.js.PhotoPickerComponent.loadComponent (photo-picker.factory.js:45)
at PhotoPickerComponent.push../node_modules/aws-amplify-angular/dist/src/components/storage/photo-picker-component/photo-picker.factory.js.PhotoPickerComponent.ngOnInit (photo-picker.factory.js:28)

@ericclemmons ericclemmons added this to the Angular 9 (Ivy) Support milestone Feb 7, 2020
@KingDarBoja
Copy link

Updating to Angular 9 trigger these warning and error logs:

WARNING in Entry point 'aws-amplify-angular' contains deep imports into 'D:/Programming/pluriza_projects/website/node_modules/rxjs/Subject', 'D:/Programming/pluriza_projects/website/node_modules/rxjs/Observable'. This is probably not a problem, but may cause the compilation of entry points to be out of order.

ERROR in Failed to compile entry-point aws-amplify-angular (module as esm5) due to compilation errors:
node_modules/aws-amplify-angular/dist/src/aws-amplify-angular.module.js:93:35 - error NG1010: Expected array when reading the NgModule.declarations of AmplifyAngularModule

93                     declarations: __spreadArrays([DynamicComponentDirective], components),
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/aws-amplify-angular/dist/src/aws-amplify-ionic-module.js:67:35 - error NG1010: Expected array when reading the NgModule.declarations of AmplifyIonicModule

67                     declarations: __spreadArrays(components),

Waiting for some release in the meantime.

@rodrigorellana
Copy link

image

hi guys! I have the same error
so, we have to wait for a new amplify release ??

@damogallagher
Copy link

I am experiencing the same issue after upgrading to Angular 9. Wondering if anyone is aware of an ETA on the fix for this?

@Temkit
Copy link

Temkit commented Feb 10, 2020

Experiencing the same issue here after upgrading to Angular 9 !
I disabled the IVY compiler to successfully build !

in tsconfig.app.json :

"angularCompilerOptions": { "enableIvy": false }

@rodrigorellana
Copy link

rodrigorellana commented Feb 10, 2020

Experiencing the same issue here after upgrading to Angular 9 !
I disabled the IVY compiler to successfully build !

in tsconfig.app.json :

"angularCompilerOptions": { "enableIvy": false }

it works, but I guess using Ivy is the main feature of angular new change/release

@rodrigorellana
Copy link

image

I tried that Temkit says, but now I have this lol

@mjkelley354
Copy link

I'm having the same issue. Disabling Ivy does get the build to succeed but i still can't get the ui component to work.

Throws the following in the browser:
auth.component.html:1 ERROR TypeError: Cannot read property 'viewContainerRef' of undefined
at AuthenticatorComponent.push../node_modules/aws-amplify-angular/dist/src/components/authenticator/authenticator/authenticator.factory.js.AuthenticatorComponent.loadComponent (authenticator.factory.js:43)
at AuthenticatorComponent.push../node_modules/aws-amplify-angular/dist/src/components/authenticator/authenticator/authenticator.factory.js.AuthenticatorComponent.ngOnInit (authenticator.factory.js:27)
at checkAndUpdateDirectiveInline (core.js:32822)
at checkAndUpdateNodeInline (core.js:45557)
at checkAndUpdateNode (core.js:45496)
at debugCheckAndUpdateNode (core.js:46519)
at debugCheckDirectivesFn (core.js:46462)
at Object.updateDirectives (auth.component.html:1)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:46450)
at checkAndUpdateView (core.js:45461)

@divinealpine
Copy link

divinealpine commented Feb 11, 2020

Experiencing the same issue here after upgrading to Angular 9 !
I disabled the IVY compiler to successfully build !

in tsconfig.app.json :

"angularCompilerOptions": { "enableIvy": false }

Tried this but now getting a new error:

ERROR in node_modules/@types/node/index.d.ts:73:11 - error TS2300: Duplicate identifier 'IteratorResult'.

73 interface IteratorResult<T> { }
             ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.

41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
        ~~~~~~~~~~~~~~

  node_modules/@types/node/index.d.ts:73:11
    73 interface IteratorResult<T> { }
                 ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.
src/app/app-routing.module.ts:22:7 - error TS2343: This syntax requires an imported helper named '__spreadArrays' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.

22       ...homeRoutes,
         ~~~~~~~~~~~~~

upgrading types/node node did NOT help: npm install --save-dev @types/node
upgrading tslib did NOT help: npm i tslib

@rodrigorellana
Copy link

we are f*cked guys lol
let's wait for angular 10

@ericclemmons
Copy link
Contributor

We're getting some underlying changes out the door, then we'll get back to checking out the latest v9 stuff, thanks to #4883!

@arkhedr
Copy link

arkhedr commented Feb 13, 2020

Hello, guys any update on that. I am still stuck :)

@KingDarBoja
Copy link

Just found out the issue regarding aws-amplify-angular:

The library does use the spread syntax (operator ...) on ngModule declarations like as amplify-ionic-module.ts, but looks like the new Angular version broke it.

There is a Angular issue about that, in this case: ngcc: libraries using spread operator in object literals cannot be processed.

@LosD
Copy link
Contributor

LosD commented Feb 14, 2020

@KingDarBoja That issue seems to have been fixed, and included as far back as rc.11: angular/angular@9.0.0-rc.11...master

Rebroken, maybe?

@cedvdb
Copy link

cedvdb commented Apr 3, 2020

I'm getting this and we are not even using Ionic.

node_modules/@angular/forms/forms.d.ts:2699:22 - error NG6002: Appears in the NgModule.imports of AmplifyIonicModule, but could not be resolved to an NgModule class.

@singhrawatbipin
Copy link

Describe the bug
The application used aws-amplify and aws-amplify-angular. It was building as expected when on angular version 8 but after upgrade to angular version 9 the build process throws up the following error:

image

Tried uninstalling and installing the npm packages to makes sure its on latest but this didn't fix the issue.

It seems to be building the module as esm5 even though the target in tsconfig is set to es2015 which might be related but thats just a case.

Thanks in advance :-)

Update
I created a new angular 9 project and installed aws-amplify-angular and it built without error. The tsconfig.json was a little different so I copied it from the new project into my application but it didn't fix the error.

To Reproduce

package.json

{
  "name": "",
  "version": "0.0.1",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4200 --ssl",
    "buildprod": "ng build --prod --configuration=production",
    "buildstaging": "ng build --prod --configuration=staging",
    "builddev": "ng build --prod --configuration=devdeploy",
    "stats": "ng build --stats-json",
    "analyze": "webpack-bundle-analyzer dist/stats.json",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "~0.900.0-rc.7",
    "@angular/animations": "^9.0.0-rc.7",
    "@angular/cdk": "^9.0.0-rc.6",
    "@angular/common": "9.0.0-rc.7",
    "@angular/compiler": "9.0.0-rc.7",
    "@angular/core": "9.0.0-rc.7",
    "@angular/forms": "9.0.0-rc.7",
    "@angular/http": "7.2.15",
    "@angular/material": "^9.0.0-rc.6",
    "@angular/platform-browser": "9.0.0-rc.7",
    "@angular/platform-browser-dynamic": "9.0.0-rc.7",
    "@angular/router": "9.0.0-rc.7",
    "@aws-amplify/auth": "^2.1.2",
    "@aws-amplify/core": "^2.2.1",
    "@egjs/hammerjs": "^2.0.17",
    "@types/vis": "^4.21.19",
    "angular-file-uploader": "^5.0.2",
    "angular-webstorage-service": "^1.0.2",
    "aws-amplify-angular": "^4.1.2",
    "core-js": "^3.6.2",
    "jquery": "^3.4.1",
    "keycharm": "^0.3.1",
    "ngx-color-picker": "^8.2.0",
    "popper.js": "^1.16.0",
    "rxjs": "^6.5.4",
    "tslib": "^1.10.0",
    "vis-data": "^6.3.1",
    "vis-network": "^6.5.0",
    "vis-util": "^2.0.2",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular/cli": "^9.0.0-rc.7",
    "@angular/compiler-cli": "9.0.0-rc.7",
    "@angular/language-service": "9.0.0-rc.7",
    "@types/jasmine": "^3.5.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "~3.0.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "protractor": "^5.4.2",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.6.4",
    "webpack-bundle-analyzer": "^3.6.0",
    "webpack-cli": "^3.3.10"
  },
  "description": "sadf",
  "main": "index.js"
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "types": ["node"],
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "module": "esnext",
    "baseUrl": "./",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true

  }
}

Environment

Describe the bug
The application used aws-amplify and aws-amplify-angular. It was building as expected when on angular version 8 but after upgrade to angular version 9 the build process throws up the following error:

image

Tried uninstalling and installing the npm packages to makes sure its on latest but this didn't fix the issue.

It seems to be building the module as esm5 even though the target in tsconfig is set to es2015 which might be related but thats just a case.

Thanks in advance :-)

Update
I created a new angular 9 project and installed aws-amplify-angular and it built without error. The tsconfig.json was a little different so I copied it from the new project into my application but it didn't fix the error.

To Reproduce

package.json

{
  "name": "",
  "version": "0.0.1",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4200 --ssl",
    "buildprod": "ng build --prod --configuration=production",
    "buildstaging": "ng build --prod --configuration=staging",
    "builddev": "ng build --prod --configuration=devdeploy",
    "stats": "ng build --stats-json",
    "analyze": "webpack-bundle-analyzer dist/stats.json",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/build-angular": "~0.900.0-rc.7",
    "@angular/animations": "^9.0.0-rc.7",
    "@angular/cdk": "^9.0.0-rc.6",
    "@angular/common": "9.0.0-rc.7",
    "@angular/compiler": "9.0.0-rc.7",
    "@angular/core": "9.0.0-rc.7",
    "@angular/forms": "9.0.0-rc.7",
    "@angular/http": "7.2.15",
    "@angular/material": "^9.0.0-rc.6",
    "@angular/platform-browser": "9.0.0-rc.7",
    "@angular/platform-browser-dynamic": "9.0.0-rc.7",
    "@angular/router": "9.0.0-rc.7",
    "@aws-amplify/auth": "^2.1.2",
    "@aws-amplify/core": "^2.2.1",
    "@egjs/hammerjs": "^2.0.17",
    "@types/vis": "^4.21.19",
    "angular-file-uploader": "^5.0.2",
    "angular-webstorage-service": "^1.0.2",
    "aws-amplify-angular": "^4.1.2",
    "core-js": "^3.6.2",
    "jquery": "^3.4.1",
    "keycharm": "^0.3.1",
    "ngx-color-picker": "^8.2.0",
    "popper.js": "^1.16.0",
    "rxjs": "^6.5.4",
    "tslib": "^1.10.0",
    "vis-data": "^6.3.1",
    "vis-network": "^6.5.0",
    "vis-util": "^2.0.2",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular/cli": "^9.0.0-rc.7",
    "@angular/compiler-cli": "9.0.0-rc.7",
    "@angular/language-service": "9.0.0-rc.7",
    "@types/jasmine": "^3.5.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "~3.0.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "protractor": "^5.4.2",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.6.4",
    "webpack-bundle-analyzer": "^3.6.0",
    "webpack-cli": "^3.3.10"
  },
  "description": "sadf",
  "main": "index.js"
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "types": ["node"],
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "module": "esnext",
    "baseUrl": "./",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true

  }
}

Environment

I had the similar issue and this is how I resolved it.
Go to the angular.json file then search for aot and if the value of aot is true then replace it with false.

@singhrawatbipin
Copy link

I am experiencing the same issue after upgrading to Angular 9. Wondering if anyone is aware of an ETA on the fix for this?

I had the similar issue and this is how I resolved it.
Go to the angular.json file then search for aot and if the value of aot is true then replace it with false.

@wickstargazer
Copy link

I'm getting this and we are not even using Ionic.

node_modules/@angular/forms/forms.d.ts:2699:22 - error NG6002: Appears in the NgModule.imports of AmplifyIonicModule, but could not be resolved to an NgModule class.

Did u use the package I published?

@singhrawatbipin
Copy link

Experiencing the same issue here after upgrading to Angular 9 !
I disabled the IVY compiler to successfully build !
in tsconfig.app.json :
"angularCompilerOptions": { "enableIvy": false }

Tried this but now getting a new error:

ERROR in node_modules/@types/node/index.d.ts:73:11 - error TS2300: Duplicate identifier 'IteratorResult'.

73 interface IteratorResult<T> { }
             ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.

41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
        ~~~~~~~~~~~~~~

  node_modules/@types/node/index.d.ts:73:11
    73 interface IteratorResult<T> { }
                 ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.
src/app/app-routing.module.ts:22:7 - error TS2343: This syntax requires an imported helper named '__spreadArrays' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.

22       ...homeRoutes,
         ~~~~~~~~~~~~~

upgrading types/node node did NOT help: npm install --save-dev @types/node
upgrading tslib did NOT help: npm i tslib

Or we can just set the aot to false in angular.json file.

@singhrawatbipin
Copy link

I'm getting this and we are not even using Ionic.
node_modules/@angular/forms/forms.d.ts:2699:22 - error NG6002: Appears in the NgModule.imports of AmplifyIonicModule, but could not be resolved to an NgModule class.

Did u use the package I published?

No, I have been using default.

@KingDarBoja
Copy link

KingDarBoja commented Apr 14, 2020

I just tried again by updating to the latest version of aws-amplify-angular (v5.0.7) and now getting a new error.

ERROR in The target entry-point "aws-amplify-angular" has missing dependencies:
 - @aws-amplify/analytics
 - @aws-amplify/api
 - @aws-amplify/pubsub
 - @aws-amplify/interactions
 - @aws-amplify/xr

Had to install aws-amplify in order to get rid of this.

@wickstargazer
Copy link

So version 5.0.7 is working now?

@djoyrocks
Copy link

Hi, I have faced the same issue with Angular 9.0.1.
I have upgraded to the latest angular version 9.1.1 and the project started to compile.

"dependencies": {
"@agm/core": "1.1.0",
"@angular/animations": "9.1.2",
"@angular/cdk": "9.0.0",
"@angular/common": "9.1.2",
"@angular/compiler": "9.1.2",
"@angular/core": "9.1.2",
"@angular/fire": "6.0.0",
"@angular/flex-layout": "9.0.0-beta.29",
"@angular/forms": "9.1.2",
"@angular/material": "9.0.0",
"@angular/material-moment-adapter": "9.0.0",
"@angular/platform-browser": "9.1.2",
"@angular/platform-browser-dynamic": "9.1.2",
"@angular/router": "9.1.2",
"@aws-amplify/ui-angular": "0.2.2",
"@ngrx/effects": "8.6.0",
"@ngrx/router-store": "8.6.0",
"@ngrx/store": "8.6.0",
"@ngrx/store-devtools": "8.6.0",
"@ngx-pwa/local-storage": "9.0.3",
"@ngx-translate/core": "12.1.1",
"@swimlane/dragula": "3.8.0",
"@swimlane/ngx-charts": "13.0.2",
"@swimlane/ngx-datatable": "16.0.3",
"@swimlane/ngx-dnd": "8.1.0",
"@types/moment": "2.13.0",
"@types/prismjs": "1.16.0",
"angular-calendar": "0.28.2",
"angular-gridster2": "9.0.1",
"angular-resize-event": "1.2.1",
"aws-amplify": "3.0.6",
"aws-amplify-angular": "5.0.6",
"chart.js": "2.9.3",
"classlist.js": "1.1.20150312",
"core-js": "3.6.4",
"d3": "5.15.0",
"date-fns": "2.9.0",
"firebase": "7.14.1",
"g": "2.0.1",
"guid-typescript": "1.0.9",
"hammerjs": "2.0.8",
"jquery": "3.4.1",
"lakmus": "0.3.0",
"lodash": "4.17.15",
"moment": "2.24.0",
"ng-appversion": "1.3.0",
"ng-dynamic-component": "6.0.0",
"ng2-charts": "2.3.0",
"ngx-color-picker": "9.0.0",
"ngx-cookie-service": "2.3.0",
"ngx-moment": "3.5.0",
"ngx-widget-grid": "8.0.0-patch1",
"npm": "6.13.7",
"perfect-scrollbar": "1.5.0",
"primeicons": "2.0.0",
"primeng": "9.0.5",
"prismjs": "1.19.0",
"rxjs": "6.5.4",
"rxjs-compat": "6.5.4",
"screenfull": "5.0.2",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/architect": "~0.900",
"@angular-devkit/build-angular": "~0.900.2",
"@angular-devkit/build-ng-packagr": "~0.900.2",
"@angular/cli": "9.1.1",
"@angular/compiler-cli": "9.1.2",
"@angular/language-service": "9.1.2",
"@angularclass/hmr": "2.1.3",
"@types/jasmine": "3.5.5",
"@types/jasminewd2": "2.0.8",
"@types/lodash": "4.14.149",
"@types/node": "^12.11.1",
"browser-sync": "2.26.7",
"codelyzer": "^5.1.2",
"firebase-tools": "^8.0.0",
"fuzzy": "^0.1.3",
"inquirer": "^6.2.2",
"inquirer-autocomplete-prompt": "^1.0.1",
"jasmine-core": "3.5.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.4.1",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "2.1.1",
"karma-jasmine": "3.1.1",
"karma-jasmine-html-reporter": "1.5.2",
"ng-packagr": "^9.0.0",
"protractor": "5.4.3",
"ts-node": "8.6.2",
"tslint": "6.0.0",
"typescript": "3.7.5",
"webpack-bundle-analyzer": "3.6.0"
}

Now I am getting content security policy error while loading aws-lex-audio.js
amplify csp error

@djoyrocks
Copy link

Hi After tackling CSP error again getting an error
ERROR TypeError: Cannot read property 'viewContainerRef' of undefined
at ChatBotComponent.push../node_modules/aws-amplify-angular/ivy_ngcc/dist/src/components/interactions/chatbot/chatbot.factory.js.ChatBotComponent.loadComponent

amplify csp error 1

@jpekeene
Copy link

jpekeene commented May 1, 2020

Hi I'm using import { Auth, Amplify } from 'aws-amplify'; to import amplify for authentication. Have just moved to Angular 9.1.4 and am getting the below:-
ERROR in ./node_modules/@aws-sdk/signature-v4/dist/es/cloneRequest.js 13:94-108 "export '__spreadArrays' was not found in 'tslib'

my tsconfig.json:-
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"paths": {
"@assets/": ["assets/"],
"@styles/": ["styles/"],
"@env/": ["environments/"]
}
}
}

Any ideas?

@jpekeene
Copy link

jpekeene commented May 2, 2020

So the version of tslib that signature-v4 is using is old and doesn't have __spreadArrays so I tried just upgrading signature-v4 but then it seemed everything else in @aws-sdk was using the old tslib. So finally I did yarn upgrade @aws-sdk/* --save and that seems to have done the job, I can now load up the application.

@Bampho
Copy link

Bampho commented May 12, 2020

Also upgraded from Angular 8.3 to Angular 9 I gives me a compilation error: failed to find expected name of node (MatIconModule = /** @Class */ (function () {
}

I recently moved from 1.x so I can't figure a lot of things as yet

@alexvdvalk
Copy link

AWS has released a new Amplify angular module for v9 and up, so I believe this current issue will not be resolved. I migrated to the new version and updated my app to v9 and it's quite different to this one, and the current documentation is limited.

This is the extent of the migration documentation so far.

@ericclemmons
Copy link
Contributor

@alexvdvalk Can you click the feedback link on https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular#migration to open an issue in our https://github.com/aws-amplify/docs/ project so we can improve the migration flow?

Angular 9 became the latest release while @aws-amplify/ui-angular was in progress, so it got support by default.

Ideally, https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular#migration would be the easiest way to get things working in Angular 9, but if that's not the case, then we want to address that.

@alexvdvalk
Copy link

alexvdvalk commented May 13, 2020

Hey guys, thankz for the response, i opened a PR for this and waiting for them to officially

  1. Update yarn version to support ivy
  2. Review the code and confirm the tests
  3. Merge the Pull Request and we can move back to the official package!

For now, anyone has a hurry or urgent need like us, please use the ‘@flowaccount/awns-amplify-angular’ :)

Regards,
Wick

Thanks for sharing this. I've got it rendering on Angular 9 and Ivy, but the [hide] property on amplify-authenticator component the has stopped working for me. I'm trying to hide the signup link. any ideas or suggestions?

@kleky
Copy link

kleky commented Jun 3, 2020

I've had enough. aws-amplify does not work with (our) Angular 9.

@ericclemmons
Copy link
Contributor

@kleky We've refactored the UI components to support Angular 9:

https://docs.amplify.aws/ui/q/framework/angular

Migration should only require a few lines to update:

https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular#migration

Let us know if that resolves things for you!

@kleky
Copy link

kleky commented Jun 4, 2020

Thanks, but there must be something weird in our app that's causing issues. I'm trying to move from using only amazon-cognito-identity-js, to using Amplify, but no matter what I do it won't build. I tried turning off aot and ivy, upgrading to latest ng v9, upgrading tslib and types/node, removing node_modules and re-installing and lots of other random installs in the hope of success.

ERROR in ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 277:10-19
"export 'immerable' was not found in 'immer'
ERROR in ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 291:10-19
"export 'immerable' was not found in 'immer'

I'll have to leave this for now, but maybe someone could let me know the state of amazon-cognito-identity-js, as this library is archived. Is it essentially deprecated?

@dvago
Copy link

dvago commented Jun 4, 2020

same issue is happening in a non Angular project, my build is using vue.js

"aws-amplify": "^3.0.16",
"vue": "^2.6.11",
"vue-router": "^3.3.2",
"vuex": "^3.4.0"

this is the error coming up:

./node_modules/@aws-sdk/signature-v4/dist/es/cloneRequest.js
"export '__spreadArrays' was not found in 'tslib'

@sammartinez
Copy link
Contributor

sammartinez commented Jul 9, 2020

I'll have to leave this for now, but maybe someone could let me know the state of amazon-cognito-identity-js, as this library is archived. Is it essentially deprecated?

We do have amazon-cognito-identity-js within our packages, which package are you using?

@kleky
Copy link

kleky commented Jul 10, 2020

I'll have to leave this for now, but maybe someone could let me know the state of amazon-cognito-identity-js, as this library is archived. Is it essentially deprecated?

We do have amazon-cognito-identity-js within our packages, which package are you using?

amazon-cognito-identity-js is the only library I'm using to use cognito on the front end. I looked at swapping it to use Amplify, but it simply would not build at all.

@sammartinez
Copy link
Contributor

Understood @kleky but you mentioned that the package is archived, which it is not and is existing within our monorepo. Is this the package you are using or something else?

@kleky
Copy link

kleky commented Jul 10, 2020

Hi, i think i took this repo to be the one pulled as npm i amazon-cognito-identity-js but looks like i was wrong - it actually pulls the package in the Amplify repo. My apologies.

@ericclemmons
Copy link
Contributor

Hi everyone,

I've been reviewing this thread this morning, and I could use your help.

The original problem (and workaround) with Angular 9 prompted us to rewrite our UI components (starting with the Authenticator) to solve these issues:

https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular

(The primary goal of this rewrite was to ensure Angular, React, and Vue versions stayed in sync with features & fixes.)

But there are multiple similar, but different, issues as part of this thread that warrants their own research, debugging, and solutions.

So this is where I need your help:

  • If you're using Angular 9, please migrate from aws-amplify-angular to @aws-amplify/ui-angular for first-class support.

    If anything doesn't meet your expectations, please open an issue with the specifics so we can address it there for you and all Angular/Vue/React users.

    (I just tested my Angular 9 app again with <amplify-authenticator> and it worked well!)

  • If you're experiencing issues with aws-amplify and not aws-amplify-angular, please open a new issue.

  • If you're experiencing something other problem, again, please open an issue.

Each of the problems you all are experiencing are important for us to resolve, which is why we've left this thread open for so long.

But, in the interest of tactically resolving these individual issues, we'll need to close this thread and move discussion to those instead.

Feel free to ping me (@ericclemmons) once you create an issue for tracking! 🙏

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Angular Related to Angular 2+ bug Something isn't working
Projects
None yet
Development

No branches or pull requests