角度库-导入@ clr / angular会导致意外的值“未定义”错误

时间:2018-08-12 16:34:09

标签: javascript angular vmware-clarity angular-library

我想在VMware的清晰度框架上使用一些自定义组件构建一个角度库项目。

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

相反,我得到:

  

BUILD ERROR:模块导出的意外值“ undefined”   'ClrFormsNextModule   draft/node_modules/@clr/angular/clr-angular.d.ts'

     

错误::模块导出的意外值'undefined'   'ClrFormsNextModule   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';

环境详细信息

  • 角度版本: 6.0.3

  • 清晰度版本: 0.12.0

  • 操作系统和版本: macOS 10.13.6

  • 浏览器: Chrome 68

1 个答案:

答案 0 :(得分:1)

版本0.12.3中存在与AoT相关的错误,因此,如果您尚未更新到最新版本,则在尝试构建时会看到类似的未定义错误。这是Uncaught TypeError: Cannot read property 'chocolate' of undefined的副本,这是同样的问题。