Description
From @tobi-or-not-tobi on April 18, 2018 12:42
Bug Report or Feature Request
- [x] bug report -> please search issues before submitting
- [ ] feature request
Area
- [ ] devkit
- [x ] schematics
Versions
Angular CLI: 6.0.0-rc.5
Repro steps
ng new myapp
cd myapp
ng g library mylib
import library module into main AppModule:
import { MylibModule } from 'mylib';
I'm exited by the new generation of libraries in the CLI. But I didn't got it to work initially. While the creation of build of the library seems to be taken care of, the integration into the main app seems to be missing. I believe this is caused by an incorrect reference in the path setup in the tsconfig.json, as it is configured with the following after creation of the library:
"paths": {
"mylib": ["dist/mylib"]
}
This requires an initial build to have a generated dist/mylib folder in the first place, but would also require to continuously rebuild the library upon changes.
After I change the path to the src folder:
"mylib": ["projects/mylib/src/public_api"]
I'm able to include the module without building, but also have a seamless experience upon any changes in my library component.
I know the public_api has been originated from the ng-packagr, but i'm wondering if we shouldn't change this into an ordinary index.ts, as it would make the import easier. in addition, if that file could live at the root of our generated library, the import could be shorten to "mylib": ["projects/mylib"]
Desired functionality
- Change the path reference to the source rather the generated build files
- (optional) simplify reference of the library by changing the public_api.ts into index.ts and move it to the root directory.
Mention any other details that might be useful
I've already logged this issue under the cli project, but after a second thought I assume it belongs to this issue tracker.
Copied from original issue: angular/devkit#730