Migrate from Angular 9 to React (Vite + TypeScript)#440
Open
devanshi-gpta wants to merge 7 commits into
Open
Conversation
… SettingsContext, router, App shell, shared components) 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>
Co-Authored-By: Devanshi Gupta <devanshi.gupta@cognition.ai>
…'origin/devin/feed-item-react-migration', 'origin/devin/react-itemdetails-comment' and 'origin/devin/port-user-profile-react' into devin/1783534263-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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full rewrite of this Hacker News PWA from Angular 9 → React 18 + Vite + TypeScript, preserving feature parity, UI/UX, the SCSS theme system, and PWA/offline support. All
@angular/*,rxjs, andzone.jsare removed; the app now builds with Vite and routes with React Router.Tooling swap:
angular.json,karma,protractor,tslint,polyfills,zone.js) → Vite (vite.config.ts,@vitejs/plugin-react,eslint).src/app/*moved up tosrc/.@angular/service-worker→vite-plugin-pwa(Workbox), keeping the manifest/icons and addingNetworkFirstruntime caching for the HN API.src/shared/scss/; per-component.scsskept as global styles (theme class lives on the app wrapper), with@importpaths rebased and Angular-only:host >>>selectors dropped.Architecture mapping:
HackernewsApiService(RxJSObservable+unfetch) →src/shared/api.tsusingfetchandPromises —fetchFeed,fetchItemContent(keeps the poll-aggregation logic viaPromise.all),fetchPollContent,fetchUser. Error strings like"Could not load ... stories."preserved.src/context/SettingsContext.tsxstorestheme/openLinkInNewTab/titleFontSize/listSpacing/showSettings, persists tolocalStorage, and subscribes tomatchMedia('(prefers-color-scheme: dark)'). Actions:setTheme,toggleOpenLinksInNewTab,setFont,setSpacing,toggleSettings.app.routes.ts→src/router.tsx(createBrowserRouter). Five feed routes (news/newest/show/ask/jobswith:page) render a shared<Feed feedType=... />;/redirects to/news/1;item/:idanduser/:idareReact.lazy+Suspense.comment.pipe.ts→commentCount(n)insrc/shared/comment-count.ts.Story/Comment/User/Settings/PollResult/FeedTypeported as interfaces (Storygains optionalcontent?/text?used by the item-detail template).Components (all Angular templates → JSX functional components;
*ngIf→&&/ternary,*ngFor→.map,routerLink→Link/NavLink,[innerHTML]→dangerouslySetInnerHTML,[ngStyle]→style,(click)→onClick,Location.back()→useNavigate(-1)):Appshell (theme wrapper +Header/<Outlet/>/Footer),Header+SettingsPanel,Footer,Feed,Item,ItemDetails, recursiveCommentItem(localuseStatecollapse,[deleted]fallback),UserProfile, plus sharedLoader/ErrorMessage.Verification
npm run build(tsc --noEmit && vite build) andnpm run lintpass cleanly on the integrated branch.nightclass applied to the wrapper) all render correctly.node-hnapi.herokuapp.com) currently returns404for/user/:id, so user-profile pages surface the "Could not load user" error. This is a pre-existing limitation of the external API — the original Angular app called the identical endpoint — not a regression from this migration.This branch integrates four component-porting sub-PRs (#436 Header/Settings, #438 Feed/Item, #439 ItemDetails/Comment, #437 User) that merged into it.
Link to Devin session: https://app.devin.ai/sessions/845284a06aca4b92b7d770d6e99e55b0
Requested by: @devanshi-gpta
Devin Review