Open
Labels
area: @angular/clifeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under consideration
Milestone
Description
It would be useful to have a way to build a certain set of projects on a workspace.
Perhaps this can be achieved with global workspace targets, or via a filtering mechanism.
Followup to #10397
Reacted by Nwel, marmaak, Jean-Philippe Leclerc, Marco Spönemann, Jared Bates, Alexandru Sfirlogea, Rohan Brodier, Addison Schuhardt, Hiromu OCHIAI, Justin Lettau and 84 more
Reacted by Kyoz, Robin Bomkamp, Andrius, Jack Baker, VitalyVrublevskiy, Barna Tóth, gerardqueralt, Yaksh Bariya, Klemen Oslaj, Pavlol Korobov and 11 more
Metadata
Metadata
Assignees
Labels
area: @angular/clifeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under consideration
Activity
abhijeetkpawar commentedon Jan 7, 2019
Any plans for this feature?
klemenoslaj commentedon Feb 20, 2019
Hi @filipesilva,
Every project in a workspace already contains
package.json(obviously). We could usepeerDependenciesto declare the dependencies between projects of the workspace. Thenbuildandtestcommands would be able to detect the dependencies and build the libraries in the correct sequence.I have written myself a node executable that does exactly that. Follows the dependency tree and builds the libraries in the correct sequence.
If that is something you see as a valuable addition to Angular CLI I would be more than happy to contribute.
filipesilva commentedon Feb 21, 2019
@klemenoslaj the approach we are looking at now would be able to do that implicitly, we hope. We're still finishing up the Architect API (this is what we use for build definitions).
klemenoslaj commentedon Feb 21, 2019
@filipesilva, that sounds good 👍
I however still like the idea of using
peerDependencies, because it forces people to think about their dependencies (very important for published packages) and if that is done correctly, build sequence is automatically correct.I can see how that can be a bit complex for someone, but I still think handling dependencies via package.json is a good way to go.
RobinBomkampDv commentedon Apr 25, 2019
Are there any plans when it can be expected?
jpleclerc commentedon Apr 26, 2019
Is it possible with the new CLI builders announced here : https://blog.angular.io/introducing-cli-builders-d012d4489f1b ?
If yes could we have an example ?
meriturva commentedon Apr 26, 2019
Actually, the builder approach is just project related and not workspace related. We already implemented npm script that just analyzes all projects, builds dependency tree and calls sequentially build but still problems during watch mode: build is too slow!
During development time I guess only productive way is to change tsconfig path as described on #10643 (comment)
siddharth1903 commentedon Aug 13, 2019
@meriturva Is this possible for multiple libraries within a single project? I understand schematics exposes options to invoke external schematics and builder is just an extension of schematics!?
meriturva commentedon Aug 13, 2019
@Goonersid our approach is just for a single project with multiple libraries. Right now we have all to test new build based on bazel before improving our internal solution.
siddharth1903 commentedon Aug 13, 2019
@meriturva I'm looking for a cli cmd that builds all libraries within a single project... Is it possible with v6 or the latest stable? Something like ng build-all
meriturva commentedon Aug 13, 2019
@Goonersid you have to write you own task script and run as:
npm run build-allprobert94 commentedon Aug 28, 2019
@Goonersid I was also looking for something like this and created a script, which reads the
angular.jsonfile and executesng buildfor every project and every configuration. Also this script collects all failed builds and prints them tostdoutat the end.EDIT:
I am using nrwl/nx, so I don't have to build libraries manually.
So this script will probably not work for default Angular CLI.
The script looks like this:
This script can be compiled to Javascript and then you can run it using
NodeJs.klemenoslaj commentedon Sep 10, 2019
@Springrbua but you're not following any dependencies, therefore if some library depends on another this will break or work by accident.
probert94 commentedon Sep 10, 2019
@klemenoslaj You are right, I never used the normal Angular CLI for multi app projects and therefore forgot, that you need to build libraries yourself.
I am using nrwl/nx, which automatically builds all needed libraries when executing
ng build, so that's not a problem in my case.17 remaining items
klemenoslaj commentedon Mar 22, 2022
There is not much going on in this feature request. I would still like to offer my repository for possible inspiration but will leave it at that due to lack of interest.
@filipesilva feel free to have a peek at the following repository. I implemented an implicit approach, so no additional config is required whatsoever.
The repository: https://github.com/klemenoslaj/ong-cli
vajahath commentedon May 5, 2022
This is indeed looks like a rough edge where the community seem to be struggling. I was able to stumble upon a lot of SO threads pointing to the need of this feature, for years.
To point out a few:
and all of these threads seem to be very genuine.
It would be very great when we run serve/build, cli would automatically build its depended libraries as well. The solution should also be compatible when ng serving multiple apps.
As of now what I'm doing is open a terminal per library and run ng build --watch. Guess how many terminal tabs I'm keeping!
hiepxanh commentedon May 5, 2022
I have to move nx to have this: https://nx.dev/generators/workspace-generators
I can build a set of project easy, example
meriturva commentedon May 5, 2022
Our way (without using nx) is to analyze all projects from
angular.jsonfile and create a dependency tree, then run multiple build commands based on tree (parallelly) to speed up the process.See how we read
angular.jsonfile: https://medium.com/we-code/angular-inspect-workspace-programmatically-3cdfeb9b93d4CharlieStuart1995 commentedon May 19, 2022
Hi,
We are facing the same problem as you and you're solution sounds perfect! Would you be willing to share how you create the dependency tree and run build commands based on it?
Thanks in advance
boeckMt commentedon May 19, 2022
@meriturva I would also be interested in how you did this because it sounds very similar to what we did :)
@K3CharlieStuart current solutions I know now are:
CharlieStuart1995 commentedon May 19, 2022
@boeckMt thanks for the suggestions!
I'm just looking into your second suggestion but I cant seem to figure out how we would utilise this in our project. Would it be a case of copying the script folder into our application and somehow executing the quoted function?
meriturva commentedon May 19, 2022
Here is just a code snippet of how we build our dependencies tree, it is really simple,
the complex one is to run all scripts parallel and that script it is on our private repo right now and I cannot share it for now.
May be I could arrange an article (or a few) about that. Would you be interested?
klemenoslaj commentedon May 19, 2022
Sorry for repeating the same thing, but I feel we are going back to basics here - reading angular.json etc.
Have a look at the #11002 (comment) where I made an entire repo public - it even supports parallel builds no matter the complexity of dependency tree.
Running example in the following comment: #11002 (comment)
Due to lack of interest I did not yet made this an npm package tho, but feel free to consume & contribute.
PrestonMonteWest commentedon Jun 11, 2024
Definitely interested in something like this. It would be nice to specify what projects to build and the order to build them. I know it can be done manually through scripts in the
package.json, but doing so is cumbersome and inconsistent with the highly configurable nature of the build process in general. Also, a first-party solution from Angular would help streamline and standardize the process. It looks like this isn't being pursued at the moment in a first-party solution, so I'm adding my comment here to give this more support.Volvohorst commentedon Oct 16, 2024
I would be highly interested in a "native" Angular CLI solution as well.
It would greatly improve our ability to guarantee development quality and provide a consistent dev environment to our developers.
Providing hints at https://angular.dev/tools/libraries would have been nice too.