Repository navigation
Rewrite Angular 9 HN PWA as React 18 + TypeScript + Vite (react-app/) - #945
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
- react-app/: React Router route map matching app.routes.ts, React.lazy item/user routes - fetch API + TanStack Query hooks (no RxJS), HNPWA user fallback - settings context + localStorage hook, root theme class, reused SCSS - vite-plugin-pwa with app-shell precache and HN API runtime cache - Vitest/RTL unit tests and Playwright e2e (incl. offline) - Travis builds/tests react-app; Firebase serves react-app/dist Co-Authored-By: piyush@cognition.ai <piyush.b.puri@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Production-preview UI QA against the live Angular app (https://angular2-hn.firebaseapp.com), using live HN data. Passed: Offline (React): this ran in an isolated browser with the network actually off. Cached Not verified: Angular-original offline parity. The live Angular deployment exposed no service-worker registration in a fresh browser, so there was no baseline to compare against. Lighthouse (React 88 PWA = Angular 88) is in the PR description.
|
Co-Authored-By: piyush@cognition.ai <piyush.b.puri@gmail.com>
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Missing profiles stuck loading forever — Confirmed api.hnpwa.com returns HTTP 200
nullfor unknown users. fetchUser now throws on a null body, so /user/ shows 'Could not load user'. Covered by a unit test and checked against the live API in the preview build.
Summary
Full port of the Angular 9 client into
react-app/(React 18, TS strict, Vite 6, React Router 6, TanStack Query 5, vite-plugin-pwa, Vitest/RTL, Playwright). Deploy is pointed at the new build; the Angularsrc/is left untouched for side-by-side comparison until cutover.Route map (parity with
src/app/app.routes.ts)Data layer –
HackerNewsAPIService(RxJS) →src/api/hackernews.tsfetch functions +useFeed/useItem/useUserhooks. Poll options are still fetched fromstory.id + i + 1and summed intopoll_votes_count.fetchUserfalls back tohttps://api.hnpwa.com/v0/user/<id>.jsonbecause node-hnapi/user/:idcurrently 404s. Queries usenetworkMode: 'always'so the service worker can answer offline (TanStack's default would pause and spin forever).Settings/theme –
SettingsService→SettingsProvider+useLocalStorage(same keys:theme,openLinkInNewTab,titleFontSize,listSpacing; sameprefers-color-schemefallback). Theme class (default|night|amoledblack) goes on<html>. Angular SCSS was copied and nested under.app-*host classes to emulate view encapsulation; global styles are imported before components so the cascade matches Angular.PWA (ngsw-config.json parity) – app shell (
index.html, JS/CSS, favicon, manifest) precached;/assets/**+ fonts/imagesStaleWhileRevalidate; node-hnapi/HNPWANetworkFirst(5s timeout, 300 entries, 7d).public/ngsw-worker.jsis a kill switch that unregisters the old Angular worker and deletesngsw:*caches for existing installs. Note: the WorkboxurlPatterncallback is serialized intosw.js, so it must not close over module variables (a regex is used).CI/hosting –
.travis.yml: Node 22/npm 11,cd react-app→ lint, typecheck, unit, build, e2e, thenfirebase deploy --only hosting.firebase.jsonpublic: react-app/dist,no-cacheonsw.js/ngsw-worker.js, immutable hashed assets.Verification
npm run lint,npm run typecheck,npm run buildclean/news/1, React preview vs live Angular (angular2-hn.firebaseapp.com):Both miss only
maskable-iconin PWA (same manifest icons reused).Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/3c3c9bc973664afc9e1aa2739618e56e
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/3c3c9bc973664afc9e1aa2739618e56e?variant=devin
Requested by: @piyushpuri96
Note
Devin errored when opening this Pull Request as piyushpuri96.
As a fallback, Devin opened this PR as itself.
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work