new library public-api.ts file not using component type declared on angular.json's schematics
- 主要语言
- TypeScript
- 星标
- 27k
- 派生
- 11.8k
- 平均合并
- 14 小时 23 分钟
- 30 天内合并 PR
- 162
描述
### Which @angular/* package(s) are the source of the bug?
Don't known / other
### Is this a regression?
No
### Description
When I create a new library the default component inside of the lib folder takes its type from the component schematic declared on angular.json. If for example my angular.json looks like this:
```
{
//...
"newProjectRoot": "projects",
//...
"schematics": {
"@schematics/angular:application": {
"style": "scss",
"inlineTemplate": true,
"inlineStyle": true,
"ssr": false
},
"@schematics/angular:component": {
"changeDetection": "OnPush",
"type": "Cmp",
"inlineStyle": true,
"inlineTemplate": true,
"style": "scss"
}
}
}
```
After creating a library using `ng generate library foo-library`, the new library includes an empty dummy `FooLibraryCmp` inside the `projects/foo-library/src/lib/foo-library.cmp.ts`. However, the contents of `projects/foo-library/src/public-api.ts` look like this:
```
/*
* Public API Surface of foo-library
*/
export * from './lib/foo-library.service';
export * from './lib/foo-library.component'; // uses .component instead of .cmp
```
### Please provide a link to a minimal reproduction of the bug
_No response_
### Please provide the exception or error you saw
_No response_
### Please provide the environment you discovered this bug in (run `ng version`)
```true
Angular CLI: 17.1.1
Node: 18.18.0
Package Manager: npm 9.6.6
OS: win32 x64
Angular: 17.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1701.1
@angular-devkit/build-angular 17.1.1
@angular-devkit/core 17.1.1
@angular-devkit/schematics 17.1.1
@schematics/angular 17.1.1
ng-packagr 17.1.2
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.3
```
### Anything else?
_No response_
贡献指南
调研方向
首先,在 `angular.json` 中使用 `@schematics/angular:component` 的 `type` 设置重现 `ng generate library foo-library`,然后检查生成的 `projects/foo-library/src/lib/foo-library.cmp.ts` 和 `projects/foo-library/src/public-api.ts`。当 `public-api.ts` 使用已配置的文件名后缀而不是 `.component` 导出生成的组件时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- build-system, cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100