feat(v2): webpack prefetch for better UX (#1071)

* feat(v2): webpack prefetch for better UX

* test snapshot update

* nits
This commit is contained in:
Endilie Yacop Sucipto 2018-10-27 13:48:10 +08:00 committed by GitHub
parent bbf355fdc7
commit f84332d0a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 7 deletions

View file

@ -17,7 +17,9 @@ async function genRoutesConfig({
path: ${JSON.stringify(permalink)},
exact: true,
component: Loadable({
loader: () => import(${JSON.stringify(source)}),
loader: () => import(/* webpackPrefetch: true */ ${JSON.stringify(
source,
)}),
loading: Loading,
render(loaded, props) {
let Content = loaded.default;
@ -38,7 +40,9 @@ async function genRoutesConfig({
path: ${JSON.stringify(permalink)},
exact: true,
component: Loadable({
loader: () => import(${JSON.stringify(source)}),
loader: () => import(/* webpackPrefetch: true */ ${JSON.stringify(
source,
)}),
loading: Loading,
render(loaded, props) {
let Content = loaded.default;
@ -63,7 +67,12 @@ async function genRoutesConfig({
component: Loadable.Map({
loader: {
${posts
.map((p, i) => `post${i}: () => import(${JSON.stringify(p.source)})`)
.map(
(p, i) =>
`post${i}: () => import(/* webpackPrefetch: true */ ${JSON.stringify(
p.source,
)})`,
)
.join(',\n\t\t\t\t')}
},
loading: Loading,
@ -86,7 +95,9 @@ async function genRoutesConfig({
path: ${JSON.stringify(permalink)},
exact: true,
component: Loadable({
loader: () => import(${JSON.stringify(source)}),
loader: () => import(/* webpackPrefetch: true */ ${JSON.stringify(
source,
)}),
loading: Loading,
render(loaded, props) {
let MarkdownContent = loaded.default;