Skip to content

build: migrate examples to vite#8729

Merged
kpal81xd merged 11 commits into
mainfrom
build/esbuild-vite-examples
May 15, 2026
Merged

build: migrate examples to vite#8729
kpal81xd merged 11 commits into
mainfrom
build/esbuild-vite-examples

Conversation

@kpal81xd
Copy link
Copy Markdown
Contributor

@kpal81xd kpal81xd commented May 15, 2026

Description

Migrate the examples browser build from Rollup/concurrently/serve to Vite and esbuild, while keeping the examples build commands routed through a single examples/build.mjs entry point.

  • Adds Vite for the examples app development server, preview server, and production app bundle.
  • Uses esbuild for bundled example support modules and the root engine esbuild helper for examples engine bundles.
  • Moves examples build helpers into examples/utils with clearer names and typed JSDoc.
  • Generates metadata before production builds, type checks, and thumbnail generation.
  • Splits examples TypeScript configs so app code and example code can be checked separately.
  • Makes the default examples development command disable automatic browser and iframe reloads.
  • Adds npm run dev for reload-enabled Vite development.
  • Preserves clean share preview routes such as /share/misc_hello-world and /share/misc_hello-world/.

npm scripts

Script Change
build Runs cross-env NODE_ENV=production node build.mjs.
build:metadata Runs node build.mjs --metadata.
build:thumbnails Runs node build.mjs --thumbnails.
clean Runs node build.mjs --clean.
dev Generates metadata and starts Vite with automatic reloads enabled.
develop Generates metadata and starts Vite with automatic reloads disabled.
serve Uses vite preview.
type:check Runs app and examples type checks.
type:check:app Generates metadata and checks app code with tsconfig.app.json.
type:check:examples Checks example code with tsconfig.examples.json.

The old Rollup watch flow was removed; Vite now handles development rebuilds.

Notes

  • Public engine API changes: none.
  • Examples output paths remain under examples/dist.
  • /, /playcanvas.d.ts, /iframe/*.html, and /share/* routes are preserved for preview output.
  • examples/scripts is removed; reusable build logic now lives in examples/utils.
  • npm run develop disables Vite HMR and suppresses the custom examples iframe reload event; manual browser refresh still serves updated files.
  • npm run dev keeps the reload-enabled Vite development behavior.
  • No examples Turbo tasks are added. Examples remain an isolated package rather than a root workspace package.
  • build:thumbnails is still available but continues to launch Puppeteer and write thumbnail output.

Build comparison

Area Main This branch Result
Files 1868 1869 Branch only adds root dist/playcanvas.d.ts.
Logical size 491.6 MB 489.8 MB Branch output is smaller overall.
Copied static/modules/share/thumbnails Byte-identical Byte-identical No copied asset differences found.
Example metadata 213 entries 213 entries Matches excluding temp worktree paths.
Engine iframe bundles Rollup output esbuild output Same bundle names; generated bundles are smaller on this branch.

Manual validation

  • Ran cd examples && npm run build:metadata.
  • Ran cd examples && npm run lint.
  • Ran cd examples && npm run type:check.
  • Ran cd examples && npm run build.
  • Ran cd examples && npm run dev -- --version.
  • Ran cd examples && npm run develop -- --version.
  • Config-loaded vite.config.mjs with EXAMPLES_AUTO_RELOAD=false and without it to confirm reloads default on and disable when requested.
  • Compared examples/dist output from main and this branch in detached worktrees; no files present on main were missing on this branch.
  • Smoke-tested Vite preview routes: /, /playcanvas.d.ts, /iframe/misc_hello-world.html, /static/lib/basis/basis.wasm.js, /share/misc_hello-world, /share/misc_hello-world/, and /share/misc_hello-world/index.html.
  • Rebased the branch onto current main after the engine build PR merged and force-pushed with lease.

Checklist

  • I have read the contributing guidelines
  • My code follows the project coding standards
  • This PR focuses on a single change

@kpal81xd kpal81xd merged commit a4cdaf3 into main May 15, 2026
8 checks passed
@kpal81xd kpal81xd deleted the build/esbuild-vite-examples branch May 15, 2026 16:16
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.

1 participant