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

Unable to build angular library that contains another library #14296

Closed
jamcoupe-ccl opened this issue Jan 12, 2023 · 2 comments
Closed

Unable to build angular library that contains another library #14296

jamcoupe-ccl opened this issue Jan 12, 2023 · 2 comments
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@jamcoupe-ccl
Copy link

Current Behavior

When trying to build an angular library that references another library it fails because it's unable to find the files.

Expected Behavior

It should be able to build a buildable angular library with other library references.

Github Repo

No response

Steps to Reproduce

  1. See: add buildable angular library issue nx-examples#256
  2. Run yarn install
  3. Run nx run buildable-angular-library:build

Nx Report

$ nx report

 >  NX   Report complete - copy this into the issue template

   Node : 18.12.1
   OS   : win32 x64
   yarn : 1.22.19

   nx : 15.4.0-rc.2
   @nrwl/angular : 15.4.0-rc.2
   @nrwl/cypress : 15.4.0-rc.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.0-rc.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.0-rc.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.0-rc.2
   @nrwl/js : 15.4.0-rc.2
   @nrwl/linter : 15.4.0-rc.2
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.4.0-rc.2
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.4.0-rc.2
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.4.0-rc.2
   @nrwl/webpack : 15.4.0-rc.2
   @nrwl/workspace : 15.4.0-rc.2
   @nrwl/vite : 15.4.0-rc.2
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         @ngrx/component-store: 15.0.0
         @ngrx/effects: 15.0.0
         @ngrx/entity: 15.0.0
         @ngrx/router-store: 15.0.0
         @ngrx/store: 15.0.0
         @ngrx/store-devtools: 15.0.0

Failure Logs

$ nx run buildable-angular-library:build

> nx run buildable-angular-library:build:production

Building Angular Package

------------------------------------------------------------------------------
Building entry point '@nx-example/buildable-angular-library'
------------------------------------------------------------------------------

 >  NX   libs/js-library/src/lib/js-library.ts:1:1 - error TS6059: File 'C:/Projects/nx-examples/libs/js-library/src/lib/js-library.ngtypecheck.ts' is not under 'rootDir' 'C:\Projects\nx-examples\libs\buildable-angular-library\src'. 'rootDir' is expected to contain all source files.


   1 export function jsLibrary(): string {
    
   libs/js-library/src/index.ts:1:1 - error TS6059: File 'C:/Projects/nx-examples/libs/js-library/src/index.ngtypecheck.ts' is not under 'rootDir' 'C:\Projects\nx-examples\libs\buildable-angular-library\src'. 'rootDir' is expected to contain all source files.

   1 export * from './lib/js-library';
    
   libs/js-library/src/index.ts:1:15 - error TS6059: File 'C:/Projects/nx-examples/libs/js-library/src/lib/js-library.ts' is not under 'rootDir' 'C:\Projects\nx-examples\libs\buildable-angular-library\src'. 'rootDir' is expected to contain all source files.

   1 export * from './lib/js-library';
                   ~~~~~~~~~~~~~~~~~~
   libs/buildable-angular-library/src/lib/buildable-angular-library/buildable-angular-library.component.ts:3:27 - error TS6059: File 'C:/Projects/nx-examples/libs/js-library/src/index.ts' is not under 'rootDir' 'C:\Projects\nx-examples\libs\buildable-angular-library\src'. 'rootDir' is expected to contain all source files.

   3 import { jsLibrary } from '@nx-example/js-library';
                               ~~~~~~~~~~~~~~~~~~~~~~~~

   Pass --verbose to see the stacktrace.


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

 >  NX   Ran target undefined for project buildable-angular-library (11s)

    ×    1/1 failed
    √    0/1 succeeded [0 read from cache]

   View structured, searchable error logs at https://cloud.nx.app/runs/d5F4Gj5I1G

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: angular Issues related to Angular support in Nx label Jan 12, 2023
@leosvelperez
Copy link
Member

Thanks for reporting this!

Buildable libraries can only depend on other buildable libraries. This is mentioned in the docs https://nx.dev/more-concepts/buildable-and-publishable-libraries#buildable-libraries.

So, in your example, you'll need to make the js-library project buildable (have a build target in this case).

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

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 3, 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