nx icon indicating copy to clipboard operation
nx copied to clipboard

feat(core): support providing schema in sync generators

Open jogelin opened this issue 2 months ago β€’ 8 comments

Summary

Align sync generator invocation with regular generators by providing schema-based options from nx.json and project configuration.

Current Behavior

Currently, sync generators are invoked with only a Tree parameter and do not receive any configuration options from the generator's schema, nx.json, or project configuration:

// Before
export type SyncGenerator = (tree: Tree) => SyncGeneratorResult;

This means sync generators cannot:

  • Access generator-specific options defined in their schema
  • Use options configured in nx.json via generators configuration
  • Use project-level generator defaults
  • Apply schema defaults and validations

Expected Behavior

Sync generators should receive combined options from their schema, just like regular generators do, but without command-line arguments (since they're not invoked directly by users).

// After
export type SyncGenerator<T = unknown> = (
  tree: Tree,
  schema: T
) => SyncGeneratorResult | Promise<SyncGeneratorResult>;

Related Discussion

Related to https://github.com/nrwl/nx/discussions/32663

jogelin avatar Oct 13 '25 15:10 jogelin

Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
Latest commit 959f1ca62f1be25c29f73e6f9b654cb669baac6f

netlify[bot] avatar Oct 13 '25 15:10 netlify[bot]

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Nov 13, 2025 4:04pm

vercel[bot] avatar Oct 13 '25 15:10 vercel[bot]

View your CI Pipeline Execution β†— for commit 89bb354adb41c326a6df791e48bef51eb10acd29

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ❌ Failed 1h 40m 13s View β†—
nx run-many -t check-imports check-commit check... βœ… Succeeded 2m 6s View β†—
nx-cloud record -- nx-cloud conformance:check βœ… Succeeded 2s View β†—
nx-cloud record -- nx format:check βœ… Succeeded 5s View β†—
nx-cloud record -- nx sync:check βœ… Succeeded 4s View β†—
nx documentation βœ… Succeeded 2m 54s View β†—

☁️ Nx Cloud last updated this comment at 2025-10-13 22:30:15 UTC

nx-cloud[bot] avatar Oct 13 '25 20:10 nx-cloud[bot]

πŸ‘ interested

mpsanchis avatar Oct 30 '25 07:10 mpsanchis

Hey @AgentEnder @FrozenPandaz, any chance we can move forward on this? It would be great to have it ready for 22.1 if possible.

jogelin avatar Nov 17 '25 13:11 jogelin

In the Nx documentation I just discovering:

image

This is only used by the typescript-sync generator which is reading NxConf directly: https://github.com/nrwl/nx/blob/081bec53cf23beab0bae332bd589d24a4745f638/packages/js/src/generators/typescript-sync/typescript-sync.ts#L201

Should we expect sync generators to read and apply options manually without any schemas?

I’m confused why this appears in the docs as a general way to configure sync generators…

jogelin avatar Nov 26 '25 10:11 jogelin

Hi folks! Anything we can do to move this forward? I'm happy to contribute with anything πŸ˜„

mpsanchis avatar Dec 09 '25 07:12 mpsanchis

πŸ’–

Scott reacted via Gmail https://www.google.com/gmail/about/?utm_source=gmail-in-product&utm_medium=et&utm_campaign=emojireactionemail#app

On Tue, 9 Dec 2025, 7:48β€―pm Scott mcgowan, @.***> wrote:

On Tue, 9 Dec 2025, 5:54β€―pm Miguel, @.***> wrote:

mpsanchis left a comment (nrwl/nx#33060) https://github.com/nrwl/nx/pull/33060#issuecomment-3630855117

Hi folks! Anything we can do to move this forward? I'm happy to contribute with anything πŸ˜„

β€” Reply to this email directly, view it on GitHub https://github.com/nrwl/nx/pull/33060#issuecomment-3630855117, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3H3VBPESWYDB53ZP6IQFVT4AZ5ZTAVCNFSM6AAAAACJBUTVGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMZQHA2TKMJRG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Gowza68 avatar Dec 09 '25 09:12 Gowza68