File tree Expand file tree Collapse file tree 7 files changed +23
-14
lines changed
Expand file tree Collapse file tree 7 files changed +23
-14
lines changed Original file line number Diff line number Diff line change 1- import React from "react" ;
1+ import React , { Suspense } from "react" ;
22import { BrowserRouter } from "react-router-dom" ;
33import { StyleSheetManager } from "styled-components" ;
44
@@ -13,7 +13,9 @@ export const App = () => {
1313 < AuthContextProvider >
1414 < GlobalStyle />
1515 < BrowserRouter >
16- < Routes />
16+ < Suspense fallback = { < p > loading...</ p > } >
17+ < Routes />
18+ </ Suspense >
1719 </ BrowserRouter >
1820 </ AuthContextProvider >
1921 </ StyleSheetManager >
Original file line number Diff line number Diff line change 1- export * from "./Top" ;
1+ export { Top as default } from "./Top" ;
Original file line number Diff line number Diff line change 1- export * from "./Odds" ;
1+ export { Odds as default } from "./Odds" ;
Original file line number Diff line number Diff line change 1- export * from "./RaceCard" ;
1+ export { RaceCard as default } from "./RaceCard" ;
Original file line number Diff line number Diff line change 1- export * from "./RaceResult" ;
1+ export { RaceResult as default } from "./RaceResult" ;
Original file line number Diff line number Diff line change 1- import React from "react" ;
1+ import React , { lazy } from "react" ;
22import { Route , Routes as RouterRoutes } from "react-router-dom" ;
33
44import { CommonLayout } from "./layouts/CommonLayout" ;
5- import { Top } from "./pages/Top" ;
6- import { Odds } from "./pages/races/Odds" ;
7- import { RaceCard } from "./pages/races/RaceCard" ;
8- import { RaceResult } from "./pages/races/RaceResult" ;
5+
6+ const Top = lazy ( ( ) => import ( "./pages/Top" ) ) ;
7+ const Odds = lazy ( ( ) => import ( "./pages/races/Odds" ) ) ;
8+ const RaceCard = lazy ( ( ) => import ( "./pages/races/RaceCard" ) ) ;
9+ const RaceResult = lazy ( ( ) => import ( "./pages/races/RaceResult" ) ) ;
910
1011/** @type {React.VFC } */
1112export const Routes = ( ) => {
Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ const DIST_PUBLIC = abs("./dist/public");
1818/** @type {Array<import('webpack').Configuration> } */
1919module . exports = [
2020 {
21- // devtool: "inline-source-map",
22- entry : path . join ( SRC_ROOT , "client/index.jsx" ) ,
21+ entry : {
22+ main : path . join ( SRC_ROOT , "client/index.jsx" ) ,
23+ } ,
2324 mode : "production" ,
2425 module : {
2526 rules : [
@@ -42,8 +43,12 @@ module.exports = [
4243 [
4344 "@babel/preset-env" ,
4445 {
45- modules : "cjs" ,
4646 spec : true ,
47+ targets : {
48+ esmodules : true ,
49+ } ,
50+ // modules: "cjs",
51+ // modules: false,
4752 } ,
4853 ] ,
4954 "@babel/preset-react" ,
@@ -55,6 +60,7 @@ module.exports = [
5560 } ,
5661 name : "client" ,
5762 output : {
63+ chunkFilename : "[name].bundle.js" ,
5864 path : DIST_PUBLIC ,
5965 } ,
6066 plugins : [
You can’t perform that action at this time.
0 commit comments