我在一个升级到angular 9的angular项目中使用Syncfusion "17.4.51“时遇到了问题。如果我在优化设置为true的情况下构建,我会得到以下奇怪的错误:
ng serve -c=dev
****************************************************************************************
This is a simple server for use in testing or debugging Angular applications locally.
It hasn't been reviewed for security issues.
DON'T USE IT FOR PRODUCTION!
****************************************************************************************
chunk {} runtime.js, runtime.js.map (runtime) 1.49 kB [entry] [rendered]
chunk {1} main.js, main.js.map (main) 452 bytes [initial] [rendered]
chunk {2} polyfills.js, polyfills.js.map (polyfills) 168 bytes [initial] [rendered]
chunk {3} styles.js, styles.js.map (styles) 3.61 MB [initial] [rendered]
chunk {4} vendor.js, vendor.js.map (vendor) 146 kB [initial] [rendered]
Date: 2020-03-06T11:05:12.264Z - Hash: 7ef4d1671de0c1866c3f - Time: 13120ms
ERROR in Cannot read property 'trim' of undefined
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **这是我的angular.json的一段摘录
"qa": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.qa.ts"
}
]
},如果我关闭优化,它就可以工作,但我不确定这是否是我想要的,因为它曾经在angular 8上构建得很好。我最初认为这是因为我提前编译了,但似乎不是这样。
有没有人知道我错过了什么,或者syncfusion只是不能与优化一起工作?
这也是我的package.json:
{
"name": "angular-template",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
},
"private": true,
"dependencies": {
"@agm/core": "^1.1.0",
"@angular/animations": "^9.0.5",
"@angular/cdk": "^9.0.1",
"@angular/common": "9.0.5",
"@angular/compiler": "^9.0.5",
"@angular/core": "9.0.5",
"@angular/flex-layout": "^9.0.0-beta.29",
"@angular/forms": "^9.0.5",
"@angular/localize": "^9.0.5",
"@angular/material": "^9.0.1",
"@angular/platform-browser": "^9.0.5",
"@angular/platform-browser-dynamic": "^9.0.5",
"@angular/router": "^9.0.5",
"@ng-bootstrap/ng-bootstrap": "^5.1.5",
"@ngtools/webpack": "^1.2.4",
"@syncfusion/ej2-angular-base": "^17.4.51",
"@syncfusion/ej2-angular-buttons": "^17.4.51",
"@syncfusion/ej2-angular-grids": "^17.4.51",
"@syncfusion/ej2-angular-pivotview": "17.4.51",
"@types/file-saver": "2.0.1",
"@types/lodash": "^4.14.149",
"angular-calendar": "^0.28.2",
"bootstrap": "^3.4.1",
"classlist.js": "^1.1.20150312",
"core-js": "^3.6.4",
"date-fns": "^2.9.0",
"file-saver": "^2.0.2",
"google-maps": "^4.2.3",
"intl": "^1.2.5",
"lodash": "^4.17.15",
"mdn-polyfills": "^5.19.0",
"ng-multiselect-dropdown": "^0.2.10",
"ng2-ckeditor": "^1.2.6",
"ng2-dragula": "^2.1.1",
"ng4-click-outside": "^1.0.1",
"ngx-bootstrap": "^5.3.2",
"raven-js": "^3.27.2",
"rxjs": "^6.5.4",
"rxjs-compat": "^6.5.4",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.5",
"@angular/cli": "^9.0.5",
"@angular/compiler-cli": "^9.0.5",
"@types/googlemaps": "^3.39.2",
"@types/jasmine": "^3.5.0",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "~3.1.0",
"karma-jasmine-html-reporter": "^1.5.1",
"protractor": "~5.4.2",
"ts-node": "~8.6.2",
"tslint": "~5.20.1",
"typescript": "~3.7.5"
}
}另外,请让我知道我是否应该提供任何额外的信息?
发布于 2020-06-20 23:11:23
因此,事实证明,我们的HTML/CSS中有专门针对IE的黑客攻击,当我们删除它们时,这个问题就消失了。
遗憾的是,我不能确切地说这为什么会导致问题,但为了找到一些解决方案,这里有一个这样的黑客的例子:
<!--[if !IE]>
.text-icon > :nth-child(1n) {
flex: 1 1 0;
}
<![endif]-->我们在我们的代码库中删除了这些代码,这个问题就消失了。
这似乎不是Syncfusion特定的问题,而是与从Angular 8升级到Angular 9有关,因为即使在repo中根本没有Syncfusion,这个问题也是相同的。
发布于 2020-03-08 23:36:17
我相信你tsconfig.json中的目标应该是"target": "es2015"。
发布于 2020-03-17 21:26:07
已验证您报告的问题,并且无法通过将优化设置为true (默认情况下,优化为true )来重现该问题。在angular 8中准备了Angular示例,然后使用“ng update @ angular /cli @angular/-force-allow-dirty-force”命令将angular版本更新到最新版本(9.0.6)。
在提供样品时没有遇到您提到的任何类型的问题。附上了示例here.
https://stackoverflow.com/questions/60563172
复制相似问题