Complete Nx plugin development toolkit: create custom generators, executors, and extend Nx workspaces with reusable automation
93
94%
Does it follow best practices?
Impact
92%
1.00xAverage score across 5 eval scenarios
Passed
No known issues
You have a generator that adds a new build target to existing projects, but it's causing major problems:
import { Tree } from '@nx/devkit';
import { writeFileSync } from 'fs';
export default async function (tree: Tree, options: { project: string }) {
// PROBLEM 1: Overwrites entire config
const newConfig = {
name: options.project,
targets: {
'custom-build': {
executor: '@nx/js:tsc',
options: { outputPath: 'dist/libs/' + options.project }
}
}
};
tree.write(`libs/${options.project}/project.json`, JSON.stringify(newConfig));
// PROBLEM 2: No boundary checks
tree.write(
`libs/${options.project}/src/index.ts`,
`import { util } from '@myorg/internal-api';` // Cross-boundary import!
);
}Issue #1: "The generator deleted all my existing targets!"
build, test, and lint targetscustom-build remainsIssue #2: "CI fails with boundary violation errors"
scope:internal to scope:public librariesIssue #3: "Generator breaks when we reorganize folders"
libs/ prefix fails with different workspace layoutspackages/, others in libs/Fix the generator to safely update configurations.
Create:
Existing project config:
{
"name": "my-lib",
"root": "packages/libs/my-lib",
"tags": ["scope:public", "type:util"],
"targets": {
"build": { "executor": "@nx/js:tsc" },
"test": { "executor": "@nx/jest:jest" }
}
}Generator should ADD custom-build target while preserving build and test.