Skip to content

Commit

Permalink
Merge pull request #10862 from DestinyItemManager/break-chunks
Browse files Browse the repository at this point in the history
Move some stuff out of the initial chunk
  • Loading branch information
bhollis authored Dec 20, 2024
2 parents c41a611 + 54d01d4 commit 5cc8ed0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import HotkeysCheatSheet from './hotkeys/HotkeysCheatSheet';
import { t } from './i18next-t';
import Login from './login/Login';
import NotificationsContainer from './notifications/NotificationsContainer';
import About from './shell/About';
import DefaultAccount from './shell/DefaultAccount';
import Destiny from './shell/Destiny';
import GATracker from './shell/GATracker';
import Header from './shell/Header';
import Privacy from './shell/Privacy';
import ScrollToTop from './shell/ScrollToTop';
import SneakyUpdates from './shell/SneakyUpdates';

Expand All @@ -29,6 +27,8 @@ const SettingsPage = lazy(
() => import(/* webpackChunkName: "settings" */ './settings/SettingsPage'),
);
const Debug = lazy(() => import(/* webpackChunkName: "debug" */ './debug/Debug'));
const Privacy = lazy(() => import(/* webpackChunkName: "privacy" */ './shell/Privacy'));
const About = lazy(() => import(/* webpackChunkName: "about" */ './shell/About'));

export default function App() {
const language = useSelector(settingSelector('language'));
Expand Down
2 changes: 1 addition & 1 deletion src/app/armory/ArmoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { t } from 'app/i18next-t';
import { useLoadStores } from 'app/inventory/store/hooks';
import { usePageTitle } from 'app/utils/hooks';
import { useLocation, useParams } from 'react-router';
import Armory from './Armory';
import Armory from './LazyArmory';

export default function ArmoryPage({ account }: { account: DestinyAccount }) {
usePageTitle(t('Armory.Armory'));
Expand Down
30 changes: 16 additions & 14 deletions src/app/armory/ArmorySheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Sheet from 'app/dim-ui/Sheet';
import { DimItem } from 'app/inventory/item-types';
import { filterMap } from 'app/utils/collections';
import focusingItemOutputs from 'data/d2/focusing-item-outputs.json';
import { useMemo } from 'react';
import Armory from './Armory';
import { Suspense, useMemo } from 'react';
import styles from './ArmorySheet.m.scss';
import Armory from './LazyArmory';

export default function ArmorySheet({
item,
Expand Down Expand Up @@ -36,17 +36,19 @@ export default function ArmorySheet({
const betterItemHash = item?.vendor && focusingItemOutputs[item.hash];

return (
<Sheet onClose={onClose} sheetClassName={styles.sheet}>
<ClickOutsideRoot>
<Armory
itemHash={itemHash ?? betterItemHash ?? item.hash}
// Only use the sockets if we didn't change what item we're even looking at.
realItemSockets={betterItemHash === undefined ? realItemSockets : undefined}
realAvailablePlugHashes={
betterItemHash === undefined ? realAvailablePlugHashes : undefined
}
/>
</ClickOutsideRoot>
</Sheet>
<Suspense fallback={null}>
<Sheet onClose={onClose} sheetClassName={styles.sheet}>
<ClickOutsideRoot>
<Armory
itemHash={itemHash ?? betterItemHash ?? item.hash}
// Only use the sockets if we didn't change what item we're even looking at.
realItemSockets={betterItemHash === undefined ? realItemSockets : undefined}
realAvailablePlugHashes={
betterItemHash === undefined ? realAvailablePlugHashes : undefined
}
/>
</ClickOutsideRoot>
</Sheet>
</Suspense>
);
}
3 changes: 3 additions & 0 deletions src/app/armory/LazyArmory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { lazy } from 'react';

export default lazy(() => import('./Armory' /* webpackChunkName: "armory" */));
23 changes: 13 additions & 10 deletions src/app/item-popup/ItemPopupContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { createItemContextSelector, sortedStoresSelector } from 'app/inventory/s
import { DimStore } from 'app/inventory/store-types';
import { applySocketOverrides } from 'app/inventory/store/override-sockets';
import { useD2Definitions } from 'app/manifest/selectors';
import { useEffect } from 'react';
import { lazy, Suspense, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useLocation } from 'react-router';
import { useSubscription } from 'use-subscription';
import { DimItem } from '../inventory/item-types';
import ItemPopup from './ItemPopup';
import { hideItemPopup, showItemPopup$ } from './item-popup';

const ItemPopup = lazy(() => import(/* webpackChunkName: "item-popup" */ './ItemPopup'));

interface Props {
boundarySelector?: string;
}
Expand Down Expand Up @@ -44,14 +45,16 @@ export default function ItemPopupContainer({ boundarySelector }: Props) {
}

return (
<ItemPopup
key={item.index}
item={item}
boundarySelector={boundarySelector}
element={currentItem.element}
extraInfo={currentItem.extraInfo}
onClose={onClose}
/>
<Suspense fallback={null}>
<ItemPopup
key={item.index}
item={item}
boundarySelector={boundarySelector}
element={currentItem.element}
extraInfo={currentItem.extraInfo}
onClose={onClose}
/>
</Suspense>
);
}

Expand Down

0 comments on commit 5cc8ed0

Please sign in to comment.