Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is angular-hybrid compatible with AOT? #47

Closed
JiriPelnar opened this issue Jul 18, 2017 · 6 comments
Closed

Is angular-hybrid compatible with AOT? #47

JiriPelnar opened this issue Jul 18, 2017 · 6 comments

Comments

@JiriPelnar
Copy link

In our angularjs / angular hybrid application we use ui-router and it works great when using JIT. Now I am trying to make it work with AOT and all my effort seem to fail. First I tried using rollup and rollup for some reason fails to resolve angular-hybrid package. I then tried to make the application work using webpack, and while the bundling completed successfully, the states that I define inside angular 2 modules do not seem to be registered in the stateRegistry. Am I doing something completely wrong? Should this be working? If it should be working, I will try to reproduce it using a plunker.

@mischkl
Copy link

mischkl commented Aug 1, 2017

Yes, AOT compatibility should work, if you follow all the steps listed in the README, or better yet copy the code from the example (it's more complete and up-to-date).

@JiriPelnar
Copy link
Author

JiriPelnar commented Aug 4, 2017

@mischkl thank you for your comment, I went through the README another time to check if I have left something important out. I believe I have all important parts covered, after all, the JIT version is working well.
I suspect a bug either in the angular-hybrid package or in the way rollup is resolving the package.
To make it apparent I have created a minimal example derived from the minimal example of angular-hybrid here:
https://github.com/ui-router/angular-hybrid/tree/master/example
and applying the steps to make AOT work from the offical angular guidelines page:
https://angular.io/guide/aot-compiler

This way I needed to adjust the package.json, tsconfig.json and main.ts files, and I needed to introduce app,module.ts and rollup-config.js files, all of which can be found adjusted inside this plunker:
https://plnkr.co/edit/tmViEDxH7PFaQkL0qKU7?p=info

The result of running rollup on the AOT compiled code is this error mesaage:

uirouter/angular-hybrid is imported by src\app.module.js, but could not be resolved - treating it as an external dependency

I would really appreciate any help here as this is a stopper for our application if we should rely on using ui-router.

@christopherthielen
Copy link
Member

christopherthielen commented Aug 13, 2017

@JiriPelnar can you provide instructions on how to reproduce the error message? perhaps put it in a git repo that I can clone, run yarn && ngc && rollup -c rollup-config.js or whatever the instructions should be?

If I can reproduce it in the plunker, please provide step by step instructions

@JiriPelnar
Copy link
Author

Thank you @christopherthielen for looking into this issue. The problem may be on my part, as I might still be missing something, but I am unable to figure out what that could be. However, I put together this repository with the necessary steps to reproduce the rollup error explained in detail in its readme.

Also, please note this answer from @Radim-Kohler to my question related to the same issue on stack overflow. Adjusting the rollup-config the way proposed in the answer makes the rollup step work just fine and it makes me think that maybe the structure of angular-hybrid package can be changed to work with rollup without this special configuration in rollup-config.

@christopherthielen
Copy link
Member

I just released ver 3.1.4 which should resolve this.

@JiriPelnar
Copy link
Author

JiriPelnar commented Aug 16, 2017

Thank and thank you very much for doing this amazing library. I have tested the version 3.1.4 and it indeed works for the angular-hybrid case. I believe a similar fix is also needed for uirouter/core, for which I still need to keep the custom resolver in rollup config in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants