-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Nx v.12 cannot build libs that depend on other libs #6443
Comments
I have taken a glance at your update an it is NOT working if I run the migration to the latest version. The error keeps the same. Node : 12.22.1 nx : Not Found
The error displayed on the console is the same one: The resulting environment properties now are: nx : Not Found What I realised is that if I create a new repository with the command "npx create-nx-workspace@latest" and then perform the same steps than before, the error is now happening anymore, so I think that the error here is solved for new projects but not for already existing ones that needs the migration step to get the Nx 12.6.0 version. Could you please check my case and consider reopen this issue? |
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. |
Current Behavior
When running Nx build with Nx v12 and Angular v12 the builder is not able to find assets from another libs, it is like the relative path ("import {whatever} from '@relative-path'") to foreign libs is broken. It appears a lot of different errors but the main reason is that error. Some examples of that errors are:
File 'folder/file.ts' is not under 'rootDir' 'libs/anotherLib/component 'rootDir' is expected to contain all source files.
Expected Behavior
When using the previous versions, the aforementioned error does not appear and the builder completed successfully.
Steps to Reproduce
I have built a simple repository that reproduces the same error and you can clone: https://github.com/gerardcastell/nx-monorepo-libs-deps I have created it with the 'npx create-nx-workspace@latest' command and selecting an Angular framework. After that, I added 3 libs using the command 'nx g @nrwl/angular:lib lib-name --directory=core --buildable' and on of the make it publishable to check if there is any difference but I was not able to find out any one. One lib is a ngrx store "core-data-access-store", which imports another lib "core-environments" which is a simple module that exports a file 'environments.ts' (the publishable lib works the same way that core-environments, it was just a test but is not used). So at this point we have two dependencies: Lab-app -> core-data-access-store -> core-environments. As I read on your book "enterprise-angular-mono-repo-patterns" I consider that the architecture follows your advices, if does't please feel free to explain me how I should do it, I will be very thankful!
Failure Logs
If you clone the repo and install the dependencies you may proceed to build the app or even the core-data-access-store. As it depends on the core-environment you will see that this package builds as expected but the core-data-access-store is failing and the following error appears:
This type of error is what appear on every lib that has imports in our enterprise repository.
We found a valid workaround but it is pretty nasty: https://medium.com/@thearunmalik/angular-monorepo-multiple-libs-and-rootdir-issue-7b8270cbc167
In fact, you may find in the repository that I share with you the wrapper_index.ts, which follows the workaround and It works perfectly when we change the entryFile of the ng-package.json pointing to the wrapper the build works:
Some issues and links that we have check and seems to be related but do not work for us are linked below:
ng-packagr/ng-packagr#987
#2955
#1765
#2794
https://stackoverflow.com/questions/48189713/visual-studio-shared-typescript-library-ts6059-file-is-not-under-rootd
ng-packagr/ng-packagr#1264
Environment
`Report complete - copy this into the issue template
Node : 12.22.1
OS : darwin x64
npm : 6.14.12
nx : Not Found
@nrwl/angular : 12.5.8
@nrwl/cli : 12.5.8
@nrwl/cypress : 12.5.8
@nrwl/devkit : 12.5.8
@nrwl/eslint-plugin-nx : 12.5.8
@nrwl/express : Not Found
@nrwl/jest : 12.5.8
@nrwl/linter : 12.5.8
@nrwl/nest : 12.5.8
@nrwl/next : Not Found
@nrwl/node : 12.5.8
@nrwl/nx-cloud : 12.2.7
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.5.8
@nrwl/web : Not Found
@nrwl/workspace : 12.5.8
@nrwl/storybook : 12.5.8
@nrwl/gatsby : Not Found
typescript : 4.2.4`
Any help is welcome, thank you for your time!
The text was updated successfully, but these errors were encountered: