There is no easy way for a development team that works on multiple projects for multiple clients to deliver the codebase for a single app
It would be nice if nx had a 'deliver-codebase' (or similar) command to create a codebase deliverable for a single app in dist.
nx deliver-codebase app1 creates dist/codebases/app1
I'm part of a rapid prototyping team that works on multiple angular apps across multiple client accounts. For all of our client engagements, we've been required to deliver a build artifact (ng build --prod) as well as a codebase. I see the codebase deliverable requirement as a big reason why our team hasn't adopted monorepo style development. For various reasons, we would not want to hand over the entire monorepo to fulfill the requirement for a codebase deliverable; so it's just easier to deliver codebases of standalone angular apps.
If my team was to adopt nx and monorepo style development, I think the laziest (manual) way for us to meet the codebase deliverable requirement for 'app1' would be something along the lines of:
1) create a new nx workspace (deliverable workspace)
2) create app1 in deliverable workspace (just to create entries in angular.json and nx.json)
3) copy package.json from dev workspace into deliverable workspace
4) copy apps/app1 directory from dev workspace into deliverable workspace
5) copy entire libs directory from dev workspace into deliverable workspace
It would be nice if NX had a command to accomplish this in a more intelligent way. Ideally, the command 'nx deliver-codebase app1' (or something similar) would create a codebase deliverable in dist/codebases/app1. That command should leverage the advanced code analysis behind dep-graph to only include libs that app1 depends on.
dist/codebases/app1 would not necessarily have to be a whole new nx workspace (I don't know how I feel about workspace-ception). It might be simpler for dist/codebases/app1 to be structured like a standalone angular app. Something like:
-apps/
-app1/
-....
-dist/
-....
-codebases/
-app1/
-src/
-e2e/
-libs/
-.....
-package.json
I'd also be interested in any guidance for adopting monorepo style development in a "multi-project, multi-client" environment.
I think this is an interesting feature. What is the interest in the community for this kind of feature?
This is not something which pertains to the main goal of Nx which is to allow monorepo development for a single organization. Thus, it is unlikely this becomes a first party feature.
However, you can implement this for your own workspace. Here's how I would do it (It might seem complex but it seems like it would save you time by automating the process):
yarn dep-graph --file dependencies.json to generate a JSON file containing the dependency graph.workspace-schematic to use the information in dependencies.json + other places.nx.json and determine which implicitDependencies affect <targetApp>root of <targetApp>dependencies of <targetApp>tsconfig.jsontslint.jsonnx.jsonangular.jsonyarn workspace-schematic <workspaceSchematic> <targetApp>Sorry, I don't think this will be a feature anytime soon within Nx. However, if someone wants to create a plugin in the community, please check out this guide: https://nx.dev/react/guides/nx-plugin
Most helpful comment
I think this is an interesting feature. What is the interest in the community for this kind of feature?
This is not something which pertains to the main goal of Nx which is to allow monorepo development for a single organization. Thus, it is unlikely this becomes a first party feature.
However, you can implement this for your own workspace. Here's how I would do it (It might seem complex but it seems like it would save you time by automating the process):
yarn dep-graph --file dependencies.jsonto generate a JSON file containing the dependency graph.workspace-schematicto use the information independencies.json+ other places.nx.jsonand determine whichimplicitDependenciesaffect<targetApp>rootof<targetApp>dependenciesof<targetApp>a.
tsconfig.jsonb.
tslint.jsonc.
nx.jsond.
angular.jsone. Others..
yarn workspace-schematic <workspaceSchematic> <targetApp>