builder: how to write custom builder within nx / provide schematics
See original GitHub issueCurrent Behaviour
So I was trying to build custom builder by following angular-devkit docs.
In the end, I was able to run it, but it didn’t work.
Error
The process required “a lot” of overhead from developer perspective:
- need to manually create all the boilerplate
- need to compile builder on your own
- need to create npm package and use
yarn linkand friends
Expected Behaviour/Feature Request
-
provide docs how to author custom builder within nx workspace
-
provide tooling
- provide have schematic for booting custom builders (we have
nx g @nrwl/workspace:workspace-schematic, so something likenx g @nrwl/workspace:workspace-builder) - allow custom workspace builder to be used as targets without all that manual churn that is needed at the moment
thx a lot !
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Nx Tutorial: Building Custom Plugins for Nx - YouTube
Get details about Nx plugins! Now you can create your own custom plugins. Nx core team member, Isaac Mann, tells shows you how,...
Read more >Create Your First Custom Angular CLI Schematic with Nx - Auth0
Learn how to create applications, libraries, and custom workspace CLI Angular schematics with enterprise Angular tool Nx.
Read more >Creating an Angular Schematic and Turn It Into an Nx Plugin
In this blog post I would like to explain how you can write a schematic and turn it into an nx plugin or...
Read more >Nx custom schematic in repository not able to load
I setup a repo for a custom Nx builder and schematics to build an application / init. Initially I developed it in the...
Read more >How to Forge a Powerful Custom Builder in Angular
Our goal is to write a builder that publishes our libraries for us. ... a custom builder, if you're using the tools provided...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found


Hello, this is probably more an issue on the Angular side, as they just don’t have official support for TS schematics (and builders) to run directly yet. See https://github.com/angular/angular-cli/issues/13858.
I had the same pain and I want to share how we approach it currently for our project where we have various builders and schematics which we use on a regular basis locally and on the CI. In the beginning we searched for a “elegant” solution, then quickly decided for the pragmatic way to get things done. We use that solution every day since then.
tools/folder for our shared packages.yarn nx build @builders/builder-a)npm-run-allfor the wildcard support.The builder artifacts will be written to
build/libs/builders/builder-aand so on.You can now start using it. Refer to the artifact via
"builder": "./build/libs/builders/builder-ain your target configuration in angular.json, wherever you want to use the builderYou are currently developing the builder? We have a
yarn nx develop @builders/builder-atarget which will output the latest artifacts intobuild/libs/builders/builder-awhenever we change code (through a custom nodemon watch task). Works flawless for schematics & builders for us, especially if you use jest for a test driven approach, as you can run the schematics within jest without even building it as jest compiles the typescript.As said, this is a limitation by Angular. Maybe we can extend the Nx Documentation to guide people properly or craft a schematic to support the creation of the various parts. I’m sure there is some smart person who can provide a solution to run the builders directly with ts-node some day, but until then the outlined solution is a good start that works without any problems for us. I hope this helps a few folks 🙏
Any updates on this? It’s a needed thing; I’d like to be able to develop Angular Builders in my Nrwl monorepo seamlessly