Closed mahmoudajawad closed 3 years ago
@mahmoudajawad This is related to fact that Nx libs are created by default as single barrel imports in tsconfig.base.json
, for example:
"@freshtest/ngtest": ["libs/ngtest/src/index.ts"]
This means you can not import a deep import from Nx libs (by design) but rather should export any files out of your lib via an index
so you can use those symbols from the single barrel throughout your workspace. If you wanted to allow deep imports off a lib you can add your own tsconfig.base.json rule in root as follows:
"@freshtest/ngtest/*": ["libs/ngtest/src/*"]
However it's not recommended since you really shouldn't be doing deep imports from your libs.
I setup a sample repo where you can see @nrwl/angular lib's working as normal (generated just as described): https://github.com/NathanWalker/freshtest
I also just pushed up a sample StateService to better illustrate: https://github.com/NathanWalker/freshtest/commit/e50811f587f05072f020748937da09da854f7fef
Thanks for spending time to build a PoC. It seems my issue is more complicated than that and that's what is causing the issue. I'll try to re-evaluate why your PoC worked while my project fails and report back.
If you’d like to share project privately would love to look. Always curious with anything like this.
So, after little attempts, guided by your earlier points, I found two interesting points:
@myorg/LIB_NAME
, and accessed the service as libs/LIB_NAME/state.service.ts
, however, only Angular app was able to understand what does libs
in the context means, while NS app fails.@nativescript/nx
is revolving around testing it and seeing how much of nx tooling can benefit the whole development process, so, I'm testing all possible scenarios, which distracted me from exporting StateService
and caused the whole issue. I can confirm once I exported the service the project builds and runs fine.So, although in practice I'm still touching differences between angular and ns apps, these differences are meaning-less, as the end-product wouldn't have the issue at all.
Thanks for your time on this. I'm closing it.
I have consistently been getting this error. I correctly imported the libs with no *.... and still got this issue.
However, after adding webpack.useConfig('angular'); in our webpack.config file - I no longer get this error.
Hi! Has anyone managed to find a solution to this situation? I'm having the exact same problem as @mahmoudajawad. I'm studying NativeScript and testing with NX to create a monorepo containing an NS + Angular web app. With angular project the libraries work fine however in NS app an import error occurs. I tried different ways but without solution.
Overview
A lib created by @nativescript/nx can be accessed by ns apps in the workspace, but not regular angular libs created by @nrwl/angular.
Steps:
npx nx g @nrwl/angular:lib
Logs
Notes
/path/to/workspace/libs/LIB_NAME
, and webpack tries to find the lib in all parent paths of the ns app, but not in/path/to/workspace/libs
.