Skip to content

Commit 93e2a51

Browse files
author
sw-yx
committed
use code splitting
1 parent 4e5e2b5 commit 93e2a51

File tree

4 files changed

+134
-24
lines changed

4 files changed

+134
-24
lines changed

.size-snapshot.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
{
22
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/reactNetlifyIdentityWidget.cjs.development.js": {
3-
"bundled": 11783,
4-
"minified": 7629,
5-
"gzipped": 1929
3+
"bundled": 12286,
4+
"minified": 7820,
5+
"gzipped": 1999
66
},
77
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/reactNetlifyIdentityWidget.cjs.production.js": {
8-
"bundled": 11783,
9-
"minified": 7629,
10-
"gzipped": 1929
8+
"bundled": 12286,
9+
"minified": 7820,
10+
"gzipped": 1999
1111
},
1212
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/reactNetlifyIdentityWidget.umd.development.js": {
13-
"bundled": 12704,
14-
"minified": 6636,
15-
"gzipped": 1884
13+
"bundled": 13231,
14+
"minified": 6790,
15+
"gzipped": 1950
1616
},
1717
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/reactNetlifyIdentityWidget.umd.production.js": {
18-
"bundled": 12704,
19-
"minified": 6636,
20-
"gzipped": 1884
18+
"bundled": 13231,
19+
"minified": 6790,
20+
"gzipped": 1950
2121
},
2222
"/Users/swyx/Netlify/react-netlify-identity-widget/dist/reactNetlifyIdentityWidget.es.production.js": {
23-
"bundled": 11548,
24-
"minified": 7397,
25-
"gzipped": 1869,
23+
"bundled": 12051,
24+
"minified": 7588,
25+
"gzipped": 1939,
2626
"treeshaked": {
2727
"rollup": {
28-
"code": 548,
29-
"import_statements": 125
28+
"code": 5599,
29+
"import_statements": 198
3030
},
3131
"webpack": {
32-
"code": 1709
32+
"code": 6907
3333
}
3434
}
3535
}

example/yarn.lock

+109-3
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,53 @@
13361336
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
13371337
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
13381338

1339+
"@reach/auto-id@^0.2.0":
1340+
version "0.2.0"
1341+
resolved "https://registry.yarnpkg.com/@reach/auto-id/-/auto-id-0.2.0.tgz#97f9e48fe736aa5c6f4f32cf73c1f19d005f8550"
1342+
integrity sha512-lVK/svL2HuQdp7jgvlrLkFsUx50Az9chAhxpiPwBqcS83I2pVWvXp98FOcSCCJCV++l115QmzHhFd+ycw1zLBg==
1343+
1344+
"@reach/component-component@^0.1.3":
1345+
version "0.1.3"
1346+
resolved "https://registry.yarnpkg.com/@reach/component-component/-/component-component-0.1.3.tgz#5d156319572dc38995b246f81878bc2577c517e5"
1347+
integrity sha512-a1USH7L3bEfDdPN4iNZGvMEFuBfkdG+QNybeyDv8RloVFgZYRoM+KGXyy2KOfEnTUM8QWDRSROwaL3+ts5Angg==
1348+
1349+
"@reach/dialog@^0.2.3":
1350+
version "0.2.7"
1351+
resolved "https://registry.yarnpkg.com/@reach/dialog/-/dialog-0.2.7.tgz#b0e1968a3df57471522bd7997c91ef81cd3a21a1"
1352+
integrity sha512-FY9qDA6H1TCUsoRNP7J+8y1hiBgIM58Yg5xvvayNOqD9BE7EodDLHrTqv6y6S9yre8aGu78jcuUinv2LeN/PRA==
1353+
dependencies:
1354+
"@reach/component-component" "^0.1.3"
1355+
"@reach/portal" "^0.2.1"
1356+
"@reach/utils" "^0.2.2"
1357+
react-focus-lock "^1.17.7"
1358+
react-remove-scroll "^1.0.2"
1359+
1360+
"@reach/portal@^0.2.1":
1361+
version "0.2.1"
1362+
resolved "https://registry.yarnpkg.com/@reach/portal/-/portal-0.2.1.tgz#07720b999e0063a9e179c14dbdc60fd991cfc9fa"
1363+
integrity sha512-pUQ0EtCcYm4ormEjJmdk4uzZCxOpaRHB8FDKJXy6q6GqRqQwZ4lAT1f2Tvw0DAmULmyZTpe1/heXY27Tdnct+Q==
1364+
dependencies:
1365+
"@reach/component-component" "^0.1.3"
1366+
1367+
"@reach/tabs@^0.1.3":
1368+
version "0.1.5"
1369+
resolved "https://registry.yarnpkg.com/@reach/tabs/-/tabs-0.1.5.tgz#0a3a8c863cc50ac661b3a66afea0f9315c8d8b2b"
1370+
integrity sha512-thQKlbN7kN/YoFfBjTVxAlRlYor0dFg7QnZwUN9v1OYFLHMoPpmwaQkae8mAEibRb4BPGgjnoSpdfco2lzP37A==
1371+
dependencies:
1372+
"@reach/auto-id" "^0.2.0"
1373+
"@reach/utils" "^0.2.2"
1374+
warning "^4.0.2"
1375+
1376+
"@reach/utils@^0.2.2":
1377+
version "0.2.2"
1378+
resolved "https://registry.yarnpkg.com/@reach/utils/-/utils-0.2.2.tgz#c3a05ae9fd1f921988ae8a89b5a0d28d1a2b92df"
1379+
integrity sha512-jYeIi46AA5jh2gfdXD/nInUYfeLp3girRafiajP7AVHF6B4hpYAzUSx/ZH4xmPyf5alut5rml2DHxrv+X+Xu+A==
1380+
1381+
"@reach/visually-hidden@^0.1.3":
1382+
version "0.1.4"
1383+
resolved "https://registry.yarnpkg.com/@reach/visually-hidden/-/visually-hidden-0.1.4.tgz#0dc4ecedf523004337214187db70a46183bd945b"
1384+
integrity sha512-QHbzXjflSlCvDd6vJwdwx16mSB+vUCCQMiU/wK/CgVNPibtpEiIbisyxkpZc55DyDFNUIqP91rSUsNae+ogGDQ==
1385+
13391386
"@svgr/babel-plugin-add-jsx-attribute@^4.0.0":
13401387
version "4.0.0"
13411388
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.0.0.tgz#5acf239cd2747b1a36ec7e708de05d914cb9b948"
@@ -4409,6 +4456,11 @@ flush-write-stream@^1.0.0:
44094456
inherits "^2.0.3"
44104457
readable-stream "^2.3.6"
44114458

4459+
focus-lock@^0.6.3:
4460+
version "0.6.3"
4461+
resolved "https://registry.yarnpkg.com/focus-lock/-/focus-lock-0.6.3.tgz#ef0e82ebac0023f841039d60bf329725d6438028"
4462+
integrity sha512-EU6ePgEauhWrzJEN5RtG1d1ayrWXhEnfzTjnieHj+jG9tNHDEhKTAnCn1TN3gs9h6XWCDH6cpeX1VXY/lzLwZg==
4463+
44124464
follow-redirects@^1.0.0:
44134465
version "1.6.1"
44144466
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.6.1.tgz#514973c44b5757368bad8bddfe52f81f015c94cb"
@@ -8283,6 +8335,14 @@ react-app-polyfill@^1.0.0:
82838335
regenerator-runtime "0.13.2"
82848336
whatwg-fetch "3.0.0"
82858337

8338+
react-clientside-effect@^1.2.0:
8339+
version "1.2.0"
8340+
resolved "https://registry.yarnpkg.com/react-clientside-effect/-/react-clientside-effect-1.2.0.tgz#db823695f75e9616a5e4dd6d908e5ea627fb2516"
8341+
integrity sha512-cVIsGG7SNHsQsCP4+fw7KFUB0HiYiU8hbvL640XaLCbZ31aK8/lj0qOKJ2K+xRjuQz/IM4Q4qclI0aEqTtcXtA==
8342+
dependencies:
8343+
"@babel/runtime" "^7.0.0"
8344+
shallowequal "^1.1.0"
8345+
82868346
react-dev-utils@^9.0.0:
82878347
version "9.0.0"
82888348
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-9.0.0.tgz#356d95db442441c5d4748e0e49f4fd1e71aecbbd"
@@ -8314,7 +8374,7 @@ react-dev-utils@^9.0.0:
83148374
strip-ansi "5.2.0"
83158375
text-table "0.2.0"
83168376

8317-
8377+
react-dom@^16.8.6:
83188378
version "16.8.6"
83198379
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f"
83208380
integrity sha512-1nL7PIq9LTL3fthPqwkvr2zY7phIPjYrT0jp4HjyEQrEROnw4dG41VVwi/wfoCneoleqrNX7iAD+pXebJZwrwA==
@@ -8329,6 +8389,16 @@ react-error-overlay@^5.1.5:
83298389
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-5.1.5.tgz#884530fd055476c764eaa8ab13b8ecf1f57bbf2c"
83308390
integrity sha512-O9JRum1Zq/qCPFH5qVEvDDrVun8Jv9vbHtZXCR1EuRj9sKg1xJTlHxBzU6AkCzpvxRLuiY4OKImy3cDLQ+UTdg==
83318391

8392+
react-focus-lock@^1.17.7:
8393+
version "1.19.1"
8394+
resolved "https://registry.yarnpkg.com/react-focus-lock/-/react-focus-lock-1.19.1.tgz#2f3429793edaefe2d077121f973ce5a3c7a0651a"
8395+
integrity sha512-TPpfiack1/nF4uttySfpxPk4rGZTLXlaZl7ncZg/ELAk24Iq2B1UUaUioID8H8dneUXqznT83JTNDHDj+kwryw==
8396+
dependencies:
8397+
"@babel/runtime" "^7.0.0"
8398+
focus-lock "^0.6.3"
8399+
prop-types "^15.6.2"
8400+
react-clientside-effect "^1.2.0"
8401+
83328402
react-is@^16.8.1:
83338403
version "16.8.1"
83348404
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.1.tgz#a80141e246eb894824fb4f2901c0c50ef31d4cdb"
@@ -8339,6 +8409,22 @@ react-is@^16.8.4:
83398409
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
83408410
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
83418411

8412+
react-remove-scroll-bar@^1.1.3:
8413+
version "1.1.4"
8414+
resolved "https://registry.yarnpkg.com/react-remove-scroll-bar/-/react-remove-scroll-bar-1.1.4.tgz#b035e973290fed6da0b479fe9e2bec296408fac8"
8415+
integrity sha512-I9oaQ1DC2Pn0pzfnRMW8Fo+4kRHq/OC9u8dC08JWBMS6ksE7bHpH45y2GhEY8ySC+PtlSVecqz+8mbuRwMSHUA==
8416+
dependencies:
8417+
react-style-singleton "^1.1.0"
8418+
tslib "^1.0.0"
8419+
8420+
react-remove-scroll@^1.0.2:
8421+
version "1.0.6"
8422+
resolved "https://registry.yarnpkg.com/react-remove-scroll/-/react-remove-scroll-1.0.6.tgz#8c5573255b4c526f8006f8643bb55fa10c410da2"
8423+
integrity sha512-iB2ToQE0sujPU7UZvdvu4LimuWRs5Fp4XO6HFO4PO8ohm4sBUZ/WiRtESwQ9X4DdP7f7yYlEChZaPDzh9faoFQ==
8424+
dependencies:
8425+
react-remove-scroll-bar "^1.1.3"
8426+
tslib "^1.0.0"
8427+
83428428
83438429
version "3.0.0"
83448430
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-3.0.0.tgz#a715613ef3eace025907b409cec8505096e0233e"
@@ -8397,7 +8483,15 @@ [email protected]:
83978483
optionalDependencies:
83988484
fsevents "2.0.6"
83998485

8400-
8486+
react-style-singleton@^1.1.0:
8487+
version "1.1.1"
8488+
resolved "https://registry.yarnpkg.com/react-style-singleton/-/react-style-singleton-1.1.1.tgz#b2b698765519da812b80f55ab3c5fc5d849a2e63"
8489+
integrity sha512-0JD+XC5veR3oxf7GzIXipr89sM8R3rWnOR/gpzIV0DnoRBrcTvvkqyMu9icDYqM/6CWJhYcH5Jdy6Nim7PmoTQ==
8490+
dependencies:
8491+
invariant "^2.2.4"
8492+
tslib "^1.0.0"
8493+
8494+
react@^16.8.6:
84018495
version "16.8.6"
84028496
resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
84038497
integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==
@@ -9021,6 +9115,11 @@ shallow-clone@^1.0.0:
90219115
kind-of "^5.0.0"
90229116
mixin-object "^2.0.1"
90239117

9118+
shallowequal@^1.1.0:
9119+
version "1.1.0"
9120+
resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
9121+
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==
9122+
90249123
shebang-command@^1.2.0:
90259124
version "1.2.0"
90269125
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
@@ -9723,7 +9822,7 @@ ts-pnp@^1.0.0:
97239822
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.0.0.tgz#44a3a9e8c13fcb711bcda75d7b576c21af120c9d"
97249823
integrity sha512-qgwM7eBrxFvZSXLtSvjf3c2mXwJOOGD49VlE+KocUGX95DuMdLc/psZHBnPpZL5b2NU7VtQGHRCWF3cNfe5kxQ==
97259824

9726-
tslib@^1.8.1, tslib@^1.9.0:
9825+
tslib@^1.0.0, tslib@^1.8.1, tslib@^1.9.0:
97279826
version "1.9.3"
97289827
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
97299828
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
@@ -10057,6 +10156,13 @@ walker@^1.0.7, walker@~1.0.5:
1005710156
dependencies:
1005810157
makeerror "1.0.x"
1005910158

10159+
warning@^4.0.2:
10160+
version "4.0.3"
10161+
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3"
10162+
integrity sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==
10163+
dependencies:
10164+
loose-envify "^1.0.0"
10165+
1006010166
watchpack@^1.5.0:
1006110167
version "1.6.0"
1006210168
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"

src/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ function Gate({ }: { onCloseDialog: Function }) {
3939
return isLoggedIn ? <LoggedInScreen /> : <LoggedOutScreen />
4040
}
4141

42-
export function Widget({ onCloseDialog }: { onCloseDialog: Function }) {
42+
export default function Widget({ onCloseDialog }: { onCloseDialog: Function }) {
4343
return <Gate onCloseDialog={onCloseDialog} />
4444
}

src/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import {
44
// DialogOverlay, DialogContent
55
} from "@reach/dialog"
66
import VisuallyHidden from "@reach/visually-hidden"
7-
import { Widget } from "./app"
7+
8+
const Widget = React.lazy(() => import("./app"))
9+
810
import { FormStateContextProvider, SettingContext } from "./context"
911

1012
import { Settings, useNetlifyIdentity as _useNetlifyIdentity } from "react-netlify-identity"
@@ -50,7 +52,9 @@ export function IdentityModal({ showDialog, onCloseDialog }: ModalProps) {
5052
<VisuallyHidden>Close</VisuallyHidden>
5153
</button>
5254
<FormStateContextProvider>
53-
<Widget onCloseDialog={onCloseDialog} />
55+
<React.Suspense fallback={<div>Loading...</div>}>
56+
<Widget onCloseDialog={onCloseDialog} />
57+
</React.Suspense>
5458
</FormStateContextProvider>
5559
</Dialog>
5660
</SettingContext.Provider>

0 commit comments

Comments
 (0)