Error: Some of the library <YOUR LIBRARY> dependencies have not been built yet. Please build these libraries before: -testing

See original GitHub issue

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": "<rootDir>../../libs/testing/src/index.ts",
  }, 

The issue might lie in these test imports. The build might be looking for “@abc/testing” at dist > @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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
maxfriedmanncommented, May 4, 2021

In my case, the @nrwl/angular:move command forgot to change the path set in libs/YOUR LIBRARY/ng-package.json. In any case someone (or my future me) stumbles over this issue again: Check the dist folder output!

8reactions
psurreycommented, Jul 3, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incremental Build Improvements, Angular 12, Distributed Task ...
As an example, let's look at an application with a dependency on a buildable library. The following workspace configuration below displays app1 ...
Read more >
Xcode 11.4 : Building for iOS Simu… | Apple Developer Forums
If this is your library, you should have your app build it from source as a dependency of your Xcode project, either through...
Read more >
Known issues with Android Studio and Android Gradle Plugin
This section describes known issues that exist in the latest stable version of the Android Gradle plugin. Not all dynamic-feature library dependencies are...
Read more >
The Java Library Plugin - Gradle User Manual
This is where you declare dependencies which are required at compile time by your module and consumers, but not at runtime. This typically...
Read more >
Getting Started with the LLVM System
Note that it is tempting to install a prior version of Clang and libc++ to be the host compiler, however libc++ was not...
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