使用ng-packagr构建离子组件库

时间:2018-07-16 13:04:54

标签: ionic-framework ionic3 angular-cli ng-packagr

我非常需要为组织的Ionic资产构建一个monorepo。我们制作了一套应用程序,并希望尽可能多地共享,以缩短产品上市时间。我一周前发现了ng-packagr,并认为它比我以前使用的方法要好得多。

无论如何,我正在开发概念证明,并且无法编译ionic-angular库。 ngc中断了,我不确定该如何解决。

首先,让我分享我的package.json,看看我是否在正确的轨道上:

{
  "name": "ionic-packagr-test",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": false,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "packagr": "ng-packagr -p ng-package.json"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/core": "4.9.1",
    "@ionic-native/splash-screen": "4.9.1",
    "@ionic-native/status-bar": "4.9.1",
    "@ionic/storage": "^2.1.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "^5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.6.8",
    "@angular/cli": "^6.0.8",
    "@angular/compiler-cli": "^5.2.11",
    "@angular/language-service": "^6.0.7",
    "@ionic/app-scripts": "3.1.10",
    "@types/node": "^10.5.2",
    "ng-packagr": "^3.0.3",
    "ts-node": "^7.0.0",
    "tslint": "^5.10.0",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project"
}

我正在尝试构建一个非常漂亮的原始组件,仅使用Shell Ionic空白模板并在app.module.ts文件中导出public_api.ts

运行打包程序时,出现以下错误:

BUILD ERROR
node_modules/ionic-angular/components/picker/picker-component.d.ts.PickerCmp.html(13,71): : Expected 0 arguments, but got 1.
node_modules/ionic-angular/components/input/input.d.ts.TextInput.html(1,928): : Expected 0 arguments, but got 1.
node_modules/ionic-angular/components/input/input.d.ts.TextInput.html(1,961): : Expected 0 arguments, but got 1.

Error: node_modules/ionic-angular/components/picker/picker-component.d.ts.PickerCmp.html(13,71): : Expected 0 arguments, but got 1.
node_modules/ionic-angular/components/input/input.d.ts.TextInput.html(1,928): : Expected 0 arguments, but got 1.
node_modules/ionic-angular/components/input/input.d.ts.TextInput.html(1,961): : Expected 0 arguments, but got 1.

我可能使用的是错误的ng-packagr版本吗?

谢谢。

1 个答案:

答案 0 :(得分:1)

Found a tutorial after days of looking。不会复制/粘贴文章-不想to窃或抑制来自其网站的访问量。

基本上,所有dependencies都应成为devDependencies。如果您的软件包使用任何devDependencies 复制,则将其作为peerDependencies