From 1b35e3acd94077a87ac2ef36bed72d7c9102ad10 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 25 May 2026 15:32:41 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(frontend)=20remove=20auth=20?= =?UTF-8?q?barrel=20file=20to=20improve=20code=20splitting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Auth-related code is used across the codebase and imported by many different features. The barrel file, while convenient for importing utilities, was harming code splitting by pulling unrelated modules into shared chunks. Verified by running `npm run build:debug` before and after: chunking and code splitting are better without the barrel. --- src/frontend/src/components/AppInitialization.tsx | 2 +- src/frontend/src/components/LoginButton.tsx | 2 +- src/frontend/src/components/ProConnectButton.tsx | 2 +- src/frontend/src/features/auth/components/UserAware.tsx | 2 +- src/frontend/src/features/auth/index.ts | 4 ---- src/frontend/src/features/auth/utils/silentLogin.ts | 2 +- src/frontend/src/features/files/api/listFiles.ts | 2 +- src/frontend/src/features/home/routes/Home.tsx | 3 ++- .../notifications/components/ToastRecordingSaving.tsx | 2 +- .../src/features/recording/components/NoAccessView.tsx | 2 +- .../src/features/recording/routes/RecordingDownload.tsx | 3 ++- .../rooms/livekit/components/effects/EffectsConfiguration.tsx | 2 +- src/frontend/src/features/rooms/routes/Room.tsx | 3 ++- src/frontend/src/features/sdk/routes/CreatePopup.tsx | 2 +- src/frontend/src/features/sdk/utils/PopupWindow.ts | 2 +- .../src/features/settings/components/SettingsDialog.tsx | 2 +- .../src/features/settings/components/tabs/AccountTab.tsx | 2 +- src/frontend/src/hooks/useLoginHint.ts | 2 +- src/frontend/src/layout/Header.tsx | 2 +- 19 files changed, 21 insertions(+), 22 deletions(-) delete mode 100644 src/frontend/src/features/auth/index.ts diff --git a/src/frontend/src/components/AppInitialization.tsx b/src/frontend/src/components/AppInitialization.tsx index b52cb9fa..0c5caeff 100644 --- a/src/frontend/src/components/AppInitialization.tsx +++ b/src/frontend/src/components/AppInitialization.tsx @@ -2,7 +2,7 @@ import { silenceLiveKitLogs } from '@/utils/livekit' import { useConfig } from '@/api/useConfig' import { useAnalytics } from '@/features/analytics/hooks/useAnalytics' import { useSupport } from '@/features/support/hooks/useSupport' -import { useSyncUserPreferencesWithBackend } from '@/features/auth' +import { useSyncUserPreferencesWithBackend } from '@/features/auth/api/useSyncUserPreferencesWithBackend' import { useEffect } from 'react' export const AppInitialization = () => { diff --git a/src/frontend/src/components/LoginButton.tsx b/src/frontend/src/components/LoginButton.tsx index c597cc85..f2c59ef8 100644 --- a/src/frontend/src/components/LoginButton.tsx +++ b/src/frontend/src/components/LoginButton.tsx @@ -1,8 +1,8 @@ import { LinkButton } from '@/primitives' -import { authUrl } from '@/features/auth' import { useTranslation } from 'react-i18next' import { useConfig } from '@/api/useConfig' import { ProConnectButton } from './ProConnectButton' +import { authUrl } from '@/features/auth/utils/authUrl' type LoginButtonProps = { proConnectHint?: boolean // Hide hint in layouts where space doesn't allow it. diff --git a/src/frontend/src/components/ProConnectButton.tsx b/src/frontend/src/components/ProConnectButton.tsx index 96f68ee4..f715cacc 100644 --- a/src/frontend/src/components/ProConnectButton.tsx +++ b/src/frontend/src/components/ProConnectButton.tsx @@ -1,5 +1,5 @@ import { Link as RALink } from 'react-aria-components' -import { authUrl } from '@/features/auth' +import { authUrl } from '@/features/auth/utils/authUrl' import { cva } from '@/styled-system/css' import { useTranslation } from 'react-i18next' import { VStack } from '@/styled-system/jsx' diff --git a/src/frontend/src/features/auth/components/UserAware.tsx b/src/frontend/src/features/auth/components/UserAware.tsx index ec9028cd..f7c0746d 100644 --- a/src/frontend/src/features/auth/components/UserAware.tsx +++ b/src/frontend/src/features/auth/components/UserAware.tsx @@ -1,4 +1,4 @@ -import { useUser } from '@/features/auth' +import { useUser } from '../api/useUser' import { LoadingScreen } from '@/components/LoadingScreen' /** diff --git a/src/frontend/src/features/auth/index.ts b/src/frontend/src/features/auth/index.ts deleted file mode 100644 index 710aa9ed..00000000 --- a/src/frontend/src/features/auth/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { useUser } from './api/useUser' -export { useSyncUserPreferencesWithBackend } from './api/useSyncUserPreferencesWithBackend' -export { authUrl } from './utils/authUrl' -export { UserAware } from './components/UserAware' diff --git a/src/frontend/src/features/auth/utils/silentLogin.ts b/src/frontend/src/features/auth/utils/silentLogin.ts index 3761a348..456b7e14 100644 --- a/src/frontend/src/features/auth/utils/silentLogin.ts +++ b/src/frontend/src/features/auth/utils/silentLogin.ts @@ -1,4 +1,4 @@ -import { authUrl } from '@/features/auth' +import { authUrl } from './authUrl' const SILENT_LOGIN_RETRY_KEY = 'silent-login-retry' diff --git a/src/frontend/src/features/files/api/listFiles.ts b/src/frontend/src/features/files/api/listFiles.ts index db57a4a1..1d9de242 100644 --- a/src/frontend/src/features/files/api/listFiles.ts +++ b/src/frontend/src/features/files/api/listFiles.ts @@ -6,7 +6,7 @@ import { ApiFileType, ApiFileUploadState, } from '@/features/files/api/types.ts' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { useConfig } from '@/api/useConfig.ts' type ListFilesResponse = { diff --git a/src/frontend/src/features/home/routes/Home.tsx b/src/frontend/src/features/home/routes/Home.tsx index e6d8cf27..63367796 100644 --- a/src/frontend/src/features/home/routes/Home.tsx +++ b/src/frontend/src/features/home/routes/Home.tsx @@ -5,7 +5,8 @@ import { styled } from '@/styled-system/jsx' import { navigateTo } from '@/navigation/navigateTo' import { Screen } from '@/layout/Screen' import { generateRoomId, useCreateRoom } from '@/features/rooms' -import { useUser, UserAware } from '@/features/auth' +import { UserAware } from '@/features/auth/components/UserAware' +import { useUser } from '@/features/auth/api/useUser' import { JoinMeetingDialog } from '../components/JoinMeetingDialog' import { RiAddLine, RiLink } from '@remixicon/react' import { LaterMeetingDialog } from '@/features/home/components/LaterMeetingDialog' diff --git a/src/frontend/src/features/notifications/components/ToastRecordingSaving.tsx b/src/frontend/src/features/notifications/components/ToastRecordingSaving.tsx index c2a2e3f1..d4814f0e 100644 --- a/src/frontend/src/features/notifications/components/ToastRecordingSaving.tsx +++ b/src/frontend/src/features/notifications/components/ToastRecordingSaving.tsx @@ -5,7 +5,7 @@ import { Text } from '@/primitives' import { StyledToastContainer, type ToastProps } from './Toast' import { HStack } from '@/styled-system/jsx' import { useTranslation } from 'react-i18next' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { css } from '@/styled-system/css' import { RecordingMode } from '@/features/recording' diff --git a/src/frontend/src/features/recording/components/NoAccessView.tsx b/src/frontend/src/features/recording/components/NoAccessView.tsx index 556c946a..76ed02ce 100644 --- a/src/frontend/src/features/recording/components/NoAccessView.tsx +++ b/src/frontend/src/features/recording/components/NoAccessView.tsx @@ -3,7 +3,7 @@ import { css } from '@/styled-system/css' import { useTranslation } from 'react-i18next' import { LoginPrompt } from './LoginPrompt' import { RequestRecording } from './RequestRecording' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { HStack, VStack } from '@/styled-system/jsx' const Divider = ({ label }: { label: string }) => ( diff --git a/src/frontend/src/features/recording/routes/RecordingDownload.tsx b/src/frontend/src/features/recording/routes/RecordingDownload.tsx index e6f872b9..2f766bdd 100644 --- a/src/frontend/src/features/recording/routes/RecordingDownload.tsx +++ b/src/frontend/src/features/recording/routes/RecordingDownload.tsx @@ -6,7 +6,8 @@ import { useTranslation } from 'react-i18next' import { useTitle } from 'hoofd' import { useMemo } from 'react' import { mediaUrl } from '@/api/mediaUrl' -import { UserAware, useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' +import { UserAware } from '@/features/auth/components/UserAware' import { Screen } from '@/layout/Screen' import { H, LinkButton, Text } from '@/primitives' import { formatDate } from '@/utils/formatDate' diff --git a/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx b/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx index e639ab1b..1a537c2f 100644 --- a/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx +++ b/src/frontend/src/features/rooms/livekit/components/effects/EffectsConfiguration.tsx @@ -27,7 +27,7 @@ import { useCreateFile } from '@/features/files/api/createFile.ts' import { FileTrigger } from 'react-aria-components' import { RiDeleteBinLine, RiImageAddFill } from '@remixicon/react' import { useDeleteFile } from '@/features/files/api/deleteFile.ts' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { ApiFileItem } from '@/features/files/api/types.ts' import { useConfig } from '@/api/useConfig.ts' import { usePersistentUserChoices } from '@/features/rooms/livekit/hooks/usePersistentUserChoices.ts' diff --git a/src/frontend/src/features/rooms/routes/Room.tsx b/src/frontend/src/features/rooms/routes/Room.tsx index 130ee0dc..72da3bca 100644 --- a/src/frontend/src/features/rooms/routes/Room.tsx +++ b/src/frontend/src/features/rooms/routes/Room.tsx @@ -1,7 +1,8 @@ import { ReactNode, useEffect, useState } from 'react' import { useLocation, useParams } from 'wouter' import { ErrorScreen } from '@/components/ErrorScreen' -import { useUser, UserAware } from '@/features/auth' +import { UserAware } from '@/features/auth/components/UserAware' +import { useUser } from '@/features/auth/api/useUser' import { Conference } from '../components/Conference' import { Join } from '../components/Join' import { Permissions } from '../components/Permissions' diff --git a/src/frontend/src/features/sdk/routes/CreatePopup.tsx b/src/frontend/src/features/sdk/routes/CreatePopup.tsx index 6cd5b3cd..10822b7e 100644 --- a/src/frontend/src/features/sdk/routes/CreatePopup.tsx +++ b/src/frontend/src/features/sdk/routes/CreatePopup.tsx @@ -1,7 +1,7 @@ import { useEffect, useMemo } from 'react' import { css } from '@/styled-system/css' import { generateRoomId, useCreateRoom } from '../../rooms' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { Spinner } from '@/primitives/Spinner' import { CallbackIdHandler } from '../utils/CallbackIdHandler' import { PopupWindow } from '../utils/PopupWindow' diff --git a/src/frontend/src/features/sdk/utils/PopupWindow.ts b/src/frontend/src/features/sdk/utils/PopupWindow.ts index 15856c4b..7d6c0590 100644 --- a/src/frontend/src/features/sdk/utils/PopupWindow.ts +++ b/src/frontend/src/features/sdk/utils/PopupWindow.ts @@ -1,4 +1,4 @@ -import { authUrl } from '@/features/auth' +import { authUrl } from '@/features/auth/utils/authUrl' import { PopupMessageType, CallbackCreationRoomData } from './types' export class PopupWindow { diff --git a/src/frontend/src/features/settings/components/SettingsDialog.tsx b/src/frontend/src/features/settings/components/SettingsDialog.tsx index cb3ab5f4..804bf84b 100644 --- a/src/frontend/src/features/settings/components/SettingsDialog.tsx +++ b/src/frontend/src/features/settings/components/SettingsDialog.tsx @@ -1,7 +1,7 @@ import { Trans, useTranslation } from 'react-i18next' import { useLanguageLabels } from '@/i18n/useLanguageLabels' import { A, Badge, Dialog, type DialogProps, Field, H, P } from '@/primitives' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { LoginButton } from '@/components/LoginButton' export type SettingsDialogProps = Pick diff --git a/src/frontend/src/features/settings/components/tabs/AccountTab.tsx b/src/frontend/src/features/settings/components/tabs/AccountTab.tsx index 2e10862b..7376371d 100644 --- a/src/frontend/src/features/settings/components/tabs/AccountTab.tsx +++ b/src/frontend/src/features/settings/components/tabs/AccountTab.tsx @@ -1,7 +1,7 @@ import { A, Badge, Button, DialogProps, Field, H, P } from '@/primitives' import { Trans, useTranslation } from 'react-i18next' import { useRoomContext } from '@livekit/components-react' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { css } from '@/styled-system/css' import { TabPanel, TabPanelProps } from '@/primitives/Tabs' import { HStack } from '@/styled-system/jsx' diff --git a/src/frontend/src/hooks/useLoginHint.ts b/src/frontend/src/hooks/useLoginHint.ts index 314b8006..e272f0b1 100644 --- a/src/frontend/src/hooks/useLoginHint.ts +++ b/src/frontend/src/hooks/useLoginHint.ts @@ -1,6 +1,6 @@ import { useSnapshot } from 'valtio' import { hintsStore } from '@/stores/hints' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { useEffect } from 'react' export const useLoginHint = () => { diff --git a/src/frontend/src/layout/Header.tsx b/src/frontend/src/layout/Header.tsx index df247b29..99fbe963 100644 --- a/src/frontend/src/layout/Header.tsx +++ b/src/frontend/src/layout/Header.tsx @@ -4,7 +4,7 @@ import { HStack, Stack } from '@/styled-system/jsx' import { useTranslation } from 'react-i18next' import { Button, Text } from '@/primitives' import { SettingsButton } from '@/features/settings' -import { useUser } from '@/features/auth' +import { useUser } from '@/features/auth/api/useUser' import { useMatchesRoute } from '@/navigation/useMatchesRoute' import { FeedbackBanner } from '@/components/FeedbackBanner' import { Menu } from '@/primitives/Menu'