gpt4 book ai didi

angular-cli - 即使我使用的是目标 esm2015,ivy 也会编译为 esm5 模块

转载 作者:行者123 更新时间:2023-12-03 13:57:27 24 4
gpt4 key购买 nike

@angular ivy 问题
描述
当我使用 ng cli 时,它将模块编译为 esm2015,我的问题是我有一个旧系统,因为 angular 2 次并且我使用 webpack,但对我来说它编译为 es5。
如何更改它以编译为 esm2015?
🔬 最小复制
我的 tsconfig.aot.json:

{
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"skipLibCheck": true,
"outDir": "build/aot",
"target": "es2015",
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"lib": [
"es2018",
"dom"
],
"paths": {
"corifeus-web-material": [
"build-modules/corifeus-web-material/index.ts"
],
"corifeus-web": [
"build-modules/corifeus-web/index.ts"
],
"corifeus-web-material/*": [
"build-modules/corifeus-web-material/*"
],
"corifeus-web/*": [
"build-modules/corifeus-web/*"
]
}
},
"include": [
"build-modules/**/*",
"src/angular/**/*",
"test/angular-webpack/**/*"
],
"exclude": [
"src-save",
"*.worker.js",
"src/angular/bundle.ts",
"test/angular-webpack/angular/bundle.ts",
"test/angular-karma",
"build/browser",
"node_modules/corifeus-web/test",
"node_modules/corifeus-web-material/test"
],
"angularCompilerOptions-save": {
"annotationsAs": "decorators",
"preserveWhitespaces": false
},
"angularCompilerOptions": {
"enableIvy": true
}
}
git clone https://github.com/patrikx3/corifeus-app-web-pages
cd corifeus-app-web-pages
npm install
grunt
输出:
Running "cory-build-aot" task

Compiling @angular/core : module as esm5

Compiling @angular/common : module as esm5

Compiling @angular/common/http : module as esm5

Compiling @angular/animations : module as esm5

Compiling @angular/animations/browser : module as esm5

Compiling @angular/animations/browser/testing : module as esm5

Compiling @angular/cdk/platform : module as esm5

Compiling @angular/cdk/coercion : module as esm5

Compiling @angular/cdk/bidi : module as esm5

Compiling @angular/cdk/collections : module as esm5

Compiling @angular/cdk/scrolling : module as esm5

Compiling @angular/cdk/drag-drop : module as esm5

Compiling @angular/common/http/testing : module as esm5

Compiling @angular/cdk/keycodes : module as esm5

Compiling @angular/cdk/observers : module as esm5

Compiling @angular/cdk/a11y : module as esm5

Compiling @angular/platform-browser : module as esm5

Compiling @angular/cdk : module as esm5

Compiling @angular/platform-browser/animations : module as esm5

Compiling @angular/material/core : module as esm5

Compiling @angular/cdk/portal : module as esm5

Compiling @angular/cdk/overlay : module as esm5

Compiling @angular/forms : module as esm5

Compiling @angular/material/form-field : module as esm5

Compiling @angular/material/autocomplete : module as esm5

Compiling @angular/material/badge : module as esm5

Compiling @angular/cdk/layout : module as esm5

Compiling @angular/material/bottom-sheet : module as esm5

Compiling @angular/material/button : module as esm5

Compiling @angular/material/button-toggle : module as esm5

Compiling @angular/material/card : module as esm5

Compiling @angular/material/checkbox : module as esm5

Compiling @angular/material/chips : module as esm5

Compiling @angular/material/dialog : module as esm5

Compiling @angular/cdk/text-field : module as esm5

Compiling @angular/material/input : module as esm5

Compiling @angular/material/datepicker : module as esm5

Compiling @angular/material/divider : module as esm5

Compiling @angular/cdk/accordion : module as esm5

Compiling @angular/material/expansion : module as esm5

Compiling @angular/material/grid-list : module as esm5

Compiling @angular/material/icon : module as esm5

Compiling @angular/material/list : module as esm5

Compiling @angular/material/menu : module as esm5

Compiling @angular/material/select : module as esm5

Compiling @angular/material/tooltip : module as esm5

Compiling @angular/material/paginator : module as esm5

Compiling @angular/material/progress-bar : module as esm5

Compiling @angular/material/progress-spinner : module as esm5

Compiling @angular/material/radio : module as esm5

Compiling @angular/material/sidenav : module as esm5

Compiling @angular/material/slide-toggle : module as esm5

Compiling @angular/material/slider : module as esm5

Compiling @angular/material/snack-bar : module as esm5

Compiling @angular/material/sort : module as esm5

Compiling @angular/cdk/stepper : module as esm5

Compiling @angular/material/stepper : module as esm5

Compiling @angular/cdk/table : module as esm5

Compiling @angular/material/table : module as esm5

Compiling @angular/material/tabs : module as esm5

Compiling @angular/material/toolbar : module as esm5

Compiling @angular/cdk/tree : module as esm5

Compiling @angular/material/tree : module as esm5

Compiling @angular/material : module as esm5

Compiling @angular/core/testing : module as esm5

Compiling @angular/platform-browser-dynamic : module as esm5

Compiling @angular/platform-browser/testing : module as esm5

Compiling @angular/compiler/testing : module as esm5

Compiling @angular/platform-browser-dynamic/testing : module as esm5

Compiling @angular/common/testing : module as esm5

Compiling @angular/router : module as esm5

Compiling @angular/router/testing : module as esm5
这是一个错误吗?我应该正在编译 esm2015 模块。

🔥 异常或错误
不是直接错误,但我的目标是 esm2015
🌍 你的环境
角度版本: 8.1.2
还有什么相关的吗?
构建错误,
我期待像:
Compiling @angular/core : es2015 as esm2015

Compiling @angular/common : es2015 as esm2015

Compiling @angular/platform-browser : es2015 as esm2015

Compiling @angular/platform-browser-dynamic : es2015 as esm2015

最佳答案

对我来说,这在升级到 后开始显示角 9 , 并添加

"postinstall": "ngcc"

package.json 中的脚本修复。

关于angular-cli - 即使我使用的是目标 esm2015,ivy 也会编译为 esm5 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57220392/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com