Skip to content

Incorrect tsconfig path for libraries #10369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tobi-or-not-tobi opened this issue Apr 17, 2018 · 4 comments
Closed

Incorrect tsconfig path for libraries #10369

tobi-or-not-tobi opened this issue Apr 17, 2018 · 4 comments

Comments

@tobi-or-not-tobi
Copy link

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';

Observed behavior

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 behavior

  • 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.
@tobi-or-not-tobi tobi-or-not-tobi changed the title Incorrect tsconfig path for using embedded libraries Incorrect tsconfig path for libraries Apr 17, 2018
@nweldev
Copy link
Contributor

nweldev commented Apr 18, 2018

@tobi-or-not-tobi Doesn't this make ng-packagr embed this files in the builded library ?

Anyway, given the comment by @dherges (angular/devkit#730 (comment)), we could respond to this by adding some consistent "continuous library build" process. I'm on this right now for a project, so I may make a PR to angular-cli or devkit soon enough if I have time.

@tobi-or-not-tobi
Copy link
Author

Thanks @noelmace, let's keep the discussion in the devkit project.

@nweldev
Copy link
Contributor

nweldev commented Apr 19, 2018

In fact, I don't know what's the angular-cli politic about issues related to both angular-cli and devkit (this is the case here angular/devkit#730 (comment)). @hansl @filipesilva @Brocco, do you have an opinion about opening separated issues for devkit and angular-cli vs keeping the discussion in one project only ? Should a devkit issue considered has external ?

nweldev pushed a commit to nweldev/angular-cli that referenced this issue Apr 19, 2018
This commit is just a first example for angular#10369, following the discussion started in
angular/devkit#730.
angular/devkit#739 would be needed.
This example would also require some evolutions on @angular-devkit/architect, but I'm
sure there is a way to do this.
nweldev pushed a commit to nweldev/angular-cli that referenced this issue May 9, 2018
This commit is just a first example for angular#10369, following the discussion started in
angular/devkit#730.
angular/devkit#739 would be needed.
This example would also require some evolutions on @angular-devkit/architect, but I'm
sure there is a way to do this.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants