如何导入外部库?

时间:2019-06-03 06:16:41

标签: angular ng-packagr

我正在尝试使用 ng-packager@5.2.0 angular@7.0.0

建立一个libray

可以正常构建,但是当我尝试在其他项目中导入新库时,项目崩溃,因为某些模块尚未导入。

我试图在 umdModuleIds 中导入库,这可以修复控制台错误,但是不能正常工作。

ng-packge.json

{
    "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
    "dest": "../../dist/lib-contenedor-lista",
    "lib": {
        "entryFile": "src/public-api.ts",
        "umdModuleIds": {
            "ng-zorro-antd": "ng-zorro-antd",
            "messagepack": "messagepack",
            "ag-grid-angular": "ag-grid-angular",
            "ng2-date-picker": "ng2-date-picker",
            "util": "util",
            "moment": "moment",
            "class-transformer": "class-transformer",
            "ngx-logger": "ngx-logger",
            "numeral": "numeral",
            "ag-grid-community": "ag-grid-community",
            "node_modules/exceljs/dist/exceljs.min.js": "exceljs_min_js",
            "jspdf": "jspdf",
            "lodash": "lodash"
        },
        "whitelistedNonPeerDependencies": ["."]
    }
}

我需要导入此文件才能在其他项目中使用此库,而不会出现问题。

package.json

  "name": "lib-test",
  "version": "0.0.15",
  "peerDependencies": {
    "@angular/common": "^7.2.0",
    "@angular/core": "^7.2.0",
    "ag-grid-community": "^20.2.0",
    "exceljs": "^1.8.0",
    "jspdf": "^1.5.3",
    "ngx-logger": "^3.3.12"
  },
  "devDependencies": {
    "ng-zorro-antd": "^7.2.0"
  }
}

0 个答案:

没有答案