Skip to content

build: parallelize engine builds with turbo#8716

Merged
kpal81xd merged 23 commits into
mainfrom
build/parallel-cached-engine-build
May 12, 2026
Merged

build: parallelize engine builds with turbo#8716
kpal81xd merged 23 commits into
mainfrom
build/parallel-cached-engine-build

Conversation

@kpal81xd
Copy link
Copy Markdown
Contributor

@kpal81xd kpal81xd commented May 11, 2026

Supersedes #8357.

Important

Watch mode is intentionally out of scope for this PR. It remains on the existing single Rollup watcher (node build.mjs --watch) and will be addressed in a follow-up build-system/watch PR.

Summary

Parallelizes the engine build pipeline with Turbo for completed build tasks. Also simplifies Rollup target generation so minified builds no longer depend on generated release artifacts.

Changes

  • Move aggregate build orchestration into turbo.json
  • Add explicit --type and --format build options
  • Rename build types to concise task names: rel, dbg, prf, min
  • Simplify Rollup target generation by removing the in-memory HISTORY dependency flow
  • Emit bundled and preserved-module ESM outputs from one Rollup target
  • Minify through a Rollup output plugin so min tasks build directly from source
  • Keep clean as an explicit utility script without making Turbo build tasks depend on it
  • Keep tree visualizer scripts generating both ESM and UMD graphs by default
  • Clean Rollup output when running through Turbo so logs keep the Turbo task prefix
  • Keep generated output filenames unchanged

Build timings

Clean sequential timings with build/ and .turbo/ removed before each run.

Build Old New Improvement
full build 32.53s 12.77s 60.7%
release / rel aggregate 7.71s 5.73s 25.7%
debug / dbg aggregate 8.43s 5.78s 31.4%
profiler / prf aggregate 7.96s 5.39s 32.3%
umd aggregate 11.31s 6.34s 43.9%
esm aggregate 14.42s 7.96s 44.8%

Public API changes

No engine runtime API changes.

Developer-facing npm script migrations:

Old script New script
build:release build:rel:umd, build:rel:esm
build:debug build:dbg:umd, build:dbg:esm
build:profiler build:prf:umd, build:prf:esm
build:umd build:rel:umd, build:dbg:umd, build:prf:umd, build:min:umd
build:esm build:rel:esm, build:dbg:esm, build:prf:esm, build:min:esm
build:esm:release build:rel:esm
build:esm:debug build:dbg:esm

New npm script: clean.

build.mjs now accepts --type <rel|dbg|prf|min|types> and --format <esm|umd>, with rel and esm as the defaults for regular builds. Tree visualizer flags default to both formats when --format is omitted.

Manual tests

  • npm run build:treemap (verified treemap.es.html and treemap.umd.html)
  • Parsed turbo.json and asserted no build task depends on clean
  • node --check build.mjs
  • npm run lint

@kpal81xd kpal81xd self-assigned this May 11, 2026
@kpal81xd kpal81xd added the enhancement Request for a new feature label May 11, 2026
@kpal81xd kpal81xd mentioned this pull request May 11, 2026
3 tasks
@kpal81xd kpal81xd force-pushed the build/parallel-cached-engine-build branch from d9662a7 to adc17e4 Compare May 11, 2026 13:01
@kpal81xd kpal81xd marked this pull request as ready for review May 11, 2026 13:14
@kpal81xd kpal81xd requested a review from a team May 11, 2026 13:14
@mvaligursky mvaligursky requested a review from Copilot May 11, 2026 13:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR parallelizes the PlayCanvas engine build pipeline by moving build orchestration into Turbo, allowing independent Rollup targets (UMD/ESM/types and rel/dbg/prf/min variants) to run concurrently instead of being coordinated by a single serial build process.

Changes:

  • Introduces turbo.json to define build task graph (aggregate tasks + leaf targets) and adds Turbo as a dev dependency.
  • Refactors build.mjs to a typed CLI (--type, --format, --watch, --sourcemaps, tree visualizer flags) and updates Rollup environment wiring accordingly.
  • Renames build types (release/debug/profilerrel/dbg/prf) across build utilities and example build config, and updates npm scripts/watch aliases.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utils/rollup-build-target.mjs Renames build types and adds a bundleSource option to support minifying from a previously-generated rel bundle.
turbo.json Adds Turbo task graph describing build aggregates and leaf build outputs for caching/parallelism.
rollup.config.mjs Switches Rollup target selection to process.env.build / process.env.bundleSource and updates build-type naming.
package.json Adds Turbo + packageManager, rewires build/watch scripts to Turbo and new build.mjs flags, updates build-type naming.
package-lock.json Locks Turbo and its optional platform binaries.
examples/rollup.config.mjs Updates example engine build targets to use rel/dbg/prf build type names.
build.mjs Replaces legacy env-arg forwarding with a typed CLI + spawn-based Rollup runner and output “cleaning”.
.gitignore Ignores the .turbo directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build.mjs
Comment thread rollup.config.mjs
Comment thread build.mjs Outdated
Comment thread build.mjs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Comment thread build.mjs Outdated
Comment thread utils/rollup-build-target.mjs Outdated
Comment thread utils/rollup-build-target.mjs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Comment thread package.json
Comment thread turbo.json Outdated
@kpal81xd kpal81xd force-pushed the build/parallel-cached-engine-build branch from 2724e78 to f499bb2 Compare May 12, 2026 09:18
@kpal81xd kpal81xd merged commit 19b9498 into main May 12, 2026
8 checks passed
@kpal81xd kpal81xd deleted the build/parallel-cached-engine-build branch May 12, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants