我正在尝试使用全球化本地化角度6 + 应用程序。
它可以在开发模式下构建并正常工作,但是不幸的是,将其构建为生产模式:“ ng build --prod ”我收到此错误:“ 无法读取属性'Symbol中的错误(Symbol.iterator)'未定义”。
本地化的源代码编写在名为“ german-language.service.ts ”的服务中。如果我注释掉“ initLagnuage ”方法的内容,则它将正确构建。
全球化并安装devextreme-cldr-data。还尝试了cldr-data。
有人和想法如何解决该问题吗?
编辑:
如果在tsconfig.json中注释掉“ resolveJsonModule:true”,则不会出现该错误。
似乎与角度错误有关:使用AOT#25456进行编译时,TypeScript resolveJsonModule功能已损坏
german-language.service.ts
import { Injectable } from '@angular/core';
import deMessages from 'devextreme/localization/messages/de.json';
import Globalize from 'globalize';
import 'devextreme/localization/globalize/number';
import 'devextreme/localization/globalize/date';
import 'devextreme/localization/globalize/currency';
import 'devextreme/localization/globalize/message';
import deCldrData from 'devextreme-cldr-data/de.json';
import supplementalCldrData from 'devextreme-cldr-data/supplemental.json';
@Injectable({
providedIn: 'root'
})
export class GermanLanguageService {
constructor() { }
initLanguage() {
Globalize.load(
deCldrData,
supplementalCldrData
);
Globalize.loadMessages(deMessages);
Globalize.locale('de');
}
}
应用程序配置如下:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types",
"src/typings.d.ts"
],
"lib": [
"es2017",
"dom"
],
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"paths": {
"globalize": [
"node_modules/globalize/dist/globalize"
],
"globalize/*": [
"node_modules/globalize/dist/globalize/*"
],
"cldr": [
"node_modules/cldrjs/dist/cldr"
],
"cldr/*": [
"node_modules/cldrjs/dist/cldr/*"
]
}
}
}
package.json
{
"name": "xxx",
"version": "x.x.x.x",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.1.9",
"@angular/common": "^6.1.9",
"@angular/compiler": "^6.1.9",
"@angular/core": "^6.1.9",
"@angular/forms": "^6.1.9",
"@angular/http": "^6.1.9",
"@angular/platform-browser": "^6.1.9",
"@angular/platform-browser-dynamic": "^6.1.9",
"@angular/router": "^6.1.9",
"@ngx-pwa/local-storage": "^6.0.0",
"@types/devextreme": "^16.2.1",
"@types/globalize": "^0.0.34",
"classlist.js": "^1.1.20150312",
"core-js": "^2.5.4",
"devextreme": "^18.1.4",
"devextreme-angular": "^18.1.4",
"devextreme-cldr-data": "^1.0.1",
"file-saver": "^1.3.8",
"globalize": "^1.4.0",
"http-server": "^0.11.1",
"ngx-bootstrap": "^3.0.1",
"ngx-dropzone-wrapper": "^6.1.0",
"ngx-mask": "^6.1.2",
"rxjs": "^6.0.0",
"stream": "0.0.2",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.4",
"@angular/cli": "~6.2.4",
"@angular/compiler-cli": "^6.1.9",
"@angular/language-service": "^6.1.9",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.9.2"
}
}
app.modules.ts
...
export class AppModule {
constructor(language: GermanLanguageService) {
language.initLanguage();
}