Repository navigation
Closed
Labels
area: compilerIssues related to `ngc`, Angular's template compilerarea: routerfreq2: mediumtype: bug/fix
Milestone
Description
I'm submitting a ...
[ ] Regression (behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
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
Current behavior
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 {}AOT compilation with the error:
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
Expected behavior
Successful AOT compilation
Reacted by Krishnan Mk, Amin Pakseresht, Michal Filip, Juan C Gonzalez, Ivan Radev, Colten Krauter and Michael Spyratos
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerarea: routerfreq2: mediumtype: bug/fix
Activity
krishnanmk commentedon Jul 1, 2017
@andreasrueedlinger , I think the issues we posted earlier in angular-cli are similar (6782 and 6784). Essentially, we are using two variables to finally prepare our routes object.
Angular peeps, here is another dead-simple scenario to reproduce the issue.
If you notice, in the second scenario, the prod bundle file will not have the variable definitions in it at all.
Hope this gets resolved soon. Waiting for this to release my app on production.
krishnanmk commentedon Jul 6, 2017
Angular people, any updates?
sgehrman commentedon Jun 26, 2018
Still looking for a solution to this... Anyone?
JoostK commentedon Mar 14, 2020
Hello folks,
In ViewEngine, the AOT compiler needed to know everything about code that was referenced from Angular decorators. Now with Ivy, this is no longer the case; when the compiler doesn't need to know about some metadata in a decorator, it simply includes the user's code in the compilation output without the need to statically interpret it. Note that there are still places where the compiler does need to statically interpret data, so some constraints still apply.
Because of this change, this issue is no longer a problem with Ivy.
krishnanmk commentedon Mar 15, 2020
For people who have not moved to Angular 9/Ivy, I think the following hack might just work. Whatever your variable/object/function is, try export it. It worked for me in one case. Hope it does for you guys too.
angular-automatic-lock-bot commentedon Apr 15, 2020
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.