Open vladkasianenko opened 1 month ago
Thanks for reporting this, @vladkasianenko. Can you please give me the minimum reproduction scenario? Is it an android app + an azure function? Which NX version are you using?
This will help me greatly to make sure that different scenarios are working properly.
It is Angular + Shared Lib + Azure Function.
Node : 22.9.0
OS : win32-x64
Native Target : x86_64-windows
npm : 10.8.3
nx (global) : 19.8.3
nx : 19.6.3
@nx/js : 19.6.3
@nx/jest : 19.6.3
@nx/linter : 19.8.3
@nx/eslint : 19.8.3
@nx/workspace : 19.6.3
@nrwl/workspace : 19.8.4
@nx/angular : 19.6.3
@nx/cypress : 19.6.3
@nx/devkit : 19.6.3
@nx/esbuild : 19.6.3
@nx/eslint-plugin : 19.8.3
@nx/node : 19.6.3
@nrwl/tao : 19.6.3
@nx/web : 19.6.3
@nx/webpack : 19.6.3
typescript : 5.5.4
---------------------------------------
Registered Plugins:
@nx/cypress/plugin
@nx/eslint/plugin
---------------------------------------
Community plugins:
@nxazure/func : 1.1.6
---------------------------------------
Another issue with these paths is that:
npx nx build myfunc
- that procudes the following dist folder
apps
libs
tsconfig.base.json
node apps\func\src\functions\function.js
This gives the error: Cannot find module '@org-name/myLib'
@vladkasianenko
Could you please share your shared lib project.json
file?
Another issue with these paths is that:
- Run the
npx nx build myfunc
- that procudes the followingdist folder
apps libs tsconfig.base.json
- Run the
node apps\func\src\functions\function.js
This gives the error:Cannot find module '@org-name/myLib'
Could you try to use the other executor to run the function app?
Try nx start myfunc
. This executor has other steps that are necessary to run the function app which will use the imports and everything.
project.json
{
"name": "myLib",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/myLib/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/libs/myLib",
"tsConfig": "libs/myLib/tsconfig.lib.json",
"packageJson": "libs/myLib/package.json",
"main": "libs/myLib/src/index.ts",
"assets": [
"libs/myLib/*.md"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}"
]
}
}
}
Unfortunately, I couldn't reproduce the issue on my end.
All works for me as expected.
Just to make sure, do you start your functions with the start
command? nx start myfunc
?
If you can create a repo with just 3 projects that can reproduce the issue, I'll be glad to have a look at it.
When creating a function, the output of
tsconfig.json
does not includeextends
andreferences
properties. So if I have a shared library, I need to manually registerpath
insidetsconfig.build.json
, which is not convenient.Compare to the Angular and Lib: Listing of
tsconfig.base.json
which is in the root:Angular's
tsconfig.json
:Angular's
tsconfig.app.json
:So in any file of Angular app, I can import something from the myLib using
import { myFunc } from '@org-name/myLib';
I can't do the same with Azure Functions. The_registerPaths.ts
seems not working for me.