bcgov / MyGovBC-CAPTCHA-Widget

An angularjs 2-4 component for displaying the CAPTCHA to the user and calling the service for validation
Apache License 2.0
1 stars 2 forks source link

CAPTCHA Widget is doesn't work with `ng build --prod`, specifically the `--aot` flag. #3

Closed acoard closed 6 years ago

acoard commented 6 years ago

Versions Ran in the the folder of a fresh clone of angular-scaffold

@angular/cli: 1.1.3
node: 7.6.0
os: darwin x64
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/compiler-cli: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.3

Current Behaviour

With the widget installed and used in bcgov/angular-scaffold the ng build --prod command fails with the following error:

ERROR in Unexpected value 'undefined' declared by the module 'AppModule in .../mygov/angular-scaffold/src/app/app.module.ts'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '.../mygov/angular-scaffold/src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

This command also happens if you run ng build --aot=true. The --prod flag is shorthand for a bunch of other flags, and after some trial and error I found out it was only the --aot flag which was an issue. (ng build --prod --aot=false compiles fine).

Desired Behaviour

An angular-scaffold project can run ng build --prod when using the CAPTCHA widget.

Steps to Reproduce

  1. Clone angular-scaffold
  2. yarn add git+https://github.com/bcgov/MyGovBC-CAPTCHA-Widget.git
  3. Add CaptchaComponent to app.module.ts, copying directly from the readme.
  4. Modify app.component.html, replacing <router-outlet> with the CAPTCHA snippet from the readme.
  5. Run ng build --prod

If you have any questions let me know. The above notwithstanding it's a great widget, thanks for making it.

GregTurner commented 6 years ago

Thanks @acoard for reporting, I've recreated the issue as reported.

acoard commented 6 years ago

This has been resolved by Yiling in version 2.0.8. Just update your package.json and you're good to go.

Note: README has not been updated, so look at angular-scaffold-captcha for example on how to integrate.