angular-hybrid: Version 10 breaks with angular-cli buildOptimizer+optimization

So after the upgrade to @uirouter/angular-hybrid@10.0.0, we’re getting issues whenever running with --prod. Build is fine, but when running app gets;

TypeError: Cannot read property 'subscribe' of undefined
    at new t (main.41a1ba9f91d11bc569f1.js:formatted:113389)
    at qr (main.41a1ba9f91d11bc569f1.js:formatted:99813)
    at Wr (main.41a1ba9f91d11bc569f1.js:formatted:99756)
    at Bs (main.41a1ba9f91d11bc569f1.js:formatted:101757)
    at Object.Fs [as createEmbeddedView] (main.41a1ba9f91d11bc569f1.js:formatted:101678)
    at e.createEmbeddedView (main.41a1ba9f91d11bc569f1.js:formatted:99454)
    at t.createEmbeddedView (main.41a1ba9f91d11bc569f1.js:formatted:99278)
    at t._updateView (main.41a1ba9f91d11bc569f1.js:formatted:109315)
    at t.set [as ngIf] (main.41a1ba9f91d11bc569f1.js:formatted:109287)
    at Zr (main.41a1ba9f91d11bc569f1.js:formatted:99884)

Which I’ve managed to identify to be this line in @uirouter/angular.

I set up a simple angular-hybrid example to try to identify the problem, and with this project I get;

main.6b5af00a46ac95f21a36.js:1 Error: [$injector:unpr] Unknown provider: class t{}DirectiveProvider <- class t{}Directive
https://errors.angularjs.org/1.7.9/$injector/unpr?p0=class%20t%7B%7DDirectiveProvider%20%3C-%20class%20t%7B%7DDirective
    at main.6b5af00a46ac95f21a36.js:1
    at main.6b5af00a46ac95f21a36.js:1
    at Object.u [as get] (main.6b5af00a46ac95f21a36.js:1)
    at main.6b5af00a46ac95f21a36.js:1
    at Object.u [as get] (main.6b5af00a46ac95f21a36.js:1)
    at main.6b5af00a46ac95f21a36.js:1
    at t.makeComponentTemplate (main.6b5af00a46ac95f21a36.js:1)
    at t.getTemplate (main.6b5af00a46ac95f21a36.js:1)
    at Object.<anonymous> (main.6b5af00a46ac95f21a36.js:1)
    at main.6b5af00a46ac95f21a36.js:1 "<ui-view class="ng-scope">"

It appears as if UIRouter is trying to render a Angular view as a AngularJS view.

Configurations and their successes

I assume it has something to do with the move to ng-packagr, but I don’t really know how to investigate what is the issue.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@petebacondarwin

  1. Installed
  2. manually changed "sideEffectes": true in @uirouter/angular-hybrid/package.json
  3. ng serve --prod

Works! 😃 Tried with @angular/*@9.0.0-4c.4 and @uirouter/angular-hybrid@10.0.0 (obviously) and Ivy on.

This should fix the problem the next time that @christopherthielen publishes a release - https://github.com/ui-router/angular-hybrid/pull/385

In the meantime the workaround is to write a short postinstall script in your application project to delete the `“sideEffects: false” line from the package.json file.