-
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
Cannot build library which depends on publishable lib in sub folder #2794
Comments
@mrucelum Thx for reporting and for the detailed reproduction steps. Helps a lot to save time on our side 🙂 I followed your steps and also cloned your repo and the build works for me. but only of course if I made the adjustments to the tsconfig.json you mentioned ( The problem right now is the following: by default, we define the path mapping of libraries in Publishable libraries (aka buildable libraries) are intended to be buildable on their own (and not as part of an app) & publishable to NPM for instance.
A valid package name cannot have muliple I'll give this a look. Meanwhile manually adjusting those libraries should work. Otherwise let me know. |
@juristr thanks you for the fast and detailed reply! And sorry for my late response... :/ I am not sure if I can follow you which manual adjustments I should do? My adjustments did not help (on my system at least :) ). I also did a fresh check out and install of my sample and I cannot make it run without errors. I also tried to switching back to
in the Thanks again :) |
Same here. It prevents me from using incremental compilation with: Is there a solution on the horizon? |
I'm seeing similar issues - happy to also provide a repo with steps if that helps. |
Hello folks, Issue: #2955 Thank you. |
I'm having the same issues, changing the tsconfig path syntax from |
@TimGeerts can you provide your system specs? Is it Windows (Version? Node Version?) or OSX? You can see in my previous comment a linked issue with an extensive explanation of the issue. I now added the screenshot from it in this thread and it's exactly showing what is happening on your side. It would be interesting if you are on Windows as this would confirm our observations. |
My system specs: Maybe I can check whether my repo works on a Linux system in the afternoon. |
Hello @mrucelum, There is an extensive analysis plus minimal example where we can perfectly reproduce the issue of the missing dependencies (on Windows while OSX is good). Could you try out the minimal example and report the following:
You don't have to build or run a server — just compile the
Results in a gist on our side: |
@georgiee , I'm on Windows 10 (Enterprise, v1709) indeed, node 12.15.0. edit I cloned the repo and ran the commands, the results are the same as in the bottom picture above (your post), so the "bad" windows 10 version where the nested (d) library is floating around in space like it's not attached to anything |
Hi, I can confirm that the issue seems to be a windows only issue. In addition I have the same behavior as @georgiee describes with his repo (https://github.com/georgiee/nx-debug-nested-dep-graph) under windows 10 enterprise: |
Thank you @mrucelum, @TimGeerts & @jbjhjm. All of your reports confirmed that Windows 10 Enterprise causes the problem. I will try to reproduce it in a Windows 10 VM. I did not succeed with this before (it just worked before) but it was early to this debugging journey and I'm unsure what version and I used. In addition I had no repository that reproduced the problem so clearly at the time of testing. If someone wants to try some debugging in parallel — I put some debugging hints in my comment here: Maybe some maintainer of the Nx Workspace recognize this is a true bug and join our discussion in the meantime. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@benjamincharity Besides using scope you describe a very different error. You should create a separate issue if you want a chance of being recognized. Don't forget to provide a minimal example that reproduces the error. |
Still facing this issue on version 9.4.4. All tests pass and build fails. |
Hey all, sorry for the long wait 😞 . So we basically just merged #2840 and it should have been already released with v10.0.3. Just upgrading won't work as we didn't do any migration because that would have been difficult & probably suboptimal. So what changed?So what did I add in the PR. Basically we're currently trying to optimize the incremental build story & the PR is a first step in that direction. So the PR now clearly distinguishes between
How can I fix my workspace?The best is to generate a new Nx v10 workspace, create a similar scenario you're having in your app & have a look at the differences. It should mostly be the TSConfig path mappings & package.json names. If you have questions, or if there are still issues, please let me/us know and open a new issue :) |
@juristr is this still the guidance for buildable libraries? Or was that changed? I'm asking since all of the examples in |
@Splaktar exactly, that is no more necessary. Publishable libraries need to have a correct path mapping since they are made for publishing and therefore need to follow those rules. Buildable libs don't have that restriction. |
I just spent 2 solid hours debugging the error
I finally understood where it came from 🤯. I generated a bunch of libraries, some of them were in nested folders. I messed up and didn't the name of the library would be concatenated so I generated something like this
and couldn't bother rename them just yet (I'm working on a huge and 100% independent task so a long lived branch isn't an issue here and wanted to do that at the end). At some point, I ended up renaming the libs everywhere in angular.json and nx.json because their names were
So I did rename them to
Same for the TS mapping as it was annoying. So I renamed them everywhere. Or at least that's what I thought. But I completely forgot about the fact that buildable libs have their own name written in their Taking the time to share in case anyone else does that or simply for my future self. I'm sure I'll re-read this thread desperately in a few years 🤦 |
@maxime1992 I ran into the same problem and it was a nightmare (multiple days) to debug. I finally just changed the libs to no longer nest and it finally fixed it. For clarity, your fix was to just change the name in the |
I fixed exact issue by adding to each library's tsconfig.lib.json one line:
This will allow typescript to load your libs instead of compiling them. Also make sure you build them in order they depend on each other. |
At first glance this looks like a clever solution, but isn't it going to cause developer havok as their IDE is parsing "built" code that is potentially out of date from the library source code they might be working on? |
the problem I had was when the repo was cloned and failed to run the server, as it looked for the library in the dist directory and there was none. so now i put your build on the |
the problem with me was due to using I renamed all lines to oh, another thing I did was use the |
@simondotm see my comment above, this way I was able to remove the tsconfig path from my lib |
Ah ok, that would make sense, since 1) yes you need to use npm compatible package names in the |
I struggled a lot with this over the last few days trying many many things, I have some core helpers and types which I wanted to include in a publishable UMD app. In the end, for me, it was very simple to bypass the Maybe this helps some of you, I added the helper and the types like normal.
Then I have added the exact locations of where these things can be found to the
|
nx version: 12 I'm not sure if anyone is still having this issue, but I ran into the exact same error ( I was trying to import a publishable lib into another publishable lib (using node:lib --buildable --publishable) I spent about 3 hours on it and decided to remove those packages from my After that the issue was resolved. Not sure why anyone would install those packages in your root package.json of an nx workspace, but if you do that it could be an issue that looks exactly like this. Here's the error, just to confirm it's the same error. |
For the record: this error will still appear under windows if you are referencing code that hasn't been built into the |
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. |
Expected Behavior
It should be possible to build a publishable lib that depends on another publishable lib that resides in a sub folder.
Current Behavior
The issue I have is similar to #602 which is already fixed and working. However, if I have my libs in sub folders (e.g. libs/platform/my-lib) then it still fails with
'rootDir' is expected to contain all source files.
Failure Information (for bugs)
Steps to Reproduce
common
uses the one fromcore
like so:tsconfig.json
on root level fromto
(not sure why its created like this although in the
package.json
the libs are named "@my-org/platform-core" and "@my-org/platform-common")However, it does not make any difference. So even if I keep it like
@my-org/platform/core
(in tsconfig.json and the import in the class incommon
lib) the error is the same.nx build platform-core
(works!)nx build platform-common
(fails)See also: https://github.com/mrucelum/nx_publishable_lib
Context
@nrwl/angular : 9.2.1
@nrwl/cli : 9.2.1
@nrwl/cypress : 9.2.1
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 9.2.1
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 9.2.1
@nrwl/web : Not Found
@nrwl/workspace : 9.2.1
typescript : 3.8.3
Failure Logs
The text was updated successfully, but these errors were encountered: