question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build buildable lib that depends on other buildable lib

See original GitHub issue

Current Behavior

I’m getting an error when building the lib that depends on the first lib.

File '/Users/leon/Temp/labs-buildable-libs/libs/shared/domain/src/index.ts' is not under 'rootDir' 'libs/shared/auth'. 'rootDir' is expected to contain all source files.
import { User } from '@myorg/shared/domain';

it seems that even though nx knows the correct dependency, (nx dep-graph) the builder for the lib does not take into account that the other lib is buildable.

Expected Behavior

I should be able to build each library separately so I can use nx cloud to cache my libs.

Steps to Reproduce

Here is a repo with instructions and a very simple workspace to illustrate the problem. https://github.com/leon/labs-nx-buildable-libs

The repo is very light to just illustrate the problem. in my real repo we have multiple angular apps / nest.js apis and loads of workspace:library libs. The whole point of buildable libs for us will be to pre compute a lot of these libs to get a faster build. we use a lot of shared domain models that are skattered across the libs, and they sometimes extend each other, so we need to be able to build a lib, that then references the other lib.

Environment

 Node : 14.17.2
  OS   : darwin x64
  yarn : 1.22.10
  
  nx : Not Found
  @nrwl/angular : Not Found
  @nrwl/cli : 12.5.1
  @nrwl/cypress : Not Found
  @nrwl/devkit : 12.5.1
  @nrwl/eslint-plugin-nx : 12.5.1
  @nrwl/express : Not Found
  @nrwl/jest : 12.5.1
  @nrwl/linter : 12.5.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 12.5.1
  @nrwl/web : Not Found
  @nrwl/workspace : 12.5.1
  @nrwl/storybook : Not Found
  @nrwl/gatsby : Not Found
  typescript : 4.3.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
leosvelperezcommented, Jul 23, 2021

This is now released, you can use 12.6.2 to get the first issue mentioned in the comment above resolved.

I’m closing this one. Please feel free to open another issue if you still have problems with this.

2reactions
TomTomBcommented, Jul 3, 2021

Interesting sidenote: The issue only appears, if the libs are inside subfolders.

Example lib-two depends on lib-one

This folder structure will build

libs/lib-one
libs/lib-two

And this will produce the error

libs/foo/lib-one
libs/lib-two
Read more comments on GitHub >

github_iconTop Results From Across the Web

Buildable libraries dependent upon shared libraries #8912
In Nx (v13.8.x), how can I have a buildable library that is dependent upon another shared library? Scenario: I have two libraries: React...
Read more >
Buildable and Publishable Libraries - Nx
In order for a buildable library to be pre-compiled, it can only depend on other buildable libraries. This allows you to take full...
Read more >
New buildable angular library can not be build - Stack Overflow
I have the latest version of nx (11.1.5) running in a new workspace ( --preset empty ) running and I want to add...
Read more >
nrwl-nx/community - Gitter
Since updating I'm getting an error with buildable libs cannot import non-buildable libs . I know what it means, but I do not...
Read more >
Dependency graph enhancements, ESLint plugin, buildable ...
For example, let's say you have my-parent-lib , that depends on my-child-lib , and also my-other-lib , to build my-parent-lib , you would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found