Skip to content

Commit

Permalink
Code splitting (#18)
Browse files Browse the repository at this point in the history
* add bundle analyzer

* peer deps missing

* lock

* travis yarn

* run bundlesize in ci

* Revert "run bundlesize in ci"

This reverts commit bbdcda2.

* react-loadable
  • Loading branch information
chrisdopuch authored Jan 19, 2019
1 parent ec60e9d commit 45682f8
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 19 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ language: node_js
node_js:
- "stable"

cache:
directories:
- "node_modules"
cache: yarn

script:
- npm run lint
- npm test
- npm run coveralls
- yarn lint
- yarn build
- yarn test
- yarn coveralls
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build:stats": "react-scripts build --stats && webpack-bundle-analyzer build/bundle-stats.json -m static -r build/bundle-stats.html -O",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "tslint -p tsconfig.json",
Expand All @@ -15,19 +16,24 @@
},
"dependencies": {
"@material-ui/core": "^3.2.2",
"@types/react-loadable": "^5.5.0",
"lodash": "^4.17.11",
"material-ui": "^0.20.2",
"prop-types": "^15.6.0",
"react": "16.7.0-alpha.2",
"react-dom": "16.7.0-alpha.2",
"react-ga": "^2.5.3",
"react-grid-gallery": "^0.5.3",
"react-hookstore": "^1.1.5",
"react-loadable": "^5.5.0",
"react-router-dom": "^4.3.1",
"react-social-github": "^2.1.1",
"react-twitter-widgets": "^1.7.1",
"tslint-react": "^3.6.0"
"tslint-react": "^3.6.0",
"webpack-bundle-analyzer": "^3.0.3"
},
"devDependencies": {
"@babel/core": "^7.0.0-0",
"@material-ui/icons": "^3.0.1",
"@types/enzyme": "^3.1.14",
"@types/jest": "^23.3.10",
Expand Down
22 changes: 19 additions & 3 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import CircularProgress from '@material-ui/core/CircularProgress';
import CssBaseline from '@material-ui/core/CssBaseline';
import { createStyles, MuiThemeProvider, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
import CameraIcon from '@material-ui/icons/Camera';
import HelpIcon from '@material-ui/icons/Help';
import HomeIcon from '@material-ui/icons/Home';
import React from 'react';
import { useStore } from 'react-hookstore';
import Loadable from 'react-loadable';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { IAppStore } from '../store';
import { appTheme, darkTheme } from '../themes';
import NavDrawer from './NavDrawer';
import About from './pages/About';
import Gallery from './pages/Gallery';
import Home from './pages/Home';
import TitleBar from './TitleBar';

const loading = () => {
return <CircularProgress />;
};

const About = Loadable({
loader: () => import('./pages/About'),
loading,
});
const Gallery = Loadable({
loader: () => import('./pages/Gallery'),
loading,
});
const Home = Loadable({
loader: () => import('./pages/Home'),
loading,
});

const navBarItems = [
{ to: '/', label: 'Home', Icon: HomeIcon, isRouteExact: true, page: Home },
{ to: '/about', label: 'About me', Icon: HelpIcon, isRouteExact: false, page: About },
Expand Down
89 changes: 80 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/core@^7.0.1":
"@babel/core@^7.0.0-0", "@babel/core@^7.0.1":
version "7.2.2"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.2.2.tgz#07adba6dde27bb5ad8d8672f15fde3e08184a687"
integrity sha512-59vB0RWt09cAct5EIe58+NzGP4TFSD3Bz//2/ELy3ZeTeKF6VTD1AXlH8BGGbCX0PuobZBsIzO7IAI9PH67eKw==
Expand Down Expand Up @@ -976,6 +976,11 @@
"@svgr/core" "^2.4.1"
loader-utils "^1.1.0"

"@types/anymatch@*":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.0.tgz#d1d55958d1fccc5527d4aba29fc9c4b942f563ff"
integrity sha512-7WcbyctkE8GTzogDb0ulRAEw7v8oIS54ft9mQTU7PfM0hp5e+8kpa+HeQ7IQrFbKtJXBKcZ4bh+Em9dTw5L6AQ==

"@types/cheerio@*":
version "0.22.10"
resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.10.tgz#780d552467824be4a241b29510a7873a7432c4a6"
Expand Down Expand Up @@ -1035,6 +1040,14 @@
"@types/react-hookstore@file:types/react-hookstore":
version "1.0.8"

"@types/react-loadable@^5.5.0":
version "5.5.0"
resolved "https://registry.yarnpkg.com/@types/react-loadable/-/react-loadable-5.5.0.tgz#7a878408ad940250aeb91d77d2b54a18f3c7c946"
integrity sha512-evH/O6Wytz6lSmi36YL7YHnFc46zRPSA8+XNtTXI4D7A/CP7OVwcWbHjb2yGbh/jDxxhnTwIVO/PeqDXtUegnQ==
dependencies:
"@types/react" "*"
"@types/webpack" "*"

"@types/react-router-dom@^4.3.1":
version "4.3.1"
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-4.3.1.tgz#71fe2918f8f60474a891520def40a63997dafe04"
Expand Down Expand Up @@ -1067,11 +1080,34 @@
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/tapable@*":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ==

"@types/[email protected]":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.2.tgz#e13182e1b69871a422d7863e11a4a6f5b814a4bd"
integrity sha512-42zEJkBpNfMEAvWR5WlwtTH22oDzcMjFsL9gDGExwF8X8WvAiw7Vwop7hPw03QT8TKfec83LwbHj6SvpqM4ELQ==

"@types/uglify-js@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
integrity sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ==
dependencies:
source-map "^0.6.1"

"@types/webpack@*":
version "4.4.23"
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.4.23.tgz#059d6f4598cfd65ddee0e2db38317ef989696712"
integrity sha512-WswyG+2mRg0ul/ytPpCSWo+kOlVVPW/fKCBEVwqmPVC/2ffWEwhsCEQgnFbWDf8EWId2qGcpL623EjLfNTRk9A==
dependencies:
"@types/anymatch" "*"
"@types/node" "*"
"@types/tapable" "*"
"@types/uglify-js" "*"
source-map "^0.6.0"

"@webassemblyjs/[email protected]":
version "1.7.6"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.6.tgz#3ef8c45b3e5e943a153a05281317474fef63e21e"
Expand Down Expand Up @@ -1272,7 +1308,7 @@ acorn-walk@^6.0.1:
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.1.1.tgz#d363b66f5fac5f018ff9c3a1e7b6f8e310cc3913"
integrity sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==

acorn@^5.0.0, acorn@^5.5.3, acorn@^5.6.2:
acorn@^5.0.0, acorn@^5.5.3, acorn@^5.6.2, acorn@^5.7.3:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
Expand Down Expand Up @@ -1905,7 +1941,7 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

[email protected]:
[email protected], bfj@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.1.tgz#05a3b7784fbd72cfa3c22e56002ef99336516c48"
integrity sha512-+GUNvzHR4nRyGybQc2WpNJL4MJazMuvf92ueIyA0bIkPRwhhQu3IfZQ2PSoVPpCBJfmoSdOxu5rnotfFLlvYRQ==
Expand Down Expand Up @@ -2577,7 +2613,7 @@ [email protected]:
dependencies:
graceful-readlink ">= 1.0.0"

commander@^2.11.0, commander@^2.12.1, commander@^2.19.0:
commander@^2.11.0, commander@^2.12.1, commander@^2.18.0, commander@^2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
Expand Down Expand Up @@ -3463,6 +3499,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=

ejs@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.6.1.tgz#498ec0d495655abc6f23cd61868d926464071aa0"
integrity sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==

electron-to-chromium@^1.3.100, electron-to-chromium@^1.3.62:
version "1.3.103"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.103.tgz#a695777efdbc419cad6cbb0e58458251302cd52f"
Expand Down Expand Up @@ -3992,7 +4033,7 @@ expect@^23.6.0:
jest-message-util "^23.4.0"
jest-regex-util "^23.3.0"

express@^4.16.2:
express@^4.16.2, express@^4.16.3:
version "4.16.4"
resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e"
integrity sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==
Expand Down Expand Up @@ -4200,7 +4241,7 @@ fileset@^2.0.2:
glob "^7.0.3"
minimatch "^3.0.3"

[email protected]:
[email protected], filesize@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.6.1.tgz#090bb3ee01b6f801a8a8be99d31710b3422bb317"
integrity sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==
Expand Down Expand Up @@ -4656,7 +4697,7 @@ growly@^1.3.0:
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=

[email protected]:
[email protected], gzip-size@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.0.0.tgz#a55ecd99222f4c48fd8c01c625ce3b349d0a0e80"
integrity sha512-5iI7omclyqrnWw4XbXAmGhPsABkSIDQonv2K0h61lybgofWa6iZyvrI3r2zsJH4P8Nb64fFVzlvfhs0g7BBxAA==
Expand Down Expand Up @@ -7425,6 +7466,11 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"

opener@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed"
integrity sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==

[email protected], opn@^5.1.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/opn/-/opn-5.4.0.tgz#cb545e7aab78562beb11aa3bfabc7042e1761035"
Expand Down Expand Up @@ -8588,7 +8634,7 @@ prompts@^0.1.9:
kleur "^2.0.1"
sisteransi "^0.1.1"

prop-types@^15.3.0, prop-types@^15.5.6, prop-types@^15.5.7, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
prop-types@^15.3.0, prop-types@^15.5.0, prop-types@^15.5.6, prop-types@^15.5.7, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==
Expand Down Expand Up @@ -8882,6 +8928,13 @@ react-lifecycles-compat@^3.0.2, react-lifecycles-compat@^3.0.4:
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==

react-loadable@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/react-loadable/-/react-loadable-5.5.0.tgz#582251679d3da86c32aae2c8e689c59f1196d8c4"
integrity sha512-C8Aui0ZpMd4KokxRdVAm2bQtI03k2RMRNzOB+IipV3yxFTSVICv7WoUr5L9ALB5BmKO1iHgZtWM8EvYG83otdg==
dependencies:
prop-types "^15.5.0"

react-octicons@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/react-octicons/-/react-octicons-0.2.0.tgz#50cfcc6a4d3a75c2f8acf116bcbdfdd7e0b01513"
Expand Down Expand Up @@ -10855,6 +10908,24 @@ webidl-conversions@^4.0.2:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==

webpack-bundle-analyzer@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.0.3.tgz#dbc7fff8f52058b6714a20fddf309d0790e3e0a0"
integrity sha512-naLWiRfmtH4UJgtUktRTLw6FdoZJ2RvCR9ePbwM9aRMsS/KjFerkPZG9epEvXRAw5d5oPdrs9+3p+afNjxW8Xw==
dependencies:
acorn "^5.7.3"
bfj "^6.1.1"
chalk "^2.4.1"
commander "^2.18.0"
ejs "^2.6.1"
express "^4.16.3"
filesize "^3.6.1"
gzip-size "^5.0.0"
lodash "^4.17.10"
mkdirp "^0.5.1"
opener "^1.5.1"
ws "^6.0.0"

[email protected]:
version "3.4.0"
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-3.4.0.tgz#1132fecc9026fd90f0ecedac5cbff75d1fb45890"
Expand Down Expand Up @@ -11208,7 +11279,7 @@ ws@^5.2.0:
dependencies:
async-limiter "~1.0.0"

ws@^6.1.2:
ws@^6.0.0, ws@^6.1.2:
version "6.1.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.2.tgz#3cc7462e98792f0ac679424148903ded3b9c3ad8"
integrity sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw==
Expand Down

0 comments on commit 45682f8

Please sign in to comment.