如何使用 angular-cli 创建 Angular2 npm 包



我想为一个项目创建一个 npm 包。我使用 angular-cli 来创建我想要打包的组件。

My tsconfig.json

{
   "compilerOptions": {
      "declaration": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es6", "dom"],
      "mapRoot": "./",
      "module": "es6",
      "moduleResolution": "node",
      "outDir": "../dist/out-tsc",
      "sourceMap": true,
      "target": "es5",
      "typeRoots": [
        "../node_modules/@types"
      ]
   } 
}

我可以用ng build生成*.d.ts

然后,有了npm link我可以将我的包测试到其他项目中,但是找不到包含我的组件的模块。

你有什么想法吗? :)

嗨,

我认为本文档会对您有所帮助。我已经成功地从我的 angular2 组件中使用 yoman 创建了 npm 包。

最新更新