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
-
@angular/*@8.2.14+@ui-router/angular-hybrid@9.0.0- Works
--prodWorks
-
@angular/*@8.2.14+@ui-router/angular-hybrid@10.0.0- Works
--prodDoes not workoptimization: trueWorksaot: trueWorksaot: truebuildOptimizer: trueWorksaot: truebuildOptimizer: trueoptimization: trueDoes not work--prodwithbuildOptimizer: falseWorks
-
@angular/*@9.0.0-4c.4+@ui-router/angular-hybrid@10.0.0- Works
--prodDoes not work--prodwithbuildOptimizer: falseWorks
-
@angular/*@9.0.0-4c.4+@ui-router/angular-hybrid@10.0.0with ivy enabled- Works
--prod, Does not work--prodwithbuildOptimizer: falseWorks
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
- fix(package): mark package as having side-effects By adding `"sideEffects": true` to the package.json we are telling ng-packagr that it should not apply the `"sideEffects": false` mark to the package... — committed to petebacondarwin/angular-hybrid by petebacondarwin 5 years ago
- fix(package): mark package as having side-effects (#385) By adding `"sideEffects": true` to the package.json we are telling ng-packagr that it should not apply the `"sideEffects": false` mark to th... — committed to ui-router/angular-hybrid by petebacondarwin 5 years ago
https://github.com/ui-router/angular-hybrid/releases/tag/10.0.1
@petebacondarwin
"sideEffectes": truein@uirouter/angular-hybrid/package.jsonng serve --prodWorks! 😃 Tried with
@angular/*@9.0.0-4c.4and@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.