Skip to content

Switch the main application build from webpack to Vite (Vite prep 5/N)#856

Draft
dtinth-claw[bot] wants to merge 3 commits into
masterfrom
chore/vite-switch
Draft

Switch the main application build from webpack to Vite (Vite prep 5/N)#856
dtinth-claw[bot] wants to merge 3 commits into
masterfrom
chore/vite-switch

Conversation

@dtinth-claw

@dtinth-claw dtinth-claw Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

The Vite switch — 5/N of the piecewise migration. Prep PRs 1–4 removed the source's webpack-specific assumptions; this one flips the actual build tool.

  • Scripts: buildvite build (webpack preserved as build:webpack), devvite, and rush dev now points at the Vite dev server.
  • bemuse/vite.config.ts (new): pug (.jade), pegjs, and JSX-in-.js transforms; an SSI <!--#include--> plugin for index.html; node polyfills (process/Buffer/util/…); scss loadPaths; a VitePWA/workbox config mirroring the old ServiceWorkerPlugin; and CommonJS interop for the linked workspace packages (bms, bemuse-notechart, …).
  • Webpack-only constructs replaced:
    • require.contextimport.meta.glob (devtools/playground.js, test/loadSpecs.js)
    • module.hotimport.meta.hot
    • val-loader! version/scoreboard injection → Vite define (__BEMUSE_VERSION__, __SCOREBOARD_SERVER__)
    • dynamic require('…/game-loader')await import(…)
  • In-browser tests: the ?mode=test Mocha suite runs under Vite; rushx test drives it headlessly (scripts/run-browser-tests.mjs) and CI runs it.
  • Generated pegjs parser: bin/build-parser.js now emits an ES module (export default …) instead of CommonJS, so the committed parser.js resolves natively under Rollup without commonjs interop. (The tidy staleness check regenerates identical output.)

Not in this PR (follow-ups)

  • The pre-deploy "boot script inlined" gate is temporarily continue-on-error — the Vite entry is a hashed ES module, not an inlined <script>. Reinstating the deploy pipeline for Vite is the next PR.
  • Removing webpack entirely (build:webpack, the config/webpack*.js, karma) once we've lived on Vite for a bit.

Verification (Node 24)

  • rushx build (vite) → green; PWA precache generated.
  • rushx typecheck → green.
  • rushx test (?mode=test, headless) → 310 passed, 1 pending, 0 failed.
  • build-scripts build:dist → 604 files, no collisions.
  • Full e2e against the Vite dist15 passed, 1 skipped.

Opening as a draft — it's a large, atomic switch. Happy to split further (e.g. peel the ?mode=test runner or the parser-format change into their own PRs) if that's easier to review.

🤖 Generated with Claude Code

https://claude.ai/code/session_014Wv1XChhvMw5LwiVDv3NWh

@codecov-commenter

codecov-commenter commented Jul 24, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.54%. Comparing base (4722ff7) to head (e47966f).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #856   +/-   ##
=======================================
  Coverage   95.54%   95.54%           
=======================================
  Files          39       39           
  Lines         673      673           
  Branches       65       65           
=======================================
  Hits          643      643           
  Misses         15       15           
  Partials       15       15           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

🔎 Preview deploy for this PR: https://previews.bemuse.ninja/pr-856/index.html

Updated for commit 289e322. Assets are shared at the bucket root (content-hashed); only index.html is per-PR. The whole previews.bemuse.ninja domain is noindex via robots.txt.

@sonarqubecloud

Copy link
Copy Markdown

@dtinth-claw dtinth-claw Bot mentioned this pull request Jul 24, 2026
dtinth-claw Bot and others added 3 commits July 24, 2026 19:21
Flip the app's build tool to Vite, the culmination of the vite-prep series.

- `build` → `vite build` (webpack kept as `build:webpack`); `dev` → `vite`;
  `rush dev` points at the Vite dev server.
- `bemuse/vite.config.ts`: pug/pegjs/JSX-in-.js transforms, SSI include for
  index.html, node polyfills (process/Buffer/util/...), scss loadPaths, PWA
  (workbox) mirroring the old ServiceWorkerPlugin, and CJS interop for the
  linked workspace packages.
- Replace webpack-only constructs: `require.context` → `import.meta.glob`
  (playground + spec loader), `module.hot` → `import.meta.hot`, the val-loader
  version/config injection → Vite `define` (__BEMUSE_VERSION__ etc.), and the
  dynamic `require()` in game-launcher → `await import()`.
- In-browser test suite runs under Vite via `?mode=test`; `rushx test` drives
  it headlessly (scripts/run-browser-tests.mjs) and CI runs it.
- Generate the committed pegjs parser as an ES module (`export default`) so it
  resolves natively under Vite/Rollup without commonjs interop.

The pre-deploy "boot script inlined" gate is temporarily non-blocking (the
entry is now a hashed ES module); it will be reinstated when the deploy
pipeline is ported. Verified: vite build, typecheck, in-browser tests
(310 passed / 1 pending), and the full e2e suite (15 passed / 1 skipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Wv1XChhvMw5LwiVDv3NWh
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Wv1XChhvMw5LwiVDv3NWh
SonarCloud flagged the bare Array.prototype.sort() (default sort is by UTF-16
code unit, not locale-aware) as a reliability bug.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Wv1XChhvMw5LwiVDv3NWh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant