Skip to content

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

Closed

Description

@andreasrueedlinger

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

Activity

  1. added
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    featureLabel used to distinguish feature request from other issues
    on Jun 26, 2017
  2. filipesilva commented on Jun 26, 2017

    @filipesilva
    Contributor

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

  3. andreasrueedlinger commented on Jun 26, 2017

    @andreasrueedlinger
    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

  4. krishnanmk commented on Jun 27, 2017

    @krishnanmk

    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.)

  5. filipesilva commented on Jun 28, 2017

    @filipesilva
    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.

  6. andreasrueedlinger commented on Jun 28, 2017

    @andreasrueedlinger
    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

  7. andreasbhansen commented on Jun 28, 2017

    @andreasbhansen
    Contributor

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

  8. filipesilva commented on Jun 28, 2017

    @filipesilva
    Contributor

    @andreasrueedlinger my bad, sorry about that :E

  9. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  10. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussioneffort2: medium (days)featureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions