Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior when extending a application generator versus generating an app using the CLI #23295

Closed
1 of 4 tasks
beeman opened this issue May 10, 2024 · 1 comment
Closed
1 of 4 tasks
Assignees

Comments

@beeman
Copy link
Contributor

beeman commented May 10, 2024

Current Behavior

In this project we extend the Next and React generators to create apps.

In a default Nx 18 and 19 project (with Crystal) the app that gets generated by our extended generators, the content of project.json is verbose as can be seen in this generated app.

However, if we generate a second app using the nx CLI in the same workspace, the content of project.json is (mostly) using the inferred targets as can be seen here.

The curious thing is that this is happening without having set useInferencePlugins in nx.json or having the env var set.

Expected Behavior

Considering the workspace does not have useInferencePlugins set, I would expect the extended generator to behave the same as when we're using the CLI.

GitHub Repo

https://github.com/beeman/solana-dapp-react-version

Steps to Reproduce

  1. Create a new app using pnpx create-solana-dapp@next
  2. Pick the React option (for consistency with the example, same happens with Next though).
  3. Verify that web/project.json is verbose
  4. Create a second app: pnpm nx g @nx/react:app second --e2e-test-runner none --routing false
  5. Verify that second/project.json is inferred.

Nx Report

❯ pnpm nx report

 NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.

Pass --verbose to see the stacktraces.

❯ pnpm nx reset

 NX   Resetting the Nx workspace cache and stopping the Nx Daemon.

This might take a few minutes.


 NX   Daemon Server - Stopped


 NX   Successfully reset the Nx workspace.

❯ pnpm nx report

 NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.

Pass --verbose to see the stacktraces.

Failure Logs

No response

Package Manager Version

pnpm 9.0.5

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

This also happened with Nx18 but I decided to wait till Nx19 to make sure it wasn't fixed there.

Somehow, nx report fails in my demo project, I'll create a separate issue for that (#23296).

@Coly010
Copy link
Contributor

Coly010 commented May 10, 2024

Hey @beeman!

Perhaps there is a misunderstanding here on Inferred Projects with new workspaces.
By default, inferred targets is turned on.

The useInferencePlugins and env var are options provided to allow people to specifically opt-out of inferred targets. Therefore when our first party plugins (such as @nx/react) are run, they will attempt to use inferred targets, even if other projects in the workspace are using defined projects in project.json files.

I'm going to convert this issue to a discussion because this is correct behaviour but perhaps it should be discussed more.

@nrwl nrwl locked and limited conversation to collaborators May 10, 2024
@Coly010 Coly010 converted this issue into discussion #23302 May 10, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants