- ABP Framework version: v5.3.1
- UI type: Angular
We have a module created via suite and now we have crate our nuget pack and NPM to reuse it in another module.
I try to find a way to solve a nightmare related to export module/proxy. All works fine until I need to call a proxy from module B that it came from module A.
I look into a SAAS module and I see that proxy folder is not inside SRC for angular but it was at root level
saas |--proxy |--src
I try to reproduce the same structure but via abp generate-proxy is not possibile... or don't find a way to do that. Looking inside the source I see that ad a ng-package.json to export proxy from module. I do the same but I still get the error module not exported.
My folder structure is ModuleA |--src |-----lib |--------proxy -> In this folder I put ng-package.json
So now I have my build module with proxy epoxrted... but it still no working.
Looking into the generated code I see that SAAS has @volo/abp.ng.saas/proxy into proxy folder but in my module I have @moduleA/src/lib/proxy. I search the documentation where find a way to create a module and NPM package but I don't find anything.
In all module angualr exists only the project foleder and not the entire project (I see that it is refere to a file tsconfig.base.json but where is this file?)
3 Answer(s)
-
0
Hello,
Currently, abp proxy generation does not support direct generation in secondary entrypoints. But there is a way to generate in a secondary entrypoint. You can follow the steps below;
- Create a secondary entrypoint named 'proxy' (you can look ng-packager doc)
- Before running the proxy generation command open the angular.json folder and edit the
sourceRoot
property of your project's from 'projects/your-lib/src' to 'projects/your-lib/proxy/src' - Run proxy generation command
- Revert sourceRoot change in angular.json
- Create an index.ts near proxy/src/lib/proxy and export dirs directly. Do not export index.ts in the proxy folder (eg
export * from proxy/identity
). Export index.ts where in proxy/src/lib/ in public-api.ts - Define paths in tsconfig.json near your modules path
//tsconfig.json "paths": { "your-project": ["src/projects/your-project/src/public-api.ts"], "your-project/proxy": ["src/projects/your-project/proxy/src/public-api.ts*"] // this line added }
After these steps, you are available to import generated code from "your-project/proxy" entry point.
Also, I opened an issue for support generating in secondary entrypoints. You can follow the status of the issue.
-
0
Hi @muhammedaltug
thanks for your quickly reply.
I add some note to integrate your suggestion:
- Remove src prefix and * at file name end
//tsconfig.json "paths": { "your-project": ["projects/your-project/src/public-api.ts"], "your-project/proxy": ["projects/your-project/proxy/src/public-api.ts"] // this line added without * }
- public-api.ts: in projects/your-project/proxy/src/public-api.ts add lib export created before on /proxy/src/lib (not index.ts into /proxy/src/lib/proxy
- create a ng-packge.json like this. On github like the suggestion is to create it empty but you must export ts on dist folder
{ "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", "dest": "../../../dist/your-project/proxy", "lib": { "entryFile": "src/public-api.ts" } }
-
0
Hello,
Yes, your notes are correct. What is the last status of the process of the generation proxies ? Can we close the question?