angular 库 - 导入 @clr/angular 导致意外值 'undefined' 错误

angular library - importing @clr/angular causes a Unexpected value 'undefined' error

我想在 VMware 的清晰框架上构建一个 angular 库项目,其中包含一些自定义组件。

运行 ng build --prod draft 应该生成库输出。

相反,我得到:

BUILD ERROR : Unexpected value 'undefined' exported by the module 'ClrFormsNextModule in draft/node_modules/@clr/angular/clr-angular.d.ts'

Error: : Unexpected value 'undefined' exported by the module 'ClrFormsNextModule in draft/node_modules/@clr/angular/clr-angular.d.ts'

at Object.<anonymous> (draft/node_modules/ng-packagr/lib/ngc/compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at draft/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (draft/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
at Object.compileSourceFiles (draft/node_modules/ng-packagr/lib/ngc/compile-source-files.js:19:12)
at Object.<anonymous> (draft/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:26:32)
at Generator.next (<anonymous>)
at draft/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
at new Promise (<anonymous>)

这里是库项目的package.json文件

{
  "name": "draft",
  "version": "0.0.1",
  "peerDependencies": {
    "@angular/common": "^6.0.0-rc.0 || ^6.0.0",
    "@angular/core": "^6.0.0-rc.0 || ^6.0.0",
    "@clr/angular": "^0.12.0",
    "@clr/icons": "^0.12.0",
    "@clr/ui": "^0.12.0",
    "moment": "^2.22.2",
    "rxjs": "^6.0.0",
    "rxjs-compat": "^6.2.2",
    "@webcomponents/custom-elements": "^1.2.0",
    "lodash": "^4.17.10",
    "object-fit-images": "^3.2.3"
  }
}

里面root/projects/draft/tsconfig.lib.json

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": [],
    "lib": [
      "dom",
      "es2015",
      "es2017.object"
    ],
    "paths": {
      "@angular/*": [
        "../node_modules/@angular/*"
      ],
      "@clr/*":[
        "../node_modules/@clr/*"
      ]
    }
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "flatModuleId": "AUTOGENERATED",
    "flatModuleOutFile": "AUTOGENERATED"
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

里面root/projects/draft/src/draft.module

import { ClarityModule } from '@clr/angular';

环境详细信息

版本 0.12.3 有一个与 AoT 相关的错误,因此如果您没有更新到最新版本,您将在尝试构建时看到类似的未定义错误。这是 的副本,这是同样的问题。