question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AOT Failing on ng build --prod --aot=true

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [X ] bug report -> please search for issues before submitting
- [ ] feature request

Versions.

keycloak-angular 2.0.0 Angular 5.2

Repro steps.

Download and install @2.0.0 Add keycloak module Add init run build and note error:

import { BrowserModule } from '@angular/platform-browser';
import {APP_INITIALIZER, NgModule} from '@angular/core';
import { AppComponent } from './app.component';
import { TreasureComponent } from './treasure/treasure.component';
import { LandingComponent } from './landing/landing.component';
import {appRoutes} from './app.routes';
import {HttpClientModule} from '@angular/common/http';
import {KeycloakAngularModule, KeycloakService} from 'keycloak-angular';
import {initializer} from './init';


@NgModule({
  declarations: [
    AppComponent,
    TreasureComponent,
    LandingComponent
  ],
  imports: [
    appRoutes,
    BrowserModule,
    HttpClientModule,
    KeycloakAngularModule
  ],
  providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: initializer,
      multi: true,
      deps: [KeycloakService]
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

./init.ts

import {KeycloakService} from 'keycloak-angular';

export function initializer(keycloak: KeycloakService): () => Promise<any> {
  return (): Promise<any> => {
    return new Promise(async (resolve, reject) => {
      try {
        await keycloak.init();
        resolve();
      } catch (error) {
        reject(error);
      }
    });
  };
}

Next:

ng build --prod --aot=true

Date: 2018-05-22T18:37:13.094Z
Hash: 945915fac13ecc0872fa
Time: 2448ms
chunk {0} styles.ac89bfdd6de82636b768.bundle.css (styles) 0 bytes [initial] [rendered]
chunk {1} polyfills.997d8cc03812de50ae67.bundle.js (polyfills) 84 bytes [initial] [rendered]
chunk {2} main.ee32620ecd1edff94184.bundle.js (main) 84 bytes [initial] [rendered]
chunk {3} inline.318b50c57b4eba3d437b.bundle.js (inline) 796 bytes [entry] [rendered]

ERROR in : Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @fish/auth-module@0.0.7 build: `ng build --prod --aot=true`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @fish/auth-module@0.0.7 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jmurphy/.npm/_logs/2018-05-22T18_37_13_120Z-debug.log

Expected: AOT should work

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mauriciovigolocommented, May 30, 2018

New versions released. All tested and working with aot. Thanks everybody!

2reactions
mauriciovigolocommented, May 24, 2018

Hi, I’m working on this issue. @rightisleft, thanks for reporting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular-cli aot build fails in production mode - Stack Overflow
So the project builds fine with ng build --aot=true but fails with this error using ng build --prod. I did some debugging of...
Read more >
Ahead-of-time (AOT) compilation - Angular
The AOT compiler detects and reports template binding errors during the build step before users can see them. Better security, AOT compiles HTML...
Read more >
Angular CLI - ng build Command - Tutorialspoint
Sr.No. Option & Syntax Description 2 ‑‑baseHref=baseHref Base url for the application being built. 9 ‑‑deployUrl=deployUrl URL where files will be deployed. 17 ‑‑localize=true|false
Read more >
Angular Ivy
In the angular.json workspace configuration file, set the default build options for your project to always use AOT compilation. When using application ...
Read more >
How to Optimize your Angular Application for Production
The ng build command compiles your angular code and places it in the dist folder by ... ng build --prod --aot=true --buildOptimizer=true.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found