We are getting this error:
Error: Some of the library "my-library" dependencies have not been built yet. Please build these libraries before: -testing
We have just upgraded to Angular 8 and are having an issue with our build.
We have two libraries generated by the Nrwl schematics (in Angular 7) within the same project. They are "my-library" and "testing".
"testing" is a library that contains nothing but stubs for Angular components that exist in "my-library". We build this library separate and place the build files in "my-library's" distribution folder. This is so we can have the following pattern in our other applications.
```
import { myComponent } from "@abc/my-library" // for components
import { myComponentStub } from "@abc/my-library/testing" // for testing
Our dist folder structure looks like this.
dist >
@abc >
my-library >
testing > // testing directory
package.json
.....
We never had an issue with this error until we upgraded to angular 8 using Nx and tried to build.
**The error shows up when we do `ng build my-library`.**
"Testing" is not a dependency used by "my-library" directly. But, the **spec** files within the library do.
They reference the stubs like so:
`Import { myComponentStub } from @abc/testing` mapped through the jest.config.
jest.config.js
...
moduleNameMapper:ย {
"@abc/testing": "
},
``
The issue might lie in these test imports. The build might be looking for "@abc/testing" atdist > @abc > testing`.
Prior versions of Angular "ng build" didn't care about the spec file and their dependencies. Seeing this error is something only found in the Nx repo during a google search (angular-package.test.ts). I thought I would ask you.
Any idea how to resolve this?
Hi, sorry about this.
This was mislabeled as stale. We are testing ways to mark _not reproducible_ issues as stale so that we can focus on actionable items but our initial experiment was too broad and unintentionally labeled this issue as stale.
@FrozenPandaz I think I got a repo where this same error appears.
When adding the code in this pr my build also fails, without it it builds perfectly.
It might be something that I'm doing wrong in one of the libraries but I can't seem to spot it.
I've got the same issue. When running nx run shared-core-ui:build --with-deps Nx correctly detects that there is another lib to be built before (> NX Running target build for project shared-core-ui and its 1 deps.) and it starts even building this lib:
> ng run shared-utils:build
Building Angular Package
After this one is successfully built, the build of the shared-core-ui lib fails:
Built shared-utils
------------------------------------------------------------------------------
Built Angular Package
- from: libs/shared/utils
- to: component-lib/shared-utils
------------------------------------------------------------------------------
> ng run shared-core-ui:build
Some of the project shared-core-ui's dependencies have not been built yet. Please build these libraries before:
- shared-utils
Try: nx run shared-core-ui:build --with-deps
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
> NX ERROR Running target "build" failed
Failed projects:
- shared-core-ui
Seems like the issue is that the compiled output of the first library isn't found again when building the second library. How does Nx know where to find the compiled versions of libraries? Somewhere there has to be a mapping!? ๐ค
Would be great if the error message would include the path where Nx is looking for the compiled library for easier debugging. ๐
After digging around through the code I was able to fix it! ๐
I found out that you can define the path for the "outputs" like this:
"architect": {
"build": {
"builder": "@nrwl/angular:package",
"outputs": ["component-lib/shared-utils"],
"options": {
"tsConfig": "libs/shared/utils/tsconfig.lib.json",
"project": "libs/shared/utils/ng-package.json"
}
}
}
Without this Nx has defaulted to dist/libs/shared/utils - see: https://github.com/nrwl/nx/blob/master/packages/workspace/src/tasks-runner/utils.ts#L73
Folks,
Our guide on buildable libraries doesn't cover this in depth (https://nx.dev/angular/guides/ci/incremental-builds#incremental-builds), and it probably should.
Does it make sense?
Closing this issue
Most helpful comment
After digging around through the code I was able to fix it! ๐
I found out that you can define the path for the "outputs" like this:
Without this Nx has defaulted to
dist/libs/shared/utils- see: https://github.com/nrwl/nx/blob/master/packages/workspace/src/tasks-runner/utils.ts#L73