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

Allowing imports relative to the repository when building libraries via @nrwl/angular:package #19335

Closed
2 of 4 tasks
Misterion96 opened this issue Sep 26, 2023 · 3 comments
Closed
2 of 4 tasks
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@Misterion96
Copy link

Current Behavior

I used NX team's solution to create angular libraries @nrwl/angular:package

All libraries from the repository are published after each release, but are used mainly for building applications within the repository.

The problem became known when 1 of the libraries was installed in another repository.

It turns out that the generic type resolution creates a dynamic import that leads to objects inside the repository through Explorer, rather than leaving package references as expected. Because of this, any build outside the repository is impossible, since there is no dist directory that is specified in the library build.

image

I've created a test repository that can recreate this issue (link).

It also turned out that the native builder from the angular team @angular-devkit/build-angular:ng-packagr with the paths specified in tsconfig eliminates this problem and the paths in the build remain correct.

image

Expected Behavior

When building via @nrwl/angular:package, the paths between packages are not resolved through the explorer, but remain according to the import, as in the source files

GitHub Repo

https://github.com/Misterion96/nx-imports/tree/main

Steps to Reproduce

  1. nx build shared - will create the wrong case in the dist directory
  2. nx native-build shared - will create the correct case in the dist directory

Nx Report

Node : 16.20.0
   OS   : darwin arm64
   npm  : 8.19.4
   
   nx : 14.8.8
   @nrwl/angular : 14.8.8
   @nrwl/cypress : 14.8.8
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.8.8
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.8
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.8.8
   @nrwl/js : 14.8.8
   @nrwl/linter : 14.8.8
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.8.8
   @nrwl/web : Not Found
   @nrwl/webpack : 14.8.8
   @nrwl/workspace : 14.8.8
   typescript : 4.7.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

-

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@Misterion96
Copy link
Author

@leosvelperez leosvelperez added the scope: angular Issues related to Angular support in Nx label Sep 27, 2023
@leosvelperez leosvelperez self-assigned this Sep 27, 2023
@leosvelperez
Copy link
Member

Thanks for reporting this!

This is an issue that has already been solved. Please update your Nx version to at least 15.1.1 (last version with Angular 14 if you need to stay on that Angular version) and the issue should be solved:

nx migrate 15.1.1
nx migrate --run-migrations

I tested the above in the provided repo, and the issue went away. I'm closing this since it has already been solved.

@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 Oct 28, 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

2 participants