Jan*_*yne 8 uglifyjs ecmascript-6 babeljs angular-cli angular
我正在为我的项目使用Angular-CLI(ng-cli).当我输入时ng serve,应用程序运行.但是,当我输入时ng serve --prod,我收到以下错误.
ERROR in vendor.bundle.js from UglifyJs SyntaxError: Unexpected token: name (IdUtil) [./~/my-lib/dist/src/common/util.js:7,0][vendor.bundle.js:9318,6]
此外,这些SO帖子(此处和此处)建议更改tsconfig.json为目标es5.我不清楚的是它们是指tsconfig.json消费的Angular项目还是用于生成库的项目.无论如何,我的Angular项目tsconfig.json已经成为目标es5.它看起来如下.
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
Run Code Online (Sandbox Code Playgroud)
在tsconfig.json已导入的角度项目库的样子以下和没有目标es5,但es6.顺便说一句,我不能简单地将这个库中的开关从es6后面翻转到es5(我刚刚尝试过),因为我正在使用es6类Set和Map(这些类的使用是如此严重,以至于改变它们并不是微不足道的,至少可以说;如果我知道所有这些,我会选择完全避免es6功能).
{
"compilerOptions": {
"noImplicitAny": true,
"target": "es6",
"module": "commonjs",
"alwaysStrict": true,
"diagnostics": false,
"listEmittedFiles": false,
"listFiles": false,
"pretty": true,
"declaration": true
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的问题.
ng serve --prod?es5/es6我的Angular项目或导入的库的目标有问题吗?ng serve --prod.该程序是否记录在案?如果是这样,请告诉我如何做到这一点.这angular-cli.json是我理解ng-cli配置的地方.如果这个建议是真的,我不能做头或尾如何勾选babel预处理.ngserve 命令专门设计用于在开发环境中工作。
尝试运行:
ng build --prod
Run Code Online (Sandbox Code Playgroud)
如果您使用 IE 测试您的应用程序:
运行命令
npm install -dev angular2-ie9-shims
Run Code Online (Sandbox Code Playgroud)
并且您必须在 angular-cli.json 中添加
"scripts": [
"../node_modules/angular2-ie9-shims/shims_for_IE@2.1.2.js",
"../node_modules/angular2-ie9-shims/shims_for_IE@2.0.0-beta.17.js",
"../node_modules/angular2-ie9-shims/shims_for_IE.dev.js"
],
Run Code Online (Sandbox Code Playgroud)
或者只是在index.html中添加
<script src="https://raw.githubusercontent.com/angular/angular/66df335998d097fa8fe46dec41f1183737332021/shims_for_IE.js" type="text/plain"></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2155 次 |
| 最近记录: |