ui-router / angular

UI-Router for Angular: State-based routing for Angular (v2+)
https://ui-router.github.io/ng2/
MIT License
354 stars 135 forks source link

ng4: cannot resolve `@angular/router/src/router_config_loader` #65

Closed marshall007 closed 7 years ago

marshall007 commented 7 years ago

Using angular v4.0.0-rc.2 (and cli v1.0.0-rc.1), it appears the deep reference to @angular/router/src/router_config_loader is broken.

https://github.com/ui-router/ng2/blob/e9705b00f90295c538dbfb568178801939ca6c1e/src/uiRouterNgModule.ts#L13

ERROR in ./~/ui-router-ng2/lib/uiRouterNgModule.js
Module not found: Error: Can't resolve '@angular/router/src/router_config_loader' in './node_modules/ui-router-ng2/lib'
 @ ./~/ui-router-ng2/lib/uiRouterNgModule.js 6:0-66
 @ ./~/ui-router-ng2/lib/index.js
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

I couldn't tell by looking at their UMD bundles if the default @angular/router exports have changed since v2.x, but import { ROUTES } from '@angular/router' appears to work. I know you guys are waiting on upstream fixes for making @ngtools/webpack router-agnostic. In the meantime is there a way we can support v4.x as well?

marshall007 commented 7 years ago

I just stumbled across @aitboudad's note about this in https://github.com/angular/angular/issues/14795#issuecomment-283073477. Reading through that thread, I can't tell what the intended resolution is on the Angular side. I have submitted https://github.com/angular/angular/issues/15119 to get clarification on the expected behavior going forward.

fulls1z3 commented 7 years ago

I had a similar issue caused by the deep import of ROUTES DI token.

The only working solution was creating two different repo branches (--ng4, --ng2) and importing the ROUTES token (on --ng4) with:

import { ROUTES } from '@angular/router';
mkoczorowski commented 7 years ago

this solution doesnt work anymore. any other ideas ?

christopherthielen commented 7 years ago

This is now resolved by https://github.com/ui-router/angular/commit/29f2d0e05e1cfddcfc4210c4222b7cc8dfe68bc8 and will be released as beta.6

ciel commented 7 years ago

Is there any way to get beta.6 at the moment? Or do we just need to download manually?

kolkov commented 7 years ago

@ciel I tryed to use this branche https://github.com/ui-router/angular/tree/angular4 This worked for me. But now I downgraded to 2.3.1 and beta.5 https://github.com/ui-router/angular/issues/58

ciel commented 7 years ago

Thanks, I'll give that a try.

kolkov commented 7 years ago

https://github.com/ui-router/angular/issues/101#issuecomment-297783417

christopherthielen commented 7 years ago

Beta.6 is released, please try it

damiensawyer commented 7 years ago

Hi @christopherthielen . Please forgive my newb question. Can I get the Beta.6 release on NPM? When I execute npm info ui-router-ng2 I'm only shown up to beta.5

If it's not via NPM, what's the best way to get it?

Thanks.

{ name: 'ui-router-ng2', description: 'State-based routing for Angular 2', 'dist-tags': { latest: '1.0.0-beta.5' }, versions: [ '0.1.0-preview.0', ..... '1.0.0-beta.4', '1.0.0-beta.5' ], maintainers: [ 'christopherthielen christopherthielen@ikkyikkyikkypikangzoopboing.com' ], time:

damiensawyer commented 7 years ago

Aah... scratch that!! .... I didn't notice this at the bottom of the npm info output.

deprecated: 'This npm package \'ui-router-ng2\' has been renamed to \'@uirouter/angular\'. Please update your package.json. See https://ui-router.github.io/blog/uirouter-scoped-packages/',

nickgrealy commented 6 years ago

latest beta.6 release is compatible with Angular 4

Note: The package ui-router-ng2 has been renamed to @uirouter/angular

This demo will likely be replaced by something involving the Angular-CLI

https://github.com/ui-router/quickstart-ng2/issues/32#issuecomment-304759155

renilbabu03 commented 6 years ago

In my case Angular Cli seemed to have imported import { ActivatedRoute } from '@angular/router/src/router_state';

Changing it to import { ActivatedRoute } from '@angular/router'; solved my problem. Don't know the reason behind it...but worked