Skip to content

chore(nx-dev): use continuous tasks in nx-dev #31127

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
43 changes: 14 additions & 29 deletions nx-dev/nx-dev/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@
"projectType": "application",
"targets": {
"build": {
"dependsOn": [
{
"target": "build-base"
}
],
"executor": "nx:run-commands",
"options": {
"commands": [
"nx run nx-dev:sitemap",
"ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts"
],
"parallel": false
},
"dependsOn": ["sitemap"],
"command": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts",
Comment on lines +8 to +9
Copy link
Contributor

Choose a reason for hiding this comment

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

The change introduces a circular dependency in the task execution flow. Currently:

  • build depends on sitemap
  • sitemap depends on build-base

This creates a cycle that differs from the original execution order where build depended on build-base first, then ran the sitemap command.

To maintain the original execution order while using the new continuous task format, consider changing the dependency to:

"dependsOn": ["build-base"]

Then have the sitemap task run before the link checker command, or include both commands in sequence.

Suggested change
"dependsOn": ["sitemap"],
"command": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts",
"dependsOn": ["build-base"],
"command": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts",

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

"inputs": [
"production",
"^production",
Expand All @@ -27,11 +16,9 @@
"outputs": ["{workspaceRoot}/dist/nx-dev/nx-dev"]
},
"sitemap": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/dist/nx-dev/nx-dev/public"],
"options": {
"command": "pnpm next-sitemap --config ./nx-dev/nx-dev/next-sitemap.config.js"
}
"dependsOn": ["build-base"],
"command": "pnpm next-sitemap --config ./nx-dev/nx-dev/next-sitemap.config.js"
},
"generate-og-images": {
"executor": "nx:run-commands",
Expand All @@ -43,7 +30,7 @@
"build-base": {
"parallelism": false,
"executor": "@nx/next:build",
"dependsOn": ["copy-docs"],
"dependsOn": ["copy-docs", "copy-tutorial"],
"outputs": ["{options.outputPath}"],
"options": {
"root": "nx-dev/nx-dev",
Expand Down Expand Up @@ -73,23 +60,21 @@
"cwd": "nx-dev/nx-dev"
}
},
"serve-docs": {
"executor": "nx:run-commands",
"options": {
"commands": [
"nx watch --projects=docs,tutorial -- nx run-many -t=copy-docs,copy-tutorial -p nx-dev",
"nx run nx-dev:serve"
],
"parallel": true
}
"watch-docs": {
"continuous": true,
"command": "nx watch --projects=docs,tutorial -- nx run-many -t=copy-docs,copy-tutorial -p nx-dev"
},
"start": {
"dependsOn": ["build-base"],
"continuous": true,
"command": "nx run nx-dev:serve:production"
},
"serve-docs": {
"continuous": true,
"command": "nx run nx-dev:serve"
},
"serve": {
"executor": "@nx/next:server",
"dependsOn": ["copy-docs", "copy-tutorial"],
"dependsOn": ["copy-docs", "copy-tutorial", "watch-docs"],
Copy link
Contributor

Choose a reason for hiding this comment

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

The serve target depends on the continuous task watch-docs, which by design never completes. This dependency structure may prevent the serve target from executing properly, as it will wait for watch-docs to complete before proceeding.

Consider one of these alternatives:

  1. Remove watch-docs from the dependency list and start both tasks in parallel using a parent task
  2. Use the "parallel": true option in the dependency configuration
  3. Restructure the workflow so that watch-docs runs independently

This ensures both tasks can run simultaneously without blocking each other.

Suggested change
"dependsOn": ["copy-docs", "copy-tutorial", "watch-docs"],
"dependsOn": [{"projects": ["copy-docs", "copy-tutorial", "watch-docs"], "parallel": true}],

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

"options": {
"buildTarget": "nx-dev:build-base",
"dev": true
Expand Down
1 change: 1 addition & 0 deletions nx-dev/tutorial/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}
},
"build": {
"dependsOn": ["build-code-block-button"],
"inputs": ["{projectRoot}/src/**/**"],
"outputs": ["{projectRoot}/dist"]
},
Expand Down
Loading