lazy load store and explorer

This commit is contained in:
Martti Malmi 2022-06-28 13:55:19 +03:00
parent 7ebbada78b
commit 41a40bfd94
3 changed files with 34 additions and 10 deletions

View File

@ -59,6 +59,7 @@
"lodash": "^4.17.21",
"oldgun": "npm:gun@0.2020.1232",
"preact": "^10.5.14",
"preact-async-route": "^2.2.1",
"preact-custom-element": "^4.2.1",
"preact-render-to-string": "^5.1.19",
"preact-router": "^3.2.1",

View File

@ -1,5 +1,6 @@
import Component from './BaseComponent';
import { Router, RouterOnChangeArgs, CustomHistory } from 'preact-router';
import AsyncRoute from 'preact-async-route';
import { createHashHistory } from 'history';
import {Helmet} from "react-helmet";
@ -13,9 +14,6 @@ import LogoutConfirmation from './views/LogoutConfirmation';
import Chat from './views/chat/Chat';
import Notifications from './views/Notifications';
import Hashtags from './views/Hashtags';
import Store from './views/Store';
import Checkout from './views/Checkout';
import Product from './views/Product';
import Login from './views/Login';
import Profile from './views/Profile';
import Group from './views/Group';
@ -23,7 +21,6 @@ import Message from './views/Message';
import Follows from './views/Follows';
import Feed from './views/Feed';
import About from './views/About';
import Explorer from './views/Explorer';
import Contacts from './views/Contacts';
import Torrent from './views/Torrent';
@ -153,12 +150,33 @@ class Main extends Component<Props,State> {
<Profile path="/likes/:id+" tab="likes"/>
<Profile path="/media/:id+" tab="media"/>
<Group path="/group/:id+"/>
<Store path="/store/:store?"/>
<Checkout path="/checkout/:store?"/>
<Product path="/product/:product/:store"/>
<Product path="/product/new" store={Session.getPubKey()}/>
<Explorer path="/explorer/:node"/>
<Explorer path="/explorer"/>
{/* Lazy load stuff that is used less often */}
<AsyncRoute
path="/store/:store?"
getComponent={() => import('./views/Store').then(module => module.default)}
/>
<AsyncRoute
path="/checkout/:store?"
getComponent={() => import('./views/Checkout').then(module => module.default)}
/>
<AsyncRoute
path="/product/:product/:store"
getComponent={() => import('./views/Product').then(module => module.default)}
/>
<AsyncRoute
path="/product/new"
store={Session.getPubKey()}
getComponent={() => import('./views/Product').then(module => module.default)}
/>
<AsyncRoute
path="/explorer/:node"
getComponent={() => import('./views/Explorer').then(module => module.default)}
/>
<AsyncRoute
path="/explorer"
store={Session.getPubKey()}
getComponent={() => import('./views/Explorer').then(module => module.default)}
/>
<Follows path="/follows/:id"/>
<Follows followers={true} path="/followers/:id"/>
<Contacts path="/contacts"/>

View File

@ -9390,6 +9390,11 @@ postcss@^8.2.1, postcss@^8.2.10, postcss@^8.2.15:
picocolors "^1.0.0"
source-map-js "^1.0.1"
preact-async-route@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/preact-async-route/-/preact-async-route-2.2.1.tgz#729f8f8650281973251fbbf852d5004f32f48594"
integrity sha512-8bg1007akXs3YDmzYT4McaTe6ji2FIzcc0/NTlu+vjJaKPNQ8lNG/HQ6LP+FoIxQ4m/KH5vvJCHJN5ADp2iNGA==
preact-cli@^3.2.2:
version "3.3.5"
resolved "https://registry.npmjs.org/preact-cli/-/preact-cli-3.3.5.tgz"