Angular-cli: build on angular 5 with errors for production but developer mode works fine

Created on 10 Nov 2017  路  13Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

  • [x] bug report -> please search issues before submitting
  • [ ] feature request

Versions.

Angular CLI: 1.5.0
Node: 8.9.1
OS: win32 x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

angular/cli: 1.5.0
angular-devkit/build-optimizer: 0.0.32
angular-devkit/core: 0.0.20
angular-devkit/schematics: 0.0.35
ngtools/json-schema: 1.1.0
ngtools/webpack: 1.8.0
schematics/angular: 0.1.2
typescript: 2.4.2
webpack: 3.8.1

Repro steps.

https://github.com/Widrogo/cakephp3-angular5

The project is quite new I just put a template, change what is necessary to use it with angular 5 and with ng serve me it runs without any error.

When I made the build for production it generates errors, it is because I use a modified modernizr script cakephp3-angular5/src/assets/js/modernizr.custom.32033.js it is just declared on angular-cli.json

Uncaught TypeError: Cannot read property 'html5' of undefined
at scripts.b43496ed343a01b5b3b7.bundle.js:11
at scripts.b43496ed343a01b5b3b7.bundle.js:11
at scripts.b43496ed343a01b5b3b7.bundle.js:11

I'm sure that the build causes problems because this is the only file that I handle html5 and debugging is the error here when I run the build.

For build test with different commands:

ng build --prod
ng build --prod --aot
ng build --prod --aot
ng build --prod --aot --base-href ./

And test the app with this:
ng serve --prod
give the same error that build for produccion

The log given by the failure.

Desired functionality.

I just want the build to work or production mode where it fails

Mention any other details that might be useful.

I'm using a modernzr modefied
https://stackoverflow.com/questions/47226546/modernizr-with-the-build-on-angular-5

devkibuild-angular

Most helpful comment

+1 as well (angular 5).
This is a major bug. My whole project is now garbage.
Everything works smoothly on developer mode, and then production fails to load a page with a message:
"l is not a constructor" - the worst thing about it is I have no clue where the source of the error is, because it's all uglified, in one row and with too many "l" variables.

All 13 comments

+1

On my project, In the production mode, all forms, made on the basis of FormControl FormGroup, don't working, without error, returning empty values.

It is very shame to do not test the angular before publishing to the world!

+1 with angular 5.2 - forms have empty values

@monoflash, have you found a workaround?

@gozzoo What version is your CLI? Just ran into this, updating to CLI 1.6.4 seemed to fix it.

@monoflash yes for me too. thanks anyways.

+1
in development mode everything works fine, but in production some pages doesn't render, and it prints out to the console this:

````
ERROR Error: Uncaught (in promise): TypeError: I.a.merge is not a function

TypeError: I.a.merge is not a function
at n.init (main.d43128a28b4131a72b5b.bundle.js:1)
at new n (main.d43128a28b4131a72b5b.bundle.js:1)
at co (main.d43128a28b4131a72b5b.bundle.js:1)
at io (main.d43128a28b4131a72b5b.bundle.js:1)
at Uo (main.d43128a28b4131a72b5b.bundle.js:1)
at Qo (main.d43128a28b4131a72b5b.bundle.js:1)
at Zo (main.d43128a28b4131a72b5b.bundle.js:1)
at Uo (main.d43128a28b4131a72b5b.bundle.js:1)
at Qo (main.d43128a28b4131a72b5b.bundle.js:1)
at Zo (main.d43128a28b4131a72b5b.bundle.js:1)
at n.init (main.d43128a28b4131a72b5b.bundle.js:1)
at new n (main.d43128a28b4131a72b5b.bundle.js:1)
at co (main.d43128a28b4131a72b5b.bundle.js:1)
at io (main.d43128a28b4131a72b5b.bundle.js:1)
at Uo (main.d43128a28b4131a72b5b.bundle.js:1)
at Qo (main.d43128a28b4131a72b5b.bundle.js:1)
at Zo (main.d43128a28b4131a72b5b.bundle.js:1)
at Uo (main.d43128a28b4131a72b5b.bundle.js:1)
at Qo (main.d43128a28b4131a72b5b.bundle.js:1)
at Zo (main.d43128a28b4131a72b5b.bundle.js:1)
at v (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at v (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at polyfills.9f81ca5a629ad134b6f8.bundle.js:1
at t.invokeTask (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at Object.onInvokeTask (main.d43128a28b4131a72b5b.bundle.js:1)
at t.invokeTask (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at n.runTask (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at h (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at n.invokeTask [as invoke] (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
at f (polyfills.9f81ca5a629ad134b6f8.bundle.js:1)
In @ main.d43128a28b4131a72b5b.bundle.js:1

+1
Basic TypeErrors like :
ERROR in src\app\app.component.html(1,8): : Property '_connected' is protected and only accessible within class 'AppComponent' and its subclasses.
appear only when build prod

CLI 1.6.4

Same thing happen before in #5620 ?

+1
in development mode everything works fine, but in production pages doesn't render all, and it prints out to the console this:

ERROR TypeError: T.a.merge is not a function
    at e.subscribeEvents (0.f529074cf8b4f36dbf99.chunk.js:1)
    at new e (0.f529074cf8b4f36dbf99.chunk.js:1)
    at vo (main.372a11c5aeacdc513273.bundle.js:1)
    at fo (main.372a11c5aeacdc513273.bundle.js:1)
    at Ko (main.372a11c5aeacdc513273.bundle.js:1)
    at Object.Ho [as createEmbeddedView] (main.372a11c5aeacdc513273.bundle.js:1)
    at t.createEmbeddedView (main.372a11c5aeacdc513273.bundle.js:1)
    at e.createEmbeddedView (main.372a11c5aeacdc513273.bundle.js:1)
    at e._updateView (main.372a11c5aeacdc513273.bundle.js:1)
    at e.set [as ngIf] (main.372a11c5aeacdc513273.bundle.js:1)

* Found out my error was related to RxJS 5.5 and higher with Kendo-ui for angular
https://github.com/telerik/kendo-angular/issues/1244

Same thing for me. No error while in dev mod, but when i try to build i got a lot of errors that were not raised before.
Angular 6

I found out that there are extra tests during the prod build. I just started compiling more often. but here is more details about what worked for me. https://stackoverflow.com/questions/50337954/angular-5-ng-build-shows-no-errors-ng-build-prod-has-many-errors

Seriously! this is huge. Has anyone found answers?

All through dev there were no errors now at launch i have 20 errors that make no sense. The errors should have been seen during dev. Please help

+1 here, angular 7 and angular 2.

+1 as well (angular 5).
This is a major bug. My whole project is now garbage.
Everything works smoothly on developer mode, and then production fails to load a page with a message:
"l is not a constructor" - the worst thing about it is I have no clue where the source of the error is, because it's all uglified, in one row and with too many "l" variables.

We've had a couple of problems with production bundles and optimization in the past, but it's hard to know what's going on from the reports here. The problems that you are experiencing might very well be fixed in the latest CLI versions. You can get more details about the exact line where the problem comes up by adding in sourcemaps to your projection builds too.

If you're still having problems on production builds only, can you open a new issue and setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings