我正在尝试为一个工作项目发布Angular 6+组件库,并且遇到了一个可疑问题,看起来像是编译器错误。
这是源代码存储库,但是我在下面也包含了演示问题的代码。
https://github.com/bradkovach/porcelain/tree/master/projects/porcelain/src
该项目是使用ng generate library
生成的,理论上现在可以推送到npm了。每当我运行ng build porcelain
时,项目都不会生成错误,但是编译后的结果缺少两个组件SimpleRefinerComponent
和DateRefinerComponent
的类型定义。我发现以下StackOverflow article似乎也遇到了同样的问题,但上述解决方案对我不起作用。
我已使用这些命令在单独的计算机上构建了项目...
git clone git@github.com:bradkovach/porcelain.git
npm install
ng build porcelain
这是public_api.ts
上的projects/porcelain/src/public_api.ts
文件的样子……
/**
* Porcelain exposed components.
*/
export { PorcelainModule } from './lib/porcelain.module';
export { PorcelainComponent } from './lib/porcelain.component';
export { SimpleRefinerModule } from './lib/simple-refiner/simple-refiner.module';
export { SimpleRefinerComponent } from './lib/simple-refiner/simple-refiner.component';
export { DateRefinerModule } from './lib/date-refiner/date-refiner.module';
export { DateRefinerComponent } from './lib/date-refiner/date-refiner.component';
export { RefinersModule } from './lib/refiners/refiners.module';
export { RefinersComponent } from './lib/refiners/refiners.component';
export * from './lib/refiners/IOption';
export * from './lib/refiners/IOptions';
export * from './lib/refiners/IRefiner';
export * from './lib/refiners/IRefinerValue'
当我运行ng build
时,它将构建以下public_api.d.ts文件...
/**
* Porcelain exposed components.
*/
export { PorcelainModule } from './lib/porcelain.module';
export { PorcelainComponent } from './lib/porcelain.component';
export { SimpleRefinerModule } from './lib/simple-refiner/simple-refiner.module';
export { SimpleRefinerComponent } from './lib/simple-refiner/simple-refiner.component';
export { DateRefinerModule } from './lib/date-refiner/date-refiner.module';
export { DateRefinerComponent } from './lib/date-refiner/date-refiner.component';
export { RefinersModule } from './lib/refiners/refiners.module';
export { RefinersComponent } from './lib/refiners/refiners.component';
export * from './lib/refiners/IOption';
export * from './lib/refiners/IOptions';
export * from './lib/refiners/IRefiner';
export * from './lib/refiners/IRefinerValue';
SimpleRefinerComponent
和DateRefinerComponent
导出分别报告以下错误
Cannot find module './lib/simple-refiner/simple-refiner.component'.ts(2307)
Cannot find module './lib/date-refiner/date-refiner.component'.ts(2307)
我尝试过
node_modules
@angular/*@^6.0.0
和最新的@angular-devkit/*
软件包。