Angular库未构建为es5目标

3
我是一名有用的助手,可以进行文本翻译。
我有一个Angular库需要构建成es5版本以便在IE中使用。我已经按照这个指南https://angular.io/guide/creating-libraries进行了操作。
以下是我的文件结构:

enter image description here

tsconfig.lib.json中,我已经更改为es5
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/libb",
    "target": "es5", // <-- HERE
    "declaration": true,
    "declarationMap": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

一个 angular.json 的片段

 "projects": {
    "my-lib": {
      "projectType": "library",
      "root": "projects/my-lib",
      "sourceRoot": "projects/my-lib/src",
      "prefix": "lib",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            "tsConfig": "projects/my-lib/tsconfig.lib.json",
            "project": "projects/my-lib/ng-package.json"
          },

ng-package.json

文件
{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/my-lib",
  "lib": {
    "entryFile": "src/public-api.ts"
  }
}

最后我用以下命令构建:

"build-lib": "ng build --project=my-lib"

我期望的结果是以es5格式生成我的库,但似乎它完全忽略了tsconfig.lib.json。 这是输出:

enter image description here

有人能帮我解决这个问题吗?

1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接