Skip to content

AOT compilation fails with empty route path from static routes class #6782

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

Closed
andreasrueedlinger opened this issue Jun 23, 2017 · 8 comments
Closed
Labels
effort2: medium (days) feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@andreasrueedlinger
Copy link

andreasrueedlinger commented Jun 23, 2017

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.1.3
node: 6.9.1
os: darwin x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/flex-layout: 2.0.0-beta.8
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/material: 2.0.0-beta.6
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.3
@angular/compiler-cli: 4.2.4

Repro steps.

We have a routes class which holds all the static routes strings to be used in routes configuration of angular and in all the router links:

export class RoutesPathRegistry {
  static foo = '';
  static bar = 'link'; 
}

Using this link in the routes setup breaks the AOT compilation with angular CLI:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { RoutesPathRegistry } from 'app/modules/routes';
import { FooComponent } from './components/foo.component';
import { BarComponent } from './components/bar.component';

const appRoutes: Routes = [
  {
    path: RoutesPathRegistry.bar,
    component: BarComponent
  },
  {
    path: RoutesPathRegistry.foo,
    component: FooComponent,
    pathMatch: 'full'
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes)
  ],
  exports: [
    RouterModule
  ]
})
export class AppRoutingModule {}

The log given by the failure.

ERROR in Illegal state: symbol without members expected, but got {"filePath":"****/src/app/modules/routes/path-registry.ts","name":"RoutesPathRegistry","members":["foo"]}.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '****/src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

Desired functionality.

Successful AOT compilation

@filipesilva filipesilva added P5 The team acknowledges the request but does not plan to address it, it remains open for discussion feature Issue that requests a new feature effort2: medium (days) package4: @angular-sdk/webpack labels Jun 26, 2017
@filipesilva
Copy link
Contributor

This isn't something we support currently, but might in the future.

@andreasrueedlinger
Copy link
Author

@filipesilva please note that it is not the indirection that is the problem but the empty string. All the other indirect routes paths (like bar in the example above) do not cause any problem and work as expected. Hence I don't see the link to #6784

@krishnanmk
Copy link

krishnanmk commented Jun 27, 2017

Thanks @filipesilva . Can you please suggest me an alternative to pull this off?

I have seen some articles on adding routes dynamically and replacing them using router.resetConfig(). It seems to work, for top-level routes (app-routing.module level), but can't find a way to do this for child routes, i.e. routes in a child module, esp. lazy loaded ones.

Any tip would be of great help.! (This is in reference to #6784.)

@filipesilva
Copy link
Contributor

@andreasbhansen you're right, I think I misread these two issues. Given that other routes work, this might be a problem with ngc itself. Could you open an issue in https://github.com/angular/angular instead please?

@kichnan I'll reopen and answer your issue there.

@andreasrueedlinger
Copy link
Author

@filipesilva thanks, since I did not know where the problem was I opened an issue in both places. Here is the corrsponding issue:
angular/angular#17728

@andreasbhansen
Copy link
Contributor

I think you tagged the wrong Andreas, @filipesilva :)

@filipesilva
Copy link
Contributor

@andreasrueedlinger my bad, sorry about that :E

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort2: medium (days) feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

5 participants