Migrate from Angular 9 to React 18 + TypeScript + Vite - #648
Migrate from Angular 9 to React 18 + TypeScript + Vite#648devanshi-gpta wants to merge 6 commits into
Conversation
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Fix conflicting workbox precache entries so the service worker installs and the app works offline. Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
…-ci' into devin/1787076559-react-migration
🤖 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:
|
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
Runtime test pass — React 18 + Vite migrationTested the production build ( PWA / offline (production build)Service worker With the preview server killed and all network requests aborted, a reload still renders the app shell from precache with the graceful offline notice; restoring the network brings back all 30 stories. Feeds, pagination, item details, polls
Settings popupAll three themes apply (AMOLED background is pure Automated checks + e2e flake (fixed)
Caveats
Full recording: https://app.devin.ai/attachments/fa744560-08d6-4ae7-a9c8-e746cedfa33e/rec-6318187d-6d0b-49f4-b45c-5f52d85f042d-edited.mp4 Tested by Devin. |
…ories Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>




Summary
Full rewrite of the Hacker News PWA from Angular 9 (Angular CLI, RxJS,
@angular/service-worker) to React 18 + TypeScript on Vite, keeping the SCSS, theming, routes, URLs and PWA behaviour identical. The Angular sources,angular.json, karma/protractor stack and.travis.ymlare gone; the app is nowindex.html→src/main.tsx→src/App.tsx.Behaviour-preserving mapping:
HackerNewsAPIService(Observables,lazyFetch)src/api/hackerNewsApi.ts— plainasyncfunctions +AbortControllerSettingsService(BehaviorSubject + localStorage)src/context/SettingsContext.tsx+useSettings()app.routes.tsw/loadChildrensrc/routes.tsxw/React.lazy+Suspensecomment.pipe.tssrc/utils/formatCommentCount.ts[innerHTML]dangerouslySetInnerHTMLngsw-worker.js+ngsw-config.jsonvite-plugin-pwa(Workbox), manifest inlined invite.config.tsPoll aggregation in
fetchItemContentkeeps the original semantics, just parallelised:Two notes on things that are not obvious from the diff:
includeAssets+globPatterns), which made Workbox throw on conflicting entries and install a service worker with an empty cache — i.e. offline silently did not work. Fixed withglobIgnoresplus a trimmedincludeAssets.page.routestubs do not apply to requests issued through the service worker, soe2e/pwa.spec.tsasserts the precached shell renders plus the feed's error state instead of stubbed stories.Testing: 62 Vitest/Testing Library tests (MSW-backed for anything touching the API) and 16 Playwright specs run against a production build, covering the redirect to
/news/1, all five feeds with pagination, item details with nested comment collapse/expand, polls, user pages, theme persistence across reload, and service-worker/offline. CI (.github/workflows/ci.yml) runs typecheck, lint, unit tests, build and e2e.Link to Devin session: https://app.devin.ai/sessions/682e0e9ed3c5406ab13970ac8d15d795
Requested by: @devanshi-gpta
Devin Review