Skip to content

Commit 72e4fd0

Browse files
authored
feat: Add moonrepo support (#19)
* feat: Add moonrepo support - Add moonrepo configuration files (.moon/workspace.yml, .moon/toolchain.yml, .moon/tasks/node.yml) - Update benchmark-json.ts to include moonrepo benchmarking - Update TypeScript types to include moon tool - Add moonrepo as devDependency in package.json - Update README.md to include moonrepo in benchmarks - Update comparison scripts to handle moonrepo results - Update release scripts to include moonrepo version info Closes #18 * chore: Update project configuration and package structure - Add new entries to .gitignore for moon executables and lerna logs - Update .prettierignore to include .nx/cache - Enable caching in nx.json build configuration - Set package manager to pnpm@10.10.0 and node engine to 22.9.0 in package.json - Update pnpm workspace to include '@moonrepo/cli' and 'sharp' as built dependencies - Change main and types paths in multiple package.json files from './index.ts' to './src/index.ts' - Remove unused readme assets (turbo-nx-perf.gif, turbo-nx-terminal.gif) - Update TypeScript types in scripts/types.ts to include comparisons field * feat: Enhance benchmarking consistency and error handling - Introduced Nx-specific environment variables to ensure consistent benchmarking across runs. - Refactored command execution to include a fallback mechanism for handling SQLite failures during benchmarks. - Updated documentation in the README to clarify benchmarking instructions.
1 parent 6b0db8e commit 72e4fd0

File tree

145 files changed

+11151
-2605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+11151
-2605
lines changed

.cursor/mcp.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mcpServers": {
3+
"nx-mcp": {
4+
"url": "http://localhost:9252/sse"
5+
}
6+
}
7+
}

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@ turbo-build.log
5050

5151
# Release automation files
5252
release-description.md
53+
54+
.cursor/rules/nx-rules.mdc
55+
.github/instructions/nx.instructions.md
56+
57+
# moon
58+
.moon/cache
59+
.moon/docker
60+
packages/*/moon
61+
packages/*/moon.exe
62+
/moon
63+
/moon.exe
64+
65+
lerna-*.log

.moon/tasks/app.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$schema: 'https://moonrepo.dev/schemas/tasks.json'
2+
3+
# Task definitions for Next.js applications
4+
tasks:
5+
# Build task for Next.js applications
6+
build:
7+
command: 'next build'
8+
inputs:
9+
- 'src/**/*'
10+
- 'pages/**/*'
11+
- 'components/**/*'
12+
- 'styles/**/*'
13+
- 'public/**/*'
14+
- 'next.config.js'
15+
- 'package.json'
16+
- 'tsconfig.json'
17+
outputs:
18+
- '.next/**/*'
19+
options:
20+
cache: true
21+
22+
# Development server
23+
dev:
24+
command: 'next dev'
25+
local: true
26+
options:
27+
cache: false
28+
29+
# Start production server
30+
start:
31+
command: 'next start'
32+
deps: ['build']
33+
local: true
34+
options:
35+
cache: false

.moon/tasks/lib.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$schema: 'https://moonrepo.dev/schemas/tasks.json'
2+
3+
# Task definitions for TypeScript libraries
4+
tasks:
5+
# Build task for TypeScript libraries (type checking)
6+
build:
7+
command: 'tsc'
8+
args: ['--noEmit', '--skipLibCheck']
9+
inputs:
10+
- 'src/**/*'
11+
- 'index.ts'
12+
- 'package.json'
13+
- 'tsconfig.json'
14+
- 'tsconfig.lib.json'
15+
options:
16+
cache: true

.moon/tasks/node.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$schema: 'https://moonrepo.dev/schemas/tasks.json'
2+
3+
# Task definitions for Node.js projects
4+
tasks:
5+
# Build task for Next.js applications
6+
build:
7+
command: 'next build'
8+
inputs:
9+
- 'src/**/*'
10+
- 'pages/**/*'
11+
- 'components/**/*'
12+
- 'styles/**/*'
13+
- 'public/**/*'
14+
- 'next.config.js'
15+
- 'package.json'
16+
- 'tsconfig.json'
17+
outputs:
18+
- '.next/**/*'
19+
options:
20+
cache: true
21+
22+
# Development server
23+
dev:
24+
command: 'next dev'
25+
local: true
26+
options:
27+
cache: false
28+
29+
# Start production server
30+
start:
31+
command: 'next start'
32+
deps: ['build']
33+
local: true
34+
options:
35+
cache: false

.moon/toolchain.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$schema: 'https://moonrepo.dev/schemas/toolchain.json'
2+
3+
# Node.js configuration
4+
node:
5+
version: '22.9.0'
6+
packageManager: 'pnpm'
7+
8+
# Performance optimizations
9+
dedupeOnLockfileChange: true
10+
syncProjectWorkspaceDependencies: true
11+
12+
# Use workspace protocol for dependencies
13+
dependencyVersionFormat: 'workspace'
14+
15+
# Add engines constraint to package.json
16+
addEnginesConstraint: true
17+
18+
# Sync package manager field in package.json
19+
syncPackageManagerField: true
20+
21+
# PNPM configuration
22+
pnpm:
23+
version: '10.10.0'
24+
installArgs: ['--frozen-lockfile']

.moon/workspace.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$schema: 'https://moonrepo.dev/schemas/workspace.json'
2+
3+
# Disable auto-discovery to prevent conflicts
4+
projects:
5+
globs:
6+
- './apps/*'
7+
8+
vcs:
9+
provider: 'github'
10+
defaultBranch: 'main'
11+
12+
notifier:
13+
terminalNotifications: 'always'
14+
experiments:
15+
fasterGlobWalk: true
16+
gitV2: true

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/dist
44
/coverage
55

6-
/.nx/workspace-data
6+
/.nx/workspace-data
7+
/.nx/cache

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"typescript.tsserver.maxTsServerMemory": 8192,
33
"typescript.tsserver.nodePath": "node",
4-
"typescript.tsdk": "node_modules/typescript/lib"
4+
"typescript.tsdk": "node_modules/typescript/lib",
5+
"nxConsole.generateAiAgentRules": true
56
}

README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Benchmarking Nx, Turbo, Lerna, and Lage
2-
<!--
3-
Recording:
4-
5-
![nx-turbo-recording](./readme-assets/turbo-nx-perf.gif) -->
1+
# Benchmarking Nx, Turbo, Lerna, Lage, and Moon
62

73
Repo contains:
84

@@ -12,33 +8,46 @@ Repo contains:
128

139
Combined there are about 26k components. It's a lot of components, but they are very small. This corresponds to a medium
1410
size enterprise repo. A lot of our clients have repos that are 10x bigger than this, so this repo isn't something out or
15-
ordinary. And, the bigger the repo, the bigger the difference in performance between Nx and Turbo.
11+
ordinary. And, the bigger the repo, the bigger the difference in performance between Nx and other tools.
1612

17-
The repo has Nx, Turbo, Lerna and Lage enabled. They don't affect each other. You can remove one without affecting the
18-
other one.
13+
The repo has Nx, Turbo, Lerna, Lage, and Moon enabled. They don't affect each other. You can remove one without affecting the
14+
others.
1915

20-
## Benchmark & Results (June 24, 2025)
16+
## Benchmark & Results (January 2025)
2117

2218
Run `pnpm run benchmark`. The benchmark will warm the cache of all the tools. We benchmark how quickly
23-
Turbo/Nx/Lage/Lerna can figure out what needs to be restored from the cache and restores it.
19+
Turbo/Nx/Lage/Lerna/Moon can figure out what needs to be restored from the cache and restores it.
2420

2521
These are the numbers using GitHub Actions runner:
2622

2723
* average lage time is: 11830.6
2824
* average turbo time is: 9992.2
2925
* average lerna (powered by nx) time is: 3407.0
26+
* average moon time is: TBD (pending benchmark)
3027
* average nx time is: 1849.4
3128
* nx is 6.4x faster than lage
3229
* nx is 5.4x faster than turbo
3330
* nx is 1.8x faster than lerna (powered by nx)
31+
* nx vs moon performance comparison: TBD
32+
33+
### About Moon
34+
35+
[Moon](https://moonrepo.dev/) is a Rust-based build system and monorepo management tool that focuses on performance and developer experience. Key features include:
36+
37+
* **Performance**: Written in Rust for maximum speed and efficiency
38+
* **Smart Caching**: Advanced caching mechanisms with remote caching support
39+
* **Task Pipeline**: Efficient task orchestration with dependency management
40+
* **Language Support**: Multi-language support including Node.js, Python, Rust, and more
41+
* **Configuration**: YAML-based configuration with intelligent defaults
42+
* **Incremental Building**: Only builds what's changed for faster development cycles
3443

3544
### Does this performance difference matter in practice?
3645

37-
The cache restoration Turborepo provides is likely to be fast enough for a lot of small and mid-size repos.
46+
The cache restoration that tools like Turborepo and Moon provide is likely to be fast enough for a lot of small and mid-size repos.
3847
What matters more is the ability to distribute any command across say 50 machines while
3948
preserving the dev ergonomics of running it on a single machine. Nx can do it. Bazel can do it (which Nx
4049
borrows some
41-
ideas from). Turbo can't. This is where the perf gains are for larger repos.
50+
ideas from). Moon supports remote caching which enables distributed builds. This is where the perf gains are for larger repos.
4251
See [this benchmark](https://github.com/vsavkin/interstellar) to learn more.
4352

4453
## Dev ergonomics & Staying out of your way
@@ -48,8 +57,6 @@ faster, but Turbo is built to stay out of you way". Let's talk about staying out
4857

4958
Run `nx build crew --skip-nx-cache` and `turbo run build --scope=crew --force`:
5059

51-
![terminal outputs](./readme-assets/turbo-nx-terminal.gif)
52-
5360
Nx doesn't change your terminal output. Spinners, animations, colors are the same whether you use Nx or not (we
5461
instrument Node.js to get this result). What is also important is that when you restore things from cache, Nx will
5562
replay the terminal output identical to the one you would have had you run the command.
@@ -128,7 +135,7 @@ The automation scripts are built with TypeScript for better type safety and deve
128135
The repository uses:
129136

130137
* **Dependabot**: For automated dependency PRs
131-
* **Daily Update Workflow**: Aggressive updates to ensure we're testing latest versions
138+
* **Daily Update Workflow**: Aggressive updates to ensure we're testing latest versions (nx, turbo, lerna, lage, moonrepo)
132139
* **Compatibility Testing**: Benchmarks run after updates to ensure everything works
133140

134141
### 📈 Performance Tracking

0 commit comments

Comments
 (0)