1

我使用 ng-packagr 创建了一个 3rd 方组件库。我们已经参考了这篇文章来创建库。

https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e

我们可以在宿主应用程序中导入和渲染组件。但是我们无法在宿主应用程序中调用该库的任何函数。它抛出以下错误 -

//node_modules/xxx.component.d.ts 在 TypeScript 编译中丢失。请通过 'files' 或 'include' 属性确保它在您的 tsconfig 中。

丢失的文件似乎是第三方库的一部分。已发布库中的 TS 文件通常是库打包不良的标志。请在库存储库中打开一个问题以提醒其作者并要求他们使用 Angular 包格式打包库。

有什么方法可以使用 ng-packagr 实现相同的效果吗?

从“库”导入 {sampleComp};

@ViewChild(sampleComp) comp:sampleComp; comp.callFunction();

4

0 回答 0