Skip to content

Redo the buildchain with vite#718

Merged
danopia merged 5 commits intomainfrom
build-with-vite
Oct 2, 2025
Merged

Redo the buildchain with vite#718
danopia merged 5 commits intomainfrom
build-with-vite

Conversation

@danopia
Copy link
Member

@danopia danopia commented Aug 20, 2024

Clear out almost all the create-react-app stuff since it's effectively an abandoned project and is starting to age on a dependency and technical level.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

This change migrates the React frontend from CRA/Webpack/Jest to Vite. It removes CRA-specific configs and scripts (webpack, dev server, Jest transforms, env/modules/paths utilities, build/start/test scripts) and adds Vite config, a new index.html, and a new ESLint config. Package scripts and dependencies are updated accordingly. The Dockerfile splits yarn install from build and removes frontend tests. React rendering is updated to createRoot. Minor component tweaks adjust props and event handler signatures. TypeScript ambient declarations and Jest setup are removed. The Go webserver switches static handling from /pub to /assets with hashed asset serving and explicit routes for common static files.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Broad build-system migration with many deletions and new configs, plus webserver routing changes. Although many files are removed wholesale, reviewers must verify Vite parity (index.html, asset handling, environment usage), package.json/scripts, Dockerfile flow, and the Go server’s new static/asset paths and caching semantics. Frontend code edits are small but need sanity checks. Changes are heterogeneous across JS/TS, HTML, Docker, and Go, requiring cross-cutting validation.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Redo the buildchain with vite” clearly and succinctly summarizes the primary change in the pull request, which replaces the Create React App/Webpack build setup with Vite. It directly reflects the main objective without extraneous detail or ambiguity.
Description Check ✅ Passed The description accurately states that the pull request removes most Create React App configuration due to its age and dependency issues, which aligns with the extensive deletions of CRA files and introduction of Vite-based build tooling. It is directly related to the changeset.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch build-with-vite

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@danopia danopia marked this pull request as ready for review October 2, 2025 09:49
@danopia danopia merged commit e9e07fc into main Oct 2, 2025
8 of 10 checks passed
@danopia danopia deleted the build-with-vite branch October 2, 2025 09:53
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
build/react-frontend/eslint.config.js (1)

1-28: LGTM! Consider updating ecmaVersion for modern features.

The ESLint config correctly uses the flat config format required for ESLint 9 and includes appropriate plugins for React/TypeScript/Vite development.

Consider updating ecmaVersion from 2020 to 'latest' or 2023 to support modern JavaScript features:

     languageOptions: {
-      ecmaVersion: 2020,
+      ecmaVersion: 'latest',
       globals: globals.browser,
     },
build/react-frontend/src/index.jsx (1)

4-7: LGTM! Correct React 18 createRoot migration.

The migration from ReactDOM.render to createRoot correctly follows React 18 API patterns. The code properly obtains the container, creates a root, and renders the app.

Consider wrapping <App /> with <StrictMode> to surface React 18.3's new deprecation warnings during development:

+import { StrictMode } from 'react';
 import { createRoot } from 'react-dom/client';
 const container = document.getElementById('root');
 const root = createRoot(container);
-root.render(<App />);
+root.render(
+  <StrictMode>
+    <App />
+  </StrictMode>
+);

Based on learnings: React 18.3.0 adds deprecation warnings to prepare for React 19, and StrictMode helps surface these warnings during development.

internal/webserver/webserver.go (1)

111-116: Consider adding Cache-Control headers for public static files.

The static file serving is functionally correct. However, unlike the /assets/ handler (which sets explicit caching policies), these routes rely on default browser caching behavior.

For better cache control:

  • manifest.json, robots.txt: Cache-Control: public, no-cache (revalidate on each use)
  • logo192.png, logo512.png, favicon.ico: Cache-Control: public, max-age=86400 (1 day with revalidation)

Example refactor for explicit caching:

 staticServer := http.FileServer(http.Dir("./web/react-frontend"))
-r.HandleFunc("/manifest.json", staticServer.ServeHTTP)
-r.HandleFunc("/robots.txt", staticServer.ServeHTTP)
-r.HandleFunc("/logo192.png", staticServer.ServeHTTP)
-r.HandleFunc("/logo512.png", staticServer.ServeHTTP)
-r.HandleFunc("/favicon.ico", staticServer.ServeHTTP)
+
+staticHandler := func(cacheControl string) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		w.Header().Add("Cache-Control", cacheControl)
+		staticServer.ServeHTTP(w, r)
+	}
+}
+r.HandleFunc("/manifest.json", staticHandler("public, no-cache"))
+r.HandleFunc("/robots.txt", staticHandler("public, no-cache"))
+r.HandleFunc("/logo192.png", staticHandler("public, max-age=86400"))
+r.HandleFunc("/logo512.png", staticHandler("public, max-age=86400"))
+r.HandleFunc("/favicon.ico", staticHandler("public, max-age=86400"))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f19a56b and 2fbdaf5.

⛔ Files ignored due to path filters (1)
  • build/react-frontend/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (26)
  • build/package/Dockerfile (1 hunks)
  • build/react-frontend/config/env.js (0 hunks)
  • build/react-frontend/config/getHttpsConfig.js (0 hunks)
  • build/react-frontend/config/jest/babelTransform.js (0 hunks)
  • build/react-frontend/config/jest/cssTransform.js (0 hunks)
  • build/react-frontend/config/jest/fileTransform.js (0 hunks)
  • build/react-frontend/config/modules.js (0 hunks)
  • build/react-frontend/config/paths.js (0 hunks)
  • build/react-frontend/config/webpack.config.js (0 hunks)
  • build/react-frontend/config/webpack/persistentCache/createEnvironmentHash.js (0 hunks)
  • build/react-frontend/config/webpackDevServer.config.js (0 hunks)
  • build/react-frontend/eslint.config.js (1 hunks)
  • build/react-frontend/index.html (1 hunks)
  • build/react-frontend/package.json (1 hunks)
  • build/react-frontend/public/index.html (0 hunks)
  • build/react-frontend/scripts/build.js (0 hunks)
  • build/react-frontend/scripts/start.js (0 hunks)
  • build/react-frontend/scripts/test.js (0 hunks)
  • build/react-frontend/src/Components/EnhancedTableHead/EnhancedTableHead.jsx (2 hunks)
  • build/react-frontend/src/Components/TextPage/TextPage.jsx (1 hunks)
  • build/react-frontend/src/index.jsx (1 hunks)
  • build/react-frontend/src/lib/rollback-api.ts (1 hunks)
  • build/react-frontend/src/react-app-env.d.ts (0 hunks)
  • build/react-frontend/src/setupTests.js (0 hunks)
  • build/react-frontend/vite.config.js (1 hunks)
  • internal/webserver/webserver.go (1 hunks)
💤 Files with no reviewable changes (16)
  • build/react-frontend/public/index.html
  • build/react-frontend/config/webpack/persistentCache/createEnvironmentHash.js
  • build/react-frontend/config/webpackDevServer.config.js
  • build/react-frontend/config/env.js
  • build/react-frontend/scripts/build.js
  • build/react-frontend/src/react-app-env.d.ts
  • build/react-frontend/scripts/test.js
  • build/react-frontend/scripts/start.js
  • build/react-frontend/src/setupTests.js
  • build/react-frontend/config/jest/cssTransform.js
  • build/react-frontend/config/paths.js
  • build/react-frontend/config/jest/fileTransform.js
  • build/react-frontend/config/modules.js
  • build/react-frontend/config/getHttpsConfig.js
  • build/react-frontend/config/jest/babelTransform.js
  • build/react-frontend/config/webpack.config.js
🧰 Additional context used
🧬 Code graph analysis (1)
internal/webserver/webserver.go (1)
internal/utility/cache-control.go (1)
  • UncachedErrorWriter (8-11)
🔇 Additional comments (11)
build/react-frontend/src/lib/rollback-api.ts (1)

161-172: LGTM! Modern global reference usage.

The replacement of window with globalThis is correct and aligns with modern JavaScript best practices. While both are equivalent in browser contexts, globalThis is the standardized ECMAScript global object reference that works across all JavaScript environments.

For browser-only code like this React app, window would also be perfectly valid, but using globalThis is a sound choice that aligns with the Vite migration's modernization efforts.

build/react-frontend/src/Components/TextPage/TextPage.jsx (1)

25-25: LGTM! Correct Material-UI variant usage.

body1 is the standard Material-UI Typography variant for body text. The previous variant="p" was not a documented variant in Material-UI v4.

build/package/Dockerfile (1)

13-15: Verify test coverage is maintained outside Docker build.

The separation of yarn install and yarn build improves Docker layer caching. However, the removal of yarn test from the Docker build means frontend tests are no longer run during the image build process.

Confirm that frontend tests are executed in your CI/CD pipeline before merging, as the migration from CRA to Vite removed Jest-based test infrastructure.

build/react-frontend/package.json (4)

5-5: LGTM! Required for Vite's ES module support.

Adding "type": "module" enables ES modules in the package, which is required for Vite's default configuration and build system.


28-33: LGTM! Vite scripts correctly configured.

The scripts correctly migrate from react-scripts to Vite commands. Note that no test script is present, which aligns with the removal of Jest-based testing infrastructure as part of the CRA migration.


20-20: LGTM! Self-hosted font addition.

Adding @fontsource/inter provides self-hosted font files, improving performance and privacy compared to CDN-hosted fonts.


11-17: @vitejs/plugin-react v4.3.1 is compatible with Vite 5.4.1.

build/react-frontend/index.html (1)

1-21: LGTM! Correct Vite HTML entry point.

The HTML structure is correctly configured for Vite:

  • Module script with /src/index.jsx entry point
  • Root-relative asset paths that Vite will resolve
  • Proper meta tags and static asset links
build/react-frontend/vite.config.js (1)

1-11: LGTM! Minimal but correct Vite configuration.

The Vite config correctly:

  • Uses defineConfig for type safety
  • Sets outDir: 'build' to match Docker expectations (line 24 in Dockerfile)
  • Includes the React plugin for JSX/Fast Refresh support
build/react-frontend/src/Components/EnhancedTableHead/EnhancedTableHead.jsx (1)

7-9: Approve createSortHandler refactor
Verified that both handleRequestSort (in ReleaseDetails) and setReleaseOrder (from useSortState in ReleaseList) accept only a single property argument, so dropping the event parameter is safe.

internal/webserver/webserver.go (1)

100-109: LGTM! Asset serving strategy aligns well with Vite.

The hashed assets are correctly served with immutable caching, and the UncachedErrorWriter wrapper appropriately loosens caching on 404s to prevent mixed-fleet cache poisoning during deployments.

key={headCell.id}
align={headCell.numeric ? 'right' : 'left'}
padding={headCell.disablePadding ? 'none' : 'default'}
padding={headCell.disablePadding ? 'none' : 'normal'}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Incorrect padding value for Material-UI v4.

The padding prop value 'normal' is not valid in Material-UI v4. Valid values are 'default', 'checkbox', or 'none'. The value 'normal' was introduced in Material-UI v5.

Since package.json specifies @material-ui/core@^4.12.4, this will cause a runtime warning or incorrect rendering.

Apply this diff to fix:

-            padding={headCell.disablePadding ? 'none' : 'normal'}
+            padding={headCell.disablePadding ? 'none' : 'default'}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
padding={headCell.disablePadding ? 'none' : 'normal'}
padding={headCell.disablePadding ? 'none' : 'default'}
🤖 Prompt for AI Agents
In build/react-frontend/src/Components/EnhancedTableHead/EnhancedTableHead.jsx
around line 18, the padding prop currently uses 'normal' which is invalid for
Material-UI v4; change the non-none value to 'default' so the prop becomes
padding={headCell.disablePadding ? 'none' : 'default'} to match
@material-ui/core@^4.12.4 valid values and avoid runtime warnings.

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