Closed nhhockeyplayer closed 2 years ago
If the nx team can review this ticket and this thread https://stackoverflow.com/questions/56603223/nrwl-nx-importing-lib-error-ts2307-cannot-find-module-eduboard-interfaces
if its truly a bug should be fixed? yes?
Thanks for your diligence
Some ground on this made and obtained a successful build but not without some divine intervention.
CONTEXT: my monorepo has two utility libraries
- @meanstacknh/shared-core-dto
- @meanstacknh/shared-core-entity
my command line terminal build sequence is as follows
@meanstacknh/shared-core-dto
builds first and succeeds
@meanstacknh/shared-core-entity
uses interfaces from @meanstacknh/shared-core-dto
and fails to build because the project for @meanstacknh/shared-core-entity
cannot find the @meanstacknh/shared-core-dto
modules via import statements
No pathing variables within tsconfig
files were touched anywhere... also .angular/cache
was turned back on w/o effect
If a @meanstacknh/shared-core-entity
utility lib is using @meanstacknh/shared-core-dto
as an npm library they should be handled as such... yes?
which implies Nx should be installing the dependent library into the node_modules (or emulating it in its product logic) in order for cross dependent publishable utility libraries to build compile and succeed
QUESTION: Are cross dependent publishable utility libraries legal in Nx ? Should they be?
What did I do to get the build to succeed?
I added the @meanstacknh/shared-core-dto
lib as a peer dependency to the package.json of @meanstacknh/shared-core-entity
but this had no effect
{
"name": "@meanstacknh/shared-core-entity",
"version": "0.0.1",
"type": "commonjs",
"peerDependencies": {
"@meanstacknh/shared-core-dto": "latest"
},
"dependencies": {
"tslib": "^2.3.0"
}
}
what really got this to work was I had to manually instrument my monorepo package.json with the following (workaround hack):
Package.json
"@meanstacknh/shared-core-dto": "file:libs/shared/core/dto/src/lib",
"@meanstacknh/shared-core-entity": "file:libs/shared/core/entity/src/lib"
Im unsure what Nx is doing internally but the crux of this issue is I cannot build cross dependent libraries without ensuring they are installed in node_modules
Nx is NOT transposing node_modules to reflect utility library compilations for dependent util library import statements to succeed their build
This ticket has been quiet but this one seems to be a fair legit bug which should be high priority as its blocking libraries from being built.
Hoping for some action and feedback (or inspired Nx workaround I am sure I have not gotten this the way Nx needs it to be)
The policy for publishable utility libraries is sketchy at this time.
Thanks for an awesome elite product and your soonest response.
the move schematic is also impacted...
nx g move --project admin-root-shell admin/root/feature-shell
have to manually update package.json with the workaround I performed for this ticket
another observation... tsconfig is not being updated properly after the MOVE schematic (awesome feature btw) is used ...specifically the paths manual intervention required at this time
yikes... well here is an interesting anomaly...
upon looking at my tsconfig.json to see if paths are changed...
paths are changed root name has a double @ sign. Thats why its unable to reference properly as mentioned above. I didn't add that... this is the Nx logic under the hood. Hopefully this will help finding more.
tsconfig.json
"@@meanstacknh/shared-feature-user": [
"libs/shared/feature-user/src/index.ts"
],
ts files impacted too on imports with '@@'
Hi @nhhockeyplayer, thanks for reporting and sorry for taking a long time to get to this issue. Can you add nartc
as a collaborator to your project? If not, can you provide a quick reproduce?
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.
SUBJECT: @nrwl/js:library fails to cross import/compile util libraries
Current Behavior
Nx cannot locate shared modules in the npm package ecosystem under node_modules My entity library cannot import dto's from dto library I have to manually rig up node_modules
file://
protocol installs to get my build to succeedExpected Behavior
modules not found... this should be automated paths are configured right typescript is coded right project files barrel all in order and fleet
Steps to Reproduce
ask to be collaborator to my repo and I will grant you access Im a private developer
remove all npm packages within package.json
then execute
====== cut here ===== here are the details on how this came about... all angular cache at
.angular/cache/**
turned off the following command was used to create entity library.. after subsequent same for dto librarymeanstack02@admin meanstacknh % node node_modules/@nrwl/cli/bin/nx.js generate @nrwl/js:library --name=dto --directory=shared/core --publishable --buildable --prefix=shared-core-dto --skipFormat --addModuleSpec --parentModule=apps/admin/src/app/app.module.ts --tags='domain:shared,scope:core,platform:web,type:util' --unitTestRunner=jest --importPath=@meanstacknh/shared-core-dto --strict --linter=eslint --standaloneConfig --compilationMode=partial --no-interactive
cross lib import statements not holding water for lines 3 and 4 below
simple build refuses to complete/succeed for entity library that cross references classes of shared dto library fails on location of the module on import statements
here is the repo just ask to be collaborator https://github.com/nhhockeyplayer/meanstacknh
Failure Logs
Environment