Add Nx

AS
2d ago
+155-0

Summary

Adds Nx for incremental adoption, following Nx's start with an existing project flow. This is task-running + caching only: nx.json is added and nx is added as a devDependency. Existing scripts are left untouched and no plugins are added.

What changed

  • nx.json (new) — Nx workspace config with the build target marked cacheable.
  • package.json — adds an nx devDependency and an empty "nx": {} field. Scripts unchanged.
  • .gitignore — adds .nx/cache, .nx/workspace-data, .nx/migrate-runs.
  • Lockfile — updated by the nx init install step (or, for repos with no package.json, Nx adds a standalone .nx/ install: nx.json, .nx/nxw.js, nx, nx.bat).

Try it

nx build <project-name>     # run a task
nx build <project-name>     # again - instant cache hit
nx run-many -t build test   # run tasks across all projects
nx graph                    # visualize project dependencies

Verification

  • nx init ran non-interactively; --plugins=skip was honored (no plugins in nx.json).
  • Confirmed on a representative repo: nx run-many -t build succeeds, and a second run is a 100% cache hit.

Notes

  • No plugins, no restructuring, no CI changes.
  • Merge this branch to enable Nx; nothing else is required.

This PR was created by an AI agent (OpenHands) on behalf of @ashcoft.


Devin Review


This change is Reviewable

Summary by Sourcery

Enable incremental Nx adoption for task running and caching without restructuring the project.

New Features:

  • Add Nx task execution and caching support with a cacheable build target.

Enhancements:

  • Provide a checked-in Nx wrapper that synchronizes the local Nx installation with the workspace configuration.
  • Configure the workspace to use the existing project structure without adding plugins or changing existing scripts.

Chores:

  • Ignore generated Nx cache and workspace data files.

Summary by CodeRabbit

  • New Features
    • Added launchers for macOS/Linux and Windows that check for Node.js and npm, then run the project’s configured local Nx version.
    • The local Nx installation is synchronized with the versions configured for the project; installation errors are reported.
    • Enabled caching by default for build targets and set master as the default comparison base.
  • Chores
    • Updated ignore rules for additional Nx-generated files.

RetriggerView in GreptileConfidence Score: 4/5

Fix the launcher paths before merging so developers with spaces in their checkout paths can start Nx.

Fix All in CodexFindings

  1. P1 Spaces break the launchers ▶
  2. P2 Schema points to missing file ▶
Fix with agent prompt
### Issue 1
nx.bat:8
If the checkout path contains spaces, `nx.bat` passes it to `node` as separate arguments. For example, `C:\Users\Ada Smith\repo` makes Node try to load `C:\Users\Ada`, so Nx never starts. The Bash launcher has the same problem when called by an absolute path containing spaces.

Quote the script path in `nx.bat`. In `nx`, quote both `$BASH_SOURCE` and the script path passed to `node`.

### Issue 2
nx.json:5
`$schema` points to root-level `node_modules`, but the wrapper installs Nx under `.nx/installation/node_modules`. There is no root `package.json` to create the referenced file. Editors therefore cannot load the schema, even after Nx is installed, so contributors lose schema-based checks and suggestions.

Point `$schema` to the standalone installation's schema or a published schema URL.

```suggestion
  "$schema": "./.nx/installation/node_modules/nx/schemas/nx-schema.json",
```

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds a standalone Nx installation with launchers for Bash and Windows.

  • Contributors can run the repo-pinned Nx task runner.

Reviews (1) · Last reviewed commit: "chore: add Nx" · Reviewed by Greptile


Summary by cubic

Adds Nx to enable task running and caching without restructuring the project. Uses a standalone Nx wrapper that syncs its version with nx.json, marks build targets as cacheable, and leaves existing scripts and configuration untouched.

  • Adds nx.json, nx/nx.bat launchers for Bash and Windows, and the .nx/nxw.js wrapper.
  • Sets build targets to cache by default and master as the default base branch.
  • Ignores Nx's installation, cache, and workspace data directories.