Skip to content

registerLocaleData in prod mode causes runtime error with angular 6.0.0-rc.4 and angular-cli 6.0.0-rc.4 #10322

@jnizet

Description

@jnizet

Versions

Angular CLI: 6.0.0-rc.4
Node: 8.11.1
OS: darwin x64
Angular: 6.0.0-rc.4
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.6
@angular-devkit/build-angular     0.5.6
@angular-devkit/build-optimizer   0.5.6
@angular-devkit/core              0.5.6
@angular-devkit/schematics        0.5.6
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.4
@schematics/angular               0.5.6
@schematics/update                0.5.6
rxjs                              6.0.0-turbo-rc.4
typescript                        2.7.2
webpack                           4.5.0

Repro steps

  • create a new project with ng new, and make sure to use angular 6.0.0-rc.4 and angular-cli 6.0.0-rc.4 (see versions above)
  • Replace app.module.ts by the following file, registering locale data:
import { BrowserModule } from '@angular/platform-browser';
import { LOCALE_ID, NgModule } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';

import { AppComponent } from './app.component';

registerLocaleData(localeFr);

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [
    { provide: LOCALE_ID, useValue: 'fr' }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • Run ng serve --prod
  • Open a browser at http://localhost:4200

You can also directly use the repro project at https://github.com/jnizet/clibug.

Observed behavior

White page, with an error in the console:

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
    at Object.zUnb (main.ef58e17b9c50a35d8c7e.js:1)
    at p (runtime.5f9d33fb31487f0fdbf1.js:1)
    at Object.3 (main.ef58e17b9c50a35d8c7e.js:1)
    at p (runtime.5f9d33fb31487f0fdbf1.js:1)
    at n (runtime.5f9d33fb31487f0fdbf1.js:1)
    at Array.e [as push] (runtime.5f9d33fb31487f0fdbf1.js:1)
    at main.ef58e17b9c50a35d8c7e.js:1

Desired behavior

The page should work fine

Mention any other details that might be useful (optional)

  • It works fine when not using --prod.
  • It works fine with version 1.7.4 of the CLI.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions