Description
getProjects or createProjectGraphAsync provide contents of project.json.
While building tools (generators/executors/other) it might happen very often that we need to access package.json to obtain more info about particular project or even additional configs.
ATM to obtain this metadata one needs to do additional IO calls to fetch these data + implement caching on its own to reduce IO impact hit.
It would be very helpful if nx api could fetch package.json metadata if present with optional config to fetch additional files as well if specified.
Motivation
Context provided in Description paragraph.
In our particular scenario the use case is to migrate away from lerna to nx / mix of various tech in a monorepo that needs to co-exists.
microsoft/fluentui#30178
Suggested Implementation
import * as devkit from '@nx/devkit';
const projects = devkit.getProjects(devkit.tree);
expect(project['hello-world'].packageJSON.toEqual({name:'@proj/hello-world',dependencies:{},devDependencies:{},bin:{...}})
// ===
const graph = await devkit.createProjectGraphAsync();
expect(graph.nodes['hello-world'].data.packageJSON).toEqual({name:'@proj/hello-world',dependencies:{},devDependencies:{},bin:{...}});
Alternate Implementations
optionally one could provide additional files to be fetched if necessary:
import * as devkit from '@nx/devkit';
const projects = devkit.getProjects(devkit.tree,{metadata:['.eslintrc.json']});
expect(project['hello-world'].packageJSON.toEqual({name:'@proj/hello-world',dependencies:{},devDependencies:{},bin:{...}})
expect(project['hello-world'].metadata.toEqual({'.eslintrc.json':{...}})
// ===
const graph = await devkit.createProjectGraphAsync();
expct(graph.nodes['hello-world'].data.packageJSON).toEqual({name:'@proj/hello-world',dependencies:{},devDependencies:{},bin:{...}});
expct(graph.nodes['hello-world'].data.metadata).toEqual({'.eslintrc.json':{...}})
Description
getProjectsorcreateProjectGraphAsyncprovide contents ofproject.json.While building tools (generators/executors/other) it might happen very often that we need to access
package.jsonto obtain more info about particular project or even additional configs.ATM to obtain this metadata one needs to do additional IO calls to fetch these data + implement caching on its own to reduce IO impact hit.
It would be very helpful if nx api could fetch
package.jsonmetadata if present with optional config to fetch additional files as well if specified.Motivation
Context provided in Description paragraph.
In our particular scenario the use case is to migrate away from lerna to nx / mix of various tech in a monorepo that needs to co-exists.
microsoft/fluentui#30178
Suggested Implementation
Alternate Implementations
optionally one could provide additional files to be fetched if necessary: