-
Notifications
You must be signed in to change notification settings - Fork 12k
Commonjs warning with @angular/common/locales #18019
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
Comments
Transferring to the CLI repo as this is a warning from the tooling, not the framework. |
So the problem is that the locale files are indeed AMD format. This is legacy because previously there were some setups that couldn't cope with ESM module format. The CLI now actually prefers the ESM format but there might still be non-CLI setups that need the AMD format. I think there are two "fixes" here:
|
Hi all, Importing the locale data and registering it is redundant when using the Angular CLI. This, is because the locale data is auto imported and inlined at a later stage in the build pipeline during localization phase where it will not effect tree-shaking and other optimizations. Before import { BrowserModule } from '@angular/platform-browser';
import { registerLocaleData } from '@angular/common';
import {LOCALE_ID, NgModule} from '@angular/core';
import '@progress/kendo-angular-intl/locales/fr/all';
import localFr from '@angular/common/locales/fr';
import { AppComponent } from './app.component';
registerLocaleData(localFr);
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [{ provide: LOCALE_ID, useValue: 'fr' }],
bootstrap: [AppComponent]
})
export class AppModule { } After import { BrowserModule } from '@angular/platform-browser';
import { registerLocaleData } from '@angular/common';
import {LOCALE_ID, NgModule} from '@angular/core';
import '@progress/kendo-angular-intl/locales/fr/all';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
bootstrap: [AppComponent]
})
export class AppModule { } I agree with @petebacondarwin that we should look into provided ESM formats for locales, but that's another discussion. |
@alan-agius4 UPDATE: everything is OK, because the Angular CLI automatically includes the locale data and sets the LOCALE_ID value when you use the --localize option with ng build. (https://angular.io/guide/i18n#set-the-source-locale-manually) |
Works for me. Before (with warning)
After (without warning)
|
I get the same warning
|
I've changed the imports to the global ones, but for the import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/global/de';
import localeEn from '@angular/common/locales/global/en-GB';
import localeDeExtra from '@angular/common/locales/extra/de';
import localeEnExtra from '@angular/common/locales/extra/en-GB';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
registerLocaleData(localeDe, 'de-DE', localeDeExtra);
registerLocaleData(localeEn, 'en-GB', localeEnExtra);
@NgModule({
declarations: [ AppComponent ],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule
],
bootstrap: [AppComponent]
})
export class AppModule { } |
@JohnnyDevNull - be aware that the global locale files actually include the extra ones already! |
I tried to import from the global folder (import localeDe from '@angular/common/locales/global/de';). Since that only contains js files (no .d.ts) I get the error "Could not find a declaration file for module '@angular/common/locales/global/de'". Since it seems to be working for others though, what am I doing wrong? |
@frauvonweb I've added just |
@timbru31 |
We need multi-locale support. |
@timbru31, if you update to the latest patch version of the |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Uh oh!
There was an error while loading. Please reload this page.
After upgrading to Angular 10, the following warning is displayed after
ng serve
command:Repro: https://github.com/destus90/angular-v10-issues
Clone it and run
ng serve -c=fr
. It would be nice not to have that warning.The text was updated successfully, but these errors were encountered: