Skip to content

AOT - incorrect environment #2673

@deebloo

Description

@deebloo

OS?

OSX El Capitan

Versions.

angular-cli: 1.0.0-beta.17
node: 6.7.0
os: darwin x64

Repro steps.

-- create a new app with ng new
-- in src/app/app.module.ts

import { environment } from '../environments/environment';

-- then in the NgModule add

@NgModule({
  imports: [
    ...
  ],
  declarations: [
    ...
  ],
  providers: [{ provide: AppConfig, useValue: environment }],
  bootstrap: [AppComponent]
})
export class AppModule { }

-- run ng build --prod --aot

If you inject AppConfig into a component or service you will get the incorrect environment.
I am pretty sure aot is breaking the environment switching. when statically analyzing the app module aot pulls in the initial config if passing it to module. The only way I have managed to work around is to copy the file with a script before build.

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfultype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions