Migrate from Angular 9 to React 18 + TypeScript + Vite#414
Migrate from Angular 9 to React 18 + TypeScript + Vite#414devanshi-gpta wants to merge 8 commits into
Conversation
… API, settings context, routing, shared components, component stubs Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
…782850201-angular-to-react-migration
…y excludes; update CI for Vite Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
End-to-end test resultsTested the migrated React app on the Vite dev server against the live HN API, exercising each core flow in a browser. Tests were designed adversarially (concrete expected values). All passed; no regressions or spec deviations.
Key evidence: pagination, collapse, theme persistence, pollsTest 2 — pagination starts at 31, Prev appears
Test 3 — nested comments collapse
Test 4 — theme persists across full reload (localStorage)
Test 6 — poll vote bars proportional to points (179 > 73 > 49) Test 1 + feeds + user error stateTest 1 — news feed, default red theme Caveat on Test 5 & known limitationTest 5: The browser automation strips Known limitation (not a regression): Tested via Devin: https://app.devin.ai/sessions/30935a6faa1c40f6bd3d483cd7f1d4e9 |










Summary
Full rewrite of the Hacker News PWA from Angular 9 to React 18 + TypeScript + Vite + react-router-dom, preserving all functionality, styling, the three themes, and PWA/offline support. The entire
src/app/Angular tree and Angular tooling (angular.json,tsconfig.app/spec.json,karma.conf.js,e2e/,tslint.json,polyfills,ngsw-config.json,@angular/*deps) are removed.Architectural mapping (Angular → React):
fetchmodulesrc/api/hackerNews.tswithAbortController.fetchItemContentkeeps the poll-aggregation logic (sumspoll_votes_countacross poll options). Each call accepts anAbortSignalsouseEffectcleanup cancels in-flight requests.SettingsService(BehaviorSubject) → React Contextsrc/context/SettingsContext.tsxexposinguseSettings()→{ settings, toggleSettings, toggleOpenLinksInNewTab, setTheme, setFont, setSpacing }. SamelocalStoragekeys (openLinkInNewTab,theme,titleFontSize,listSpacing) and theprefers-color-schemelistener that togglesdefault/night.src/models/.comment.pipe→commentCount(n)helper insrc/helpers/comment.ts.app.routes.ts→createBrowserRouterinsrc/router.tsx./→/news/1;news|newest|show|ask|jobs/:pagerenderFeed(feed type as prop);item/:idanduser/:iduseReact.lazy+Suspense(preserving the original lazy-loaded chunks).src/components/<Name>/:App(theme class wrapper +Header/Outlet/Footer),Header,Settings,Footer,Feed,Item,ItemDetails,Comment(recursive, per-instance collapse viauseState),User,Loader,ErrorMessage. Templates ported with*ngIf→conditional render,*ngFor→.map()+key,[innerHTML]→dangerouslySetInnerHTML,routerLink→<Link>,(click)→onClick, controlled inputs.@angular/service-worker(ngsw) →vite-plugin-pwa(Workbox) invite.config.ts: precaches the build andNetworkFirst-caches the HN API; web manifest retained.default,night,amoledblack) and all SCSS partials are preserved (moved tosrc/styles/).Scripts:
dev/start(vite),build(tsc -b && vite build),lint(eslint,--max-warnings 0),typecheck..travis.ymlupdated to Node 18 and the Angular CLI install dropped (Firebase deploy step unchanged).How this was built
Foundation (scaffolding, models, API, settings context, routing, shared components) was built here, then component porting was parallelized across child sessions (#410 User, #411 Header+Settings, #412 ItemDetails+Comment, #413 Feed+Item) which targeted this branch on disjoint files and were merged in.
Verification
npm run lint,npm run typecheck, andnpm run buildall pass clean. Smoke-tested in the browser against the live HN API: feeds load/paginate, item details render with nested comments + collapse, settings modal + theme switching work and persist across reloads, lazy chunks load, error state renders.Note: the
/user/:idpage shows the error state becausenode-hnapi.herokuapp.comreturns 404 for the user endpoint — this is a pre-existing API limitation (the original Angular app called the exact same endpoint), not a regression. The error UI is the portedErrorMessagecomponent.Link to Devin session: https://app.devin.ai/sessions/30935a6faa1c40f6bd3d483cd7f1d4e9
Requested by: @devanshi-gpta
Devin Review