Closed GeoedgeGuyMoreh closed 4 weeks ago
This problem seems to be appearing from nx version 16.3.0 and later.
Before (nx version <= 16.2.2) inside the file generated by nx graph --file=graph.json
relevant apps would have the following structure:
Their data
property would contain a files
array, which in turn contained references to dependencies
.
For example (redacted for brevity):
{
"graph": {
"nodes": {
"<app-name>": {
"name": "<app-name>",
"type": "app",
"data": {
"name": "<app-name>",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/<app-name>/src",
"prefix": "<app-prefix>",
"targets": {
// ...
},
"tags": [],
"root": "apps/<app-name>",
"implicitDependencies": [],
"files": [
{
"file": "apps/<app-name>/src/app/<module-name>/<module-name>.module.ts",
"hash": "<app-hash>",
"dependencies": [
{
"target": "npm:@angular/common", // ๐ desired reference to an npm dependency
"source": "<app-name>",
"type": "static"
},
// ...
],
// ...
}
]
},
},
// ...
Now (nx version >= 16.3.0) the generated file lacks the whole files
array inside the data
property.
For example (again redacted):
{
"graph": {
"nodes": {
"<app-name>": {
"name": "<app-name>",
"type": "app",
"data": {
"name": "<app-name>",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/<app-name>/src",
"prefix": "<app-prefix>",
"targets": {
// ...
},
"tags": [],
"implicitDependencies": []
// โ files array and therefore any reference to dependencies is missing in JSON output
}
},
// ...
This should be reproducible with any project using nx, but if necessary I can provide an MWE repo.
@FrozenPandaz Did you have a chance to look into this issue already?
Is there a new flag to enable the files array to be included in the JSON output file again?
I've tested a bit more and this problem seems to be caused by commit 0848031dd9c19672ab795e0494e54bbef61240c5
(I've tested 16.3.0-beta.0 and the problem / change already appears there).
@vsavkin Would it be possible for you to look into this problem please, as you authored that change?
Up!
Since print-affected
was deprecated in v19 (where we had access through .projectGraph.dependencies
), we need this fix to use the replacement graph
command (now .graph.dependencies
)
Can I ask what the exact use case for this is? If you want to just access the project graph programatically, you can use createProjectGraphAsync
from @nx/devkit
. It will contain all external nodes as well.
We specifically do not include external dependencies in the outputted .json
file to avoid bloat.
This issue has been automatically marked as stale because more information has not been provided within 7 days. It will be closed in 21 days if no information is provided. If information has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐
Current Behavior
Lately, in the recent version the nx dep-graph --file dep.json schema has been changed, it used to include the npm packages per file but it's not anymore.
I looked over the changelog and didn't see anything related to that, any idea why this change was? shouldn't I count on this file to be stable (structure-wise)?
Expected Behavior
include the npm packages as before, for example { "file": "apps/test-service/src/app/test-service/test-service.module.ts", "hash": "0ac96d6d11f862360f827746872562e9cb699603", "deps": [ "npm:@ssut/nestjs-sqs", "npm:@nestjs/common", "ces-events-hub-core", "data-access-s3-core", "npm:@willsoto/nestjs-prometheus" ] },
GitHub Repo
No response
Steps to Reproduce
1.Running nx dep-graph --file dep.json
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response