Expose FsTree, flushChanges, and printChanges from @nx/devkit for programmatic generator execution
#34836
Fasosnql
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Currently,
FsTree,flushChanges, andprintChangesare internal to thenxpackage and cannot be imported from@nx/devkit. This means that anyone wanting to run Nx generators programmatically — without shelling out tonx generate— has no supported way to do so.This issue proposes exposing these three symbols (plus
TreeWriteOptions) as part of the public@nx/devkitAPI.Current Behavior
The
@nx/devkitpublic API only exports theTreeinterface andFileChangeinterface (both as types). The concrete implementationFsTreeand the utility functionsflushChanges/printChangesare internal-only:The only way to run a generator today is via
exec/spawn:Alternatively, consumers import from the internal path
nx/src/generators/tree, which is not a public API and subject to breaking changes without notice:Expected Behavior
FsTree,flushChanges,printChanges, andTreeWriteOptionsshould be importable from@nx/devkit:This enables the following programmatic workflow:
Motivation: LLM-Based and Agentic Code Generation
This change is particularly important for agentic and LLM-based code generation workflows, where:
exec/spawnis an unsafe primitive — giving an agent permission to shell out means files hit disk immediately, with no chance to review, validate, or roll back before the write occurs.execcalls.Example: LLM-Augmented Library Generation
This pattern is impossible today without either:
nx/src/generators/tree)exec/spawnand accepting immediate, unvalidated disk writesProposed Change
The change is minimal and additive — no modifications to existing code, just new exports in the public API barrel file.
File:
packages/nx/src/devkit-exports.tsBecause
packages/devkit/index.tsalready doesexport * from 'nx/src/devkit-exports', no changes are needed in the@nx/devkitpackage itself.Beta Was this translation helpful? Give feedback.
All reactions