Skip to content
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

Building a publishable library that is extending another publishable library (shared library). #5840

Closed
zwarag opened this issue May 31, 2021 · 5 comments
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@zwarag
Copy link

zwarag commented May 31, 2021

I'm having the troubles when building a publishable lib that is extending another publishable lib.
Setup:

  • dev-app (angular app)
  • lib-core (publishable lib)
  • lib-extend(publishable lib that extends lib-core)

image

I read these issues to make sure this is not a dupe: #3518 #2794 #602

Repo to reproduce: GitHub or GitHub1s

I've also first asked this question on slack to make sure it's not a trivial thing that I'm missunderstanding.

I assume I'm doing someting wrong and expecially after reading #3518 I suspect my config to be wrong. However, I cannot figure out what exactly is wrong and maybe it is a edge case that is not "correctly" handeld yet.

One more thing, the libs are written in a way to support secondary entry points. So maybe thats the root of the issue.

Current Behavior

The command nx run lib-extend:build --with-deps returns an error.

Expected Behavior

It should build the lib-extend library without erroring out.
For context, it never worked for me.

However, I have two idea of what could be the cause of the error:

  1. Wrong usage of the "paths" in tsconfig.base.json
  2. Missing dependency in {ng-}, package.json? I think I need to add lib-core as a dependency, but my tryings so far did not help.

Steps to Reproduce

I can run nx run dev-app:build and nx run lib-core:build without any problems. However, when I run nx run lib-extend:build --with-deps I get the error in section "Failure Logs":

Failure Logs

> Executing task: ng build lib-extend --with-deps --skip-nx-cache <


>  NX  Running target build for project lib-extend and 1 task(s) that it depends on.
        

———————————————————————————————————————————————

> nx run lib-core:build 
Building Angular Package

------------------------------------------------------------------------------
Building entry point '@my-org/lib-core'
------------------------------------------------------------------------------
✔ Compiling TypeScript sources through NGC
✔ Bundling to FESM2015
✔ Bundling to UMD
✔ Writing package metadata
✔ Built @my-org/lib-core

------------------------------------------------------------------------------
Building entry point '@my-org/lib-core/button'
------------------------------------------------------------------------------
✔ Compiling TypeScript sources through NGC
✔ Bundling to FESM2015
✔ Bundling to UMD
✔ Writing package metadata
✔ Built @my-org/lib-core/button

------------------------------------------------------------------------------
Building entry point '@my-org/lib-core/unordered-list'
------------------------------------------------------------------------------
✔ Compiling TypeScript sources through NGC
✔ Bundling to FESM2015
✔ Bundling to UMD
✔ Writing package metadata
✔ Built @my-org/lib-core/unordered-list

------------------------------------------------------------------------------
Built Angular Package
 - from: /home/wrskah/repos/org/libs/lib-core
 - to:   /home/wrskah/repos/org/dist/@my-org/lib-core
------------------------------------------------------------------------------

Build at: 2021-05-31T09:34:43.136Z - Time: 2766ms


> nx run lib-extend:build 
Some of the project lib-extend's dependencies have not been built yet. Please build these libraries before:
- lib-core

Try: nx run lib-extend:build --with-deps

———————————————————————————————————————————————

>  NX   ERROR  Running target "lib-extend:build" failed

  Failed tasks:
  
  - lib-extend:build

The terminal process "/usr/bin/bash '-l', '-c', '/home/wrskah/repos/org/node_modules/.bin/ng build lib-extend --with-deps --skip-nx-cache', 'ng build lib-extend --with-deps --skip-nx-cache'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Environment

➜  org git:(master) nx report

>  NX  Report complete - copy this into the issue template

  Node : 12.22.1
  OS   : linux x64
  yarn : 1.22.10
  
  nx : Not Found
  @nrwl/angular : 12.3.5
  @nrwl/cli : 12.3.5
  @nrwl/cypress : 12.3.5
  @nrwl/devkit : 12.3.5
  @nrwl/eslint-plugin-nx : 12.3.5
  @nrwl/express : Not Found
  @nrwl/jest : 12.3.5
  @nrwl/linter : 12.3.5
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 12.3.5
  @nrwl/web : Not Found
  @nrwl/workspace : 12.3.5
  @nrwl/storybook : Not Found
  @nrwl/gatsby : Not Found
  typescript : 4.2.4
zwarag pushed a commit to zwarag/nx-poc that referenced this issue Jun 1, 2021
As stated in nrwl/nx#2479 (comment)
the "outputs" property needs to be assigned in the angular.json when a default path is changed in the ng-package.json.

However I did not change the path so I think something else is wrong here.

I opened an Issue nrwl/nx#5840.
@zwarag
Copy link
Author

zwarag commented Jun 1, 2021

After further investigation I've found a solution. I suggest this should be communicated in the docs and/or it potentially could be a bug.

juristr pointed out here that if the dest path is changed inside the ng-package, then it is necessary to provide the outputs property in the angular.json file.

I cannot remember changing the dest path and had to provide outputs to make it work.


For others stumbling upon this problem:
The library lib-extend extends the lib-core library. I had to add this line to the lib-core, so that lib-extend could be build without an error.


@zwarag zwarag closed this as completed Jun 1, 2021
@zwarag zwarag reopened this Jun 1, 2021
@zwarag
Copy link
Author

zwarag commented Jun 1, 2021

For my part this issue is resolved. I'll let it open in case it is relevant for nrwl team. If you're a dev/community manager and feel like this needs no further investigation, you can close it.

And a thank you for the awesome work 👍. I really enjoy nx!

@juristr juristr added the scope: angular Issues related to Angular support in Nx label Jun 15, 2021
@leosvelperez
Copy link
Member

I cannot remember changing the dest path and had to provide outputs to make it work.

When generating a library, there was an issue where Nx was not generating the outputs property. This was resolved here and released as part of 12.3.6. Any library created before that version has this problem. That's why, even though you didn't change the dest path, you had to provide the outputs property because it wasn't even set before.

@leosvelperez
Copy link
Member

@zwarag I amended the docs and added a notice about keeping the outputs property in sync with the dest property in ng-package.json.

I'm closing this one since it has been solved and the docs have been updated with more info.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants