Repository navigation
Move the build from Create React App to Vite - #99
Conversation
Create React App (react-scripts 5.0.1) is no longer maintained. It pins webpack-dev-server 4 and svgo 1, which have known CVEs. Vite replaces it. - Vite builds the site into build/, as before. The dev server stays on port 3000. - index.html moves from public/ to the repository root. - Env vars change from REACT_APP_* (process.env) to VITE_* (import.meta.env). The GitHub secret keeps its old name; the workflow maps it. - Node goes to 22.23.4 in .nvmrc and the workflow. Vite 8 needs 22.12 or newer. - An ESLint flat config replaces the CRA ESLint config. - Vitest replaces Jest for the one existing test file. - The Google Fonts @import moves to the top of index.css. Vite drops an @import that comes after other rules; CRA moved it up silently. - The apple-touch-icon link points to an image that exists. - Overrides for on-headers, serialize-javascript and uuid go away, because these packages are no longer installed. A new override pins postcss-selector-parser to 6.1.5. Addresses argotorg/sourcify#3035 (move sourcify.dev from Create React App to Vite). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for sourcify-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
manuelwedler
left a comment
There was a problem hiding this comment.
I checked out the branch: npm ci, npm run build, npm run lint (0 errors, 25 warnings) and npm test (12/12) all pass.
The main finding is that the Umami placeholder ships literally in dev and in Netlify previews (index.html). There is also a browser-support change from the new default Vite build target, and nothing runs the tests or lint automatically. The OpenRouter key in the bundle is an older issue and does not block this PR. The rest are nits.
Generated by Claude Code
- Add the Umami script only when VITE_UMAMI_WEBSITE_ID is set, through a small plugin in vite.config.mts. Set it to empty in .env.development and netlify.toml, so dev and previews load no analytics script. - Set build.target to the oldest browsers that the Create React App build supported (Chrome 109, Safari/iOS 15.6, Firefox 115). - Add a CI workflow for pull requests: lint, unit tests, build and Playwright smoke tests against the build. - Read VERIFY_URL from constants.ts everywhere. - Require Node.js 22.13 or newer (README and engines). - Remove nginx.conf, which only the old Docker setup used. - Type-check vite.config.mts and the Playwright files with tsconfig.node.json. Remove the duplicate vite/client reference. - Explain in release.yaml why the OpenRouter key is in the bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013vUbuRRw2eZLCJwQ4jY2VY
manuelwedler
left a comment
There was a problem hiding this comment.
I re-reviewed 748c3b5. All earlier comments are addressed, and I resolved the threads.
What I checked locally:
npm ci,npm run lint(0 errors),npm test(12/12), andnpm run build(which now also type-checkstsconfig.node.json) all pass.- Umami: a build without the id has no tag. A build with
.env.build.staginghas the tag with the rightdata-website-id. A build where the process env sets it to empty overrides.env, as the CI workflow expects. The deploy preview has no Umami tag and no%VITE_…%placeholder. - Browser target: today
>0.2%, not dead, not op_mini allresolves to chrome 109, edge 119, firefox 120 and ios_saf 15.6. The newbuild.targetis the same or older, so no supported browser is lost. - Smoke tests: 4/4 pass locally and in the new CI job. When I block the staging backend, the landing page still renders with no page errors, so the tests do not become flaky when staging is down.
LGTM.
Generated by Claude Code
Addresses argotorg/sourcify#3035 (move sourcify.dev from Create React App to Vite).
Summary
This PR replaces Create React App (
react-scripts5.0.1) with Vite 8. Vite is a build tool and dev server for front-end apps.npm run dev(ornpm start) starts the dev server on port 3000, as before.VITE_, notREACT_APP_. The code reads them fromimport.meta.env, notprocess.env..nvmrcand the deploy workflow now pin 22.23.4.npm testruns the existing unit tests with Vitest.Why
Create React App is no longer maintained.
react-scriptspinswebpack-dev-server4 andsvgo1. Both have known CVEs (published security flaws). We cannot update them while we usereact-scripts.The install also gets much smaller.
npm ciinstalls 398 packages now. Onstagingit installs 1428.Socket result
Socket checks npm packages for known risks. I ran
npm cithroughsocket npmon a cleannode_modules. The table shows the five packages from the issue.webpack-dev-server4.15.2react-scripts)svgo1.3.2react-scripts)postcss-selector-parser6.1.4sprintf-js1.0.3react-scripts)elliptic6.6.1@ethersproject/signing-key. Socket does not flag it in this run. It is not in the bundle.Socket now flags one package:
undici6.29.0 (a moderate CVE). It is already onstaging. It comes from@ai-sdk/provider-utils, which theaipackage uses. This PR does not change it.undici6.29.1 exists and is in range, so a lockfile update can probably fix it in a separate PR.Build comparison
I built
staging(Create React App) and this branch (Vite) with the same.env.build.staging.public/are inbuild/, byte for byte the same.index.htmlhead: the same meta tags, title, Umami script (with the real website id), and hash-URL migration script. No%PUBLIC_URL%or%VITE_…%placeholder is left.process.envdoes not occur in the bundle.Differences in the output:
build/assets/, not inbuild/static/. The deploy workflow uploads all ofbuild/, so this does not matter. The workflow keepsstatic/stats.jsonandstatic/manifest.jsonin the bucket. The build does not write these files, so the change has no effect on them.*.map). Create React App made 8 of them (16 MB). Setbuild.sourcemap: trueinvite.config.mtsif we want them back.asset-manifest.json. Nothing in the repo reads it.Smoke test
I ran
npm run dev(with.env.development) and opened these pages in Chrome. I saw no console errors./: the hero, the live counter and the stats load. All 31 images load, also the 5 chain logos that usenew URL(…, import.meta.url). The IBM Plex and VT323 fonts load./address/0xd61dAdFb716Aa65aA29E7CF6E15Ed833a403dcd6: the lookup shows the Sepolia match./#/lookup/0xd61d…changes to/address/0xd61d…./#dataset-playgroundchanges to/dataset-playground. The OpenRouter key from.env.developmentreaches the page./verifiershows the staging verify URL.Then I ran
npm run previewon the staging build. A direct load of/dataset-playgroundrenders the page, so the fallback toindex.htmlworks.Fixes that the move needed
The Google Fonts
@importinsrc/index.css. It came after the Tailwind lines:CSS allows
@importonly at the top of a file. Create React App moved it up without a warning. Vite drops it, so the fonts did not load. The@importis now the first line.The one test file,
src/pages/LandingPage/liveStats.test.ts. It importeddescribe,itandexpectfrom@jest/globals. Jest came only fromreact-scripts. The file now imports them fromvitest, andnpm testrunsvitest run. All 12 tests pass. Vitest 5 needs@types/node22 or newer, so@types/nodegoes from 20.19.43 to 22.20.5. This matches the new Node pin.A missing image.
index.htmllinked%PUBLIC_URL%/logo192.png, which does not exist inpublic/. Theapple-touch-iconlink now points to/sourcify_blue_rounded.png.Overrides.
on-headers,serialize-javascriptanduuidare no longer installed, so their overrides go away. Thereact-scriptsblock goes away too.prismjsstays.Lint
The old ESLint config extended
react-appfromreact-scripts. The neweslint.config.mjsis a flat config, based on the official Vitereact-tstemplate. It uses ESLint 10, the current version.npm run lintchecks the files insrc/andvite.config.mts.I fixed the mechanical errors:
bigqueryinsrc/utils/api.tsx, the unusedenow goes into the new error as its cause:AIGenerator(src/components/BigQueryExplorer/AIGenerator.tsx),catch (e: any)becomescatch. Areact-hooks/exhaustive-depsdisable comment that no longer suppresses anything is gone.BigQueryExplorer(src/components/BigQueryExplorer/index.tsx), the two emptycatch {}blocks aroundlocalStoragenow have a comment that explains why they are empty.These rules flag code that works today. A fix needs a refactor, so they are set to
warn(25 warnings in total):@typescript-eslint/no-explicit-anyanytypesreact-refresh/only-export-componentsreact-hooks/set-state-in-effectsetStatecalled directly in auseEffectreact-hooks/refsLiveFeed.tsxreact-hooks/purityDate.now()during render inVerifiedContracts.tsxtsc --noEmitreports no type errors.npm run buildruns it beforevite build, the same as Create React App type-checked during its build.Other changes
vite.config.mtsandeslint.config.mjsuse ES module file extensions.package.jsonhas no"type": "module", andpostcss.config.jsandtailwind.config.jsuse CommonJS.README.mddescribes the new commands and env vars. The Docker section is gone, because the repo has noDockerfile.Settings outside the repo
No setting outside the repo needs to change.
.env.build.stagingand.env.build.main, and this PR renames their keys.REACT_APP_OPENROUTER_API_KEY, keeps its name. The workflow passes it to the build asVITE_OPENROUTER_API_KEY..nvmrcand runsnpm run build. The publish directory staysbuild/. The deploy preview of this PR builds with the staging URLs.Changes after the review
vite.config.mtsadds the Umami script only whenVITE_UMAMI_WEBSITE_IDis set. Dev and Netlify previews set it to empty, so they load no analytics script. Before, they shipped the%VITE_UMAMI_WEBSITE_ID%placeholder.build.targetis now the oldest browsers that the Create React App build supported (Chrome 109, Safari/iOS 15.6, Firefox 115). Without it, Vite targets Chrome 111 and Safari 16.4. The main bundle is now 215.7 kB gzip (212.0 kB before this change).ci.yamlworkflow runs lint, unit tests, the build and Playwright smoke tests (npm run test:e2e) on every pull request.VERIFY_URLcomes fromconstants.tseverywhere.enginesasks for Node 22.13+.nginx.confis gone.tsconfig.node.jsontype-checks the config files.release.yamlexplains why the OpenRouter key is in the bundle.🤖 Generated with Claude Code