From fb4667130cf055d108d608eff709e82ddd55dbec Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Sat, 9 Sep 2023 14:58:39 -0700 Subject: [PATCH] chore: remove use of nextjs dynamic import --- apps/trading/client-pages/disclaimer/index.ts | 4 +- apps/trading/client-pages/home/index.ts | 4 +- apps/trading/client-pages/liquidity/index.ts | 4 +- apps/trading/client-pages/market/index.ts | 4 +- apps/trading/client-pages/markets/index.ts | 4 +- apps/trading/client-pages/portfolio/index.ts | 4 +- apps/trading/pages/client-router.tsx | 114 ++++++------------ 7 files changed, 46 insertions(+), 92 deletions(-) diff --git a/apps/trading/client-pages/disclaimer/index.ts b/apps/trading/client-pages/disclaimer/index.ts index c47c92bfc..a5a11f6cd 100644 --- a/apps/trading/client-pages/disclaimer/index.ts +++ b/apps/trading/client-pages/disclaimer/index.ts @@ -1,3 +1 @@ -import { Disclaimer } from './disclaimer'; - -export default Disclaimer; +export { Disclaimer } from './disclaimer'; diff --git a/apps/trading/client-pages/home/index.ts b/apps/trading/client-pages/home/index.ts index 64a0ba43f..e331f58c5 100644 --- a/apps/trading/client-pages/home/index.ts +++ b/apps/trading/client-pages/home/index.ts @@ -1,3 +1 @@ -import { Home } from './home'; - -export default Home; +export { Home } from './home'; diff --git a/apps/trading/client-pages/liquidity/index.ts b/apps/trading/client-pages/liquidity/index.ts index 2b2228473..15a9df50e 100644 --- a/apps/trading/client-pages/liquidity/index.ts +++ b/apps/trading/client-pages/liquidity/index.ts @@ -1,3 +1 @@ -import { Liquidity } from './liquidity'; - -export default Liquidity; +export { Liquidity } from './liquidity'; diff --git a/apps/trading/client-pages/market/index.ts b/apps/trading/client-pages/market/index.ts index 22af22088..20f2a87f3 100644 --- a/apps/trading/client-pages/market/index.ts +++ b/apps/trading/client-pages/market/index.ts @@ -1,3 +1 @@ -import { MarketPage } from './market'; - -export default MarketPage; +export { MarketPage as default } from './market'; diff --git a/apps/trading/client-pages/markets/index.ts b/apps/trading/client-pages/markets/index.ts index 6141f6f03..64f1859fa 100644 --- a/apps/trading/client-pages/markets/index.ts +++ b/apps/trading/client-pages/markets/index.ts @@ -1,3 +1 @@ -import { MarketsPage } from './markets-page'; - -export default MarketsPage; +export { MarketsPage } from './markets-page'; diff --git a/apps/trading/client-pages/portfolio/index.ts b/apps/trading/client-pages/portfolio/index.ts index 7ae87c170..aab6c3eff 100644 --- a/apps/trading/client-pages/portfolio/index.ts +++ b/apps/trading/client-pages/portfolio/index.ts @@ -1,3 +1 @@ -import { Portfolio } from './portfolio'; - -export default Portfolio; +export { Portfolio as default } from './portfolio'; diff --git a/apps/trading/pages/client-router.tsx b/apps/trading/pages/client-router.tsx index 1bcbce6da..4d6aa2494 100644 --- a/apps/trading/pages/client-router.tsx +++ b/apps/trading/pages/client-router.tsx @@ -1,40 +1,23 @@ -import { Suspense } from 'react'; import type { RouteObject } from 'react-router-dom'; -import { Outlet, useRoutes } from 'react-router-dom'; -import dynamic from 'next/dynamic'; +import { Navigate, Outlet, useRoutes } from 'react-router-dom'; +import { lazy, Suspense } from 'react'; import { t } from '@vegaprotocol/i18n'; import { Loader, Splash } from '@vegaprotocol/ui-toolkit'; import trimEnd from 'lodash/trimEnd'; import { LayoutWithSidebar } from '../components/layouts'; import { LayoutCentered } from '../components/layouts/layout-centered'; +import { Home } from '../client-pages/home'; +import { Liquidity } from '../client-pages/liquidity'; +import { MarketsPage } from '../client-pages/markets'; +import { Disclaimer } from '../client-pages/disclaimer'; import { Transact } from '../client-pages/transact'; import { Deposit } from '../client-pages/deposit'; import { Withdraw } from '../client-pages/withdraw'; import { Transfer } from '../client-pages/transfer'; -const LazyHome = dynamic(() => import('../client-pages/home'), { - ssr: false, -}); - -const LazyLiquidity = dynamic(() => import('../client-pages/liquidity'), { - ssr: false, -}); - -const LazyMarkets = dynamic(() => import('../client-pages/markets'), { - ssr: false, -}); - -const LazyMarket = dynamic(() => import('../client-pages/market'), { - ssr: false, -}); - -const LazyPortfolio = dynamic(() => import('../client-pages/portfolio'), { - ssr: false, -}); - -const LazyDisclaimer = dynamic(() => import('../client-pages/disclaimer'), { - ssr: false, -}); +// These must remain dynamically imported as pennant cannot be compiled by nextjs +const MarketPage = lazy(() => import('../client-pages/market')); +const Portfolio = lazy(() => import('../client-pages/portfolio')); export enum Routes { HOME = '/', @@ -66,55 +49,43 @@ export const Links: ConsoleLinks = { [Routes.TRANSFER]: () => Routes.TRANSFER, }; -export const routerConfig: RouteObject[] = [ +const NotFound = () => ( + +

{t('Page not found')}

+
+); + +const routerConfig: RouteObject[] = [ { - path: '/*', + index: true, + element: , + }, + { + path: 'markets/*', element: , children: [ - // all pages that require the Layout component (Sidebar) { index: true, - element: , - id: Routes.HOME, + element: , }, { - path: 'markets', + path: 'all', + element: , + }, + { + path: ':marketId', element: , children: [ - { - path: 'all', - element: , - id: Routes.MARKETS, - }, - { - path: ':marketId', - element: , - id: Routes.MARKET, - }, - ], - }, - { - path: 'portfolio', - element: , - id: Routes.PORTFOLIO, - }, - { - path: 'liquidity', - element: , - children: [ - { - path: ':marketId', - element: , - id: Routes.LIQUIDITY, - }, + { index: true, element: }, + { path: 'liquidity', element: }, ], }, ], }, { - path: Routes.DISCLAIMER, - element: , - children: [{ index: true, element: }], + path: 'portfolio', + element: , + children: [{ index: true, element: }], }, { path: Routes.TRANSACT, @@ -126,19 +97,14 @@ export const routerConfig: RouteObject[] = [ { path: 'transfer', element: }, ], }, -<<<<<<< HEAD - { path: Routes.DEPOSIT, element: }, - { path: Routes.WITHDRAW, element: }, - { path: Routes.TRANSFER, element: }, -======= ->>>>>>> 35a90b2ec (feat: add shared layout page for transact routes) + { + path: Routes.DISCLAIMER, + element: , + children: [{ index: true, element: }], + }, { path: '*', - element: ( - -

{t('Not found')}

-
- ), + element: , }, ]; @@ -147,9 +113,9 @@ export const ClientRouter = () => { return ( + - + } > {routes}