Skip to content
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

feat(nextjs): allow withNx to be used with other executors such as run-commands #17819

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Jun 27, 2023

This PR allows withNx plugin to be used without @nx/next:build or @nx/next:server executors. As long as the command runs through Nx we can read the run information (e.g. project node, options, config) from the project graph.

Why?

There are legit cases where users may not use @nx/next:build or other expected executors.

  1. They wrap out @nx/next:build into their own custom plugin, say @acme/next:build.
  2. They use run-commands to execute npx next build directly.

After some thought, they only special case is that buildTarget or devServerTarget may be present, which requires additional reading of those target configurations. These special cases could be @nx/next:server that specify buildTarget, which defines the outputPath for example. Or when Cypress defines a devServerTarget, which then defines a buildTarget, so we need to follow that target chain fully.

In all other cases, we can safely fallback to the default behavior, which is to return the configuration for the current target. This could be either @nx/next:build, run-commands, or a custom executor.

Current Behavior

Using run-commands or command breaks with withNx.

Expected Behavior

Using run-commands or command does not break with withNx.

Related Issue(s)

Fixes #16064, #16277

@jaysoo jaysoo requested a review from a team as a code owner June 27, 2023 13:34
@jaysoo jaysoo requested a review from xiongemi June 27, 2023 13:34
@vercel
Copy link

vercel bot commented Jun 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2023 1:36pm

@nx-cloud
Copy link

nx-cloud bot commented Jun 27, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit b955e21. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@@ -421,7 +435,7 @@ describe('Next.js Applications', () => {
checkUnitTest: false,
checkLint: false,
checkE2E: false,
checkExport: true,
checkExport: false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really don't care about exports at this point since it's a deprecated Next.js command.

Copy link
Contributor

@ndcunningham ndcunningham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jaysoo jaysoo merged commit 77ca8d7 into nrwl:master Jun 27, 2023
@jaysoo jaysoo deleted the feat/nextjs-works-with-run-commands branch June 27, 2023 14:27
@github-actions
Copy link

github-actions bot commented Jul 3, 2023

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running Nextron(Next js library) inside NX monorepo
2 participants