Skip to content

Migrate welcome webapp from Create React App to Vite - #22

Merged
lagergren merged 2 commits into
masterfrom
webapp-vite-migration
Sep 25, 2026
Merged

lagergren merged 2 commits into
masterfrom
webapp-vite-migration

Conversation

@lagergren

@lagergren lagergren commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The welcome webapp was built with Create React App (react-scripts 5.0.1). CRA is deprecated and 5.0.1 is its final release. Its pinned transitive dependencies caused the npm deprecation warnings in the CI log (svgo@1.3.2, source-map-resolve@0.6.0) and all 80 npm audit findings (6 critical, 37 high). Updating dependency versions can't remove them, so this PR replaces CRA with Vite, the replacement the React docs recommend.

Changes

  • package.json: react-scripts replaced by vite 8.3.1 and @vitejs/plugin-react 6.1.1. React 18 → 19.3. Scripts are now dev/build/preview; Gradle still calls npm run build.
  • public/index.html moved to webapp/index.html, the Vite entry point, with an explicit <script type="module" src="/src/index.jsx">. %PUBLIC_URL% references replaced by /; the app is served at /, so the resulting URLs are the same.
  • App.js/index.js renamed to .jsx (Vite only treats .jsx files as JSX). No code changes.
  • New vite.config.js with outDir: 'build', so welcome.x (@StaticContent("/", /build)) and the buildWebapp output in webapp-conventions stay unchanged.
  • webapp-conventions.gradle.kts: index.html and vite.config.js added as buildWebapp inputs, so editing either triggers a rebuild.
  • Removed CRA leftovers:
    • src/App.test.js: CRA boilerplate that looked for "learn react", text the app doesn't render. Nothing ever ran it.
    • The testing-library and web-vitals dependencies. web-vitals wasn't imported anywhere.
    • The eslintConfig/browserslist settings, which only CRA read.

Result: the npm install drops from ~1,400 packages to 19, prints no deprecation warnings, and npm audit reports 0 vulnerabilities. The lockfile was regenerated with npm 11.6.2, the version the build pins.

Verification

  • ./gradlew clean, then ./gradlew build installDist :welcome:runXtc --warning-mode=all --max-workers=1 --no-build-cache: BUILD SUCCESSFUL. No npm warnings in the webapp build.

  • End-to-end on the XQIZ.IT platform (built from xtclang/platform master), comparing master (CRA) with this branch (Vite). Both builds were uploaded as welcome.examples.org and deployed as welcome. Headless Chrome loaded https://welcome.localhost.xqiz.it/ for each.

    master (CRA) this branch (Vite)
    Page + JS/CSS bundle 200 (/static/js/main.*.js, /static/css/main.*.css) 200 (/assets/index-*.js, /assets/index-*.css)
    /welcome/org, /welcome/info, /welcome/count 200 200
    Rendered text "Welcome to ! This is your N-th visit… How's the weather in your city?" identical
    Timer counts up / "Reset timer" resets it yes / yes yes / yes
    Console errors none none

    CI's :welcome:runXtc step only runs welcomeTest, the database console app. Nothing in CI loads this page, so the platform run above is the only check that the page itself works.

Differences in the build/ output

  • Bundles live in assets/ instead of static/js/static/css. The generated index.html references them with absolute paths, as before.
  • asset-manifest.json (CRA-specific) is no longer generated; nothing in the repo refers to it.
  • public/manifest.json still has CRA's sample name ("Create React App Sample"). Left as is to keep this PR focused.

Measured impact of the migration

master (CRA) this branch (Vite)
Packages installed (CI, Linux) 1,275 21
node_modules size (local) 289 MB 37 MB
npm audit 80 vulnerabilities (6 critical, 37 high) 0
npm deprecation warnings 2 0
CI :welcome:npmInstall ~19 s ~2 s
CI :welcome:buildWebapp ~12 s ~0.3 s
Local cold npm ci + build 4 s + 4 s 1 s + 1 s

The CI numbers come from Gradle task timestamps in the last master run and this PR's first run. The webapp used to take about 31 s of the "Build & test" job and now takes about 2.5 s. The whole job took 4m55s on this PR's first run versus 8–9 min on master, but most of that difference is Gradle build-cache hits: 3 of the 7 testXtc tasks were restored from cache, so 174 xunit tests ran instead of 280. Don't read that job time as a gain from the migration.

Why so few packages

react-scripts installed every tool a CRA project might use, whether this app used it or not: webpack plus its dev server, Babel with dozens of plugins, Jest with jsdom, ESLint with its plugins, PostCSS, workbox and svgo. Each of those is made of many small JavaScript packages. Vite 8 does its bundling with Rolldown (Rust) and CSS processing with Lightning CSS, and each arrives as one precompiled binary package for the platform. There's also no test runner, linter or offline-support tool left to install, because this app doesn't use them.

The full install is react, react-dom and scheduler; then vite, @vitejs/plugin-react, rolldown plus its native binding and helpers, and @oxc-project/types; then lightningcss plus its native binding and postcss; and a handful of small utilities (nanoid, picocolors, picomatch, fdir, tinyglobby, source-map-js, detect-libc). The lockfile has 19 packages; the exact count installed varies by OS because of platform-specific packages (21 on CI's Linux runner, 20 on macOS).

CI: parallel Gradle workers

This PR also removes the --max-workers=1 added in #20. The workaround was needed because the XTC xunit engine generated test modules into a single shared /tmp/xunit. xtclang/xvm#561 (merged 2026-08-31) moved them into each project's build/xunit/modules, and CI already runs with that fix: its logs show XUnit: Creating test module … in chess-game/app/build/xunit/modules.

Without the flag, Gradle uses one worker per CPU core. That's 4 on the standard GitHub-hosted runner for public repos, and org.gradle.parallel=true is already set in gradle.properties.

Local stress test: full build --rerun-tasks --no-build-cache runs on a 10-core Mac.

Workers Result xunit test classes finished OK Wall time
1 BUILD SUCCESSFUL 280 3m15s
4 BUILD SUCCESSFUL 280 2m28s
4 BUILD SUCCESSFUL 280 3m09s
10 BUILD SUCCESSFUL 280 3m35s
  • No failures in any run.
  • Nothing was written to /tmp/xunit.
  • The local timings vary too much to show a clear speed-up; locally the build appears dominated by a few long sequential chains. This PR's CI passes with parallel workers, but its timings are dominated by build-cache hits. A cache-off measurement of 1 vs. 4 workers on the CI runner is running separately and will be reported outside this PR.

xtclang/xvm#561 moved generated xunit test modules from a shared /tmp/xunit
into each project's build directory, so the --max-workers=1 workaround is
no longer needed.
@lagergren
lagergren merged commit bd63f5e into master Sep 25, 2026
2 checks passed
@lagergren
lagergren deleted the webapp-vite-migration branch September 25, 2026 12:20
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