Skip to content

Commit

Permalink
enable bundle splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-sz committed Oct 26, 2023
1 parent 071a51b commit c6cd534
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 34 deletions.
67 changes: 36 additions & 31 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React from 'react';
import React, { Suspense } from 'react';
import { Router, Route, Switch } from 'wouter';
import { useTranslation } from 'react-i18not';

import './App.scss';

import { Home } from './screens/Home.js';
import { Redirect } from './screens/Redirect.js';
import { Privacy } from './screens/Privacy.js';
import { ToS } from './screens/ToS.js';
import { Abuse } from './screens/Abuse.js';
import { About } from './screens/About.js';
import { TechnicalInformation } from './screens/TechnicalInformation.js';
import { Header } from './components/Header.js';
import { Status } from './components/Status.js';

const Abuse = React.lazy(() => import('./screens/Abuse.js'));
const TechnicalInformation = React.lazy(
() => import('./screens/TechnicalInformation.js')
);
const ToS = React.lazy(() => import('./screens/ToS.js'));
const Privacy = React.lazy(() => import('./screens/Privacy.js'));
const About = React.lazy(() => import('./screens/About.js'));

export const App: React.FC = () => {
const { dir } = useTranslation();
document.body.dir = dir;
Expand All @@ -22,31 +25,33 @@ export const App: React.FC = () => {
<div className="app">
<Header />
<Status />
<Router>
<Switch>
<Route path="/abuse">
<Abuse />
</Route>
<Route path="/about">
<About />
</Route>
<Route path="/privacy">
<Privacy />
</Route>
<Route path="/tos">
<ToS />
</Route>
<Route path="/tech">
<TechnicalInformation />
</Route>
<Route path="/:networkName">
<Home />
</Route>
<Route>
<Redirect />
</Route>
</Switch>
</Router>
<Suspense>
<Router>
<Switch>
<Route path="/abuse">
<Abuse />
</Route>
<Route path="/about">
<About />
</Route>
<Route path="/privacy">
<Privacy />
</Route>
<Route path="/tos">
<ToS />
</Route>
<Route path="/tech">
<TechnicalInformation />
</Route>
<Route path="/:networkName">
<Home />
</Route>
<Route>
<Redirect />
</Route>
</Switch>
</Router>
</Suspense>
</div>
);
};
2 changes: 2 additions & 0 deletions web/src/screens/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ export const About: React.FC = () => {
</TextSection>
);
};

export default About;
2 changes: 2 additions & 0 deletions web/src/screens/Abuse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export const Abuse: React.FC = observer(() => {
</TextSection>
);
});

export default Abuse;
9 changes: 6 additions & 3 deletions web/src/screens/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { Suspense, useEffect, useState } from 'react';
import { useParams } from 'wouter';
import { observer } from 'mobx-react-lite';
import { useTranslation } from 'react-i18not';
Expand All @@ -14,11 +14,12 @@ import { YourTileSection } from '../sections/YourTile/index.js';
import { NoticeSection } from '../sections/Notice/index.js';
import { NetworkSection } from '../sections/Network/index.js';
import { TransfersSection } from '../sections/Transfers/index.js';
import { ConnectSection } from '../sections/Connect/index.js';
import { ChatSection } from '../sections/Chat/index.js';
import { MobileTabs } from '../sections/MobileTabs/index.js';
import { SettingsSection } from '../sections/Settings/index.js';

const ConnectSection = React.lazy(() => import('../sections/Connect/index.js'));

function itemToString(item: DataTransferItem): Promise<string> {
return new Promise(resolve => {
item.getAsString(resolve);
Expand Down Expand Up @@ -142,7 +143,9 @@ export const Home: React.FC = observer(() => {
mobileHidden: tab !== 'connect',
})}
>
<ConnectSection />
<Suspense>
<ConnectSection />
</Suspense>
</div>
<div
className={clsx('mobileFlex', {
Expand Down
2 changes: 2 additions & 0 deletions web/src/screens/Privacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ export const Privacy: React.FC = () => {
</TextSection>
);
};

export default Privacy;
2 changes: 2 additions & 0 deletions web/src/screens/TechnicalInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ export const TechnicalInformation: React.FC = observer(() => {
</TextSection>
);
});

export default TechnicalInformation;
2 changes: 2 additions & 0 deletions web/src/screens/ToS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ export const ToS: React.FC = () => {
</TextSection>
);
};

export default ToS;
2 changes: 2 additions & 0 deletions web/src/sections/Connect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ export const ConnectSection: React.FC = observer(() => {
</>
);
});

export default ConnectSection;

0 comments on commit c6cd534

Please sign in to comment.