Aot Compile issue with grid localization

Hello,

we are using currently "@syncfusion/ej2-ng-grids": "16.1.28".

We implemented in our project the fallowing files:
import * as n1 from './localization/cldr-data/de/currencies.json';
import * as n2 from './localization/cldr-data/de/timeZoneNames.json';
import * as n3 from './localization/cldr-data/de/numbers.json';
import * as n4 from './localization/cldr-data/de/numberingSystems.json';
import * as n5 from './localization/cldr-data/de/currencyData.json';
import * as n6 from './localization/cldr-data/de/ca-gregorian.json';

Link to the documentation about localization which we used:
https://ej2.syncfusion.com/16.1.32/angular/documentation/grid/globalization-and-localization.html

Everything works in debug mode.
Unfortunately we receive this exception if we are trying to aot compile our project.
npm : client/app/app.module.ts(51,21): error TS2307: Cannot find module './localization/cldr-data/de/currencies.json'.
At line:1 char:1
+ npm run ngc
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (client/app/app....rrencies.json'.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

client/app/app.module.ts(52,22): error TS2307: Cannot find module './localization/cldr-data/de/timeZoneNames.json'.
client/app/app.module.ts(53,22): error TS2307: Cannot find module './localization/cldr-data/de/numbers.json'.
client/app/app.module.ts(54,22): error TS2307: Cannot find module './localization/cldr-data/de/numberingSystems.json'.
client/app/app.module.ts(55,22): error TS2307: Cannot find module './localization/cldr-data/de/currencyData.json'.
client/app/app.module.ts(56,22): error TS2307: Cannot find module './localization/cldr-data/de/currencies.json'.

We need shortly a fix or an workaround for this issue to aot compile our project.


Additonaly we have in our declarations.d.ts following code:
declare module "*.json" {
    const value: any;
    export default value;
};
Regards
LastCodeDE

3 Replies

IR Isuriya Rajan Syncfusion Team April 5, 2018 11:13 AM UTC

Hi LastCodeDE, 
 
Thanks for contacting Syncfusion support, 
 
We have checked this localization with AOT compilation. For this we suggest to load all your json files using require. Use loadCLdr method to load the culture specific  CLDR Json data. 
 
Refer the below code example: 
 
 
import { loadCldr,L10n,setCulture, setCurrencyCode } from '@syncfusion/ej2-base'; 
  declare var require: any; 
  loadCldr( 
        require('cldr-data/main/de/numbers.json'), 
        require('cldr-data/main/de/currencies.json'), 
        require('cldr-data/supplemental/numberingSystems.json'), 
        require('cldr-data/supplemental/currencyData.json') 
    ); 
 

Regards, 
Isuriya R 
  



LA LastCodeDE April 13, 2018 07:34 AM UTC

Thank you for the answer.

It works with this workaround.

Unfortunately I think this workaround is a step back. I hope it will be normal fixed in the new version.


SM Saranya Murugasamy Syncfusion Team April 18, 2018 06:26 AM UTC

Hi LastCodeDE, 

We would like to let you know that, the TypeScript compilation doesn’t include the JSON files until we use the typing file for it. so we suggest you to use the declaration.d.ts for JSON typing to achieve your requirement.  

For your convenience, we have created a simple sample and the same can be download from the below link. 


Please let us know if you have any concerns. 

Regards, 
Saranya Murugasamy 


Loader.
Up arrow icon