Skip to content

Conversation

@ijjk
Copy link
Member

@ijjk ijjk commented Jul 15, 2019

Adds an additional experimentalPrerender mode for an alternative optimization.

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.6s 13.2s -414ms
node_modules Size 45.4 MB 45.5 MB ⚠️ +5.24 kB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 68.8 kB 68.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 222 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 23.7 kB 23.7 kB
Client main gzip Size 7.81 kB 7.81 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.36 kB 1.36 kB
Build Dir Size 756 kB 756 kB
Click to expand serverless stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.9s 13.8s -78ms
node_modules Size 45.4 MB 45.5 MB ⚠️ +5.24 kB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 68.8 kB 68.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 222 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 23.7 kB 23.7 kB
Client main gzip Size 7.81 kB 7.81 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 338 kB 338 kB ⚠️ +314 B
Serverless pages/link gzip Size 86.7 kB 86.9 kB ⚠️ +157 B
Serverless pages/index Size Error getting size Error getting size
Serverless pages/index gzip Size Error getting size Error getting size
Serverless pages/_error Size 328 kB 329 kB ⚠️ +314 B
Serverless pages/_error gzip Size 84 kB 84.2 kB ⚠️ +161 B
Serverless pages/routerDirect Size 329 kB 330 kB ⚠️ +314 B
Serverless pages/routerDirect gzip Size 84.3 kB 84.5 kB ⚠️ +157 B
Serverless pages/withRouter Size 329 kB 330 kB ⚠️ +314 B
Serverless pages/withRouter gzip Size 84.3 kB 84.4 kB ⚠️ +153 B
Build Dir Size 1.94 MB 1.94 MB ⚠️ +1.31 kB

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.3s 13.7s -665ms
node_modules Size 45.4 MB 45.5 MB ⚠️ +5.32 kB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 68.8 kB 68.8 kB ⚠️ +1 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB -1 B
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 224 B ⚠️ +2 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 300 B -1 B
Client main Size 23.7 kB 23.7 kB
Client main gzip Size 7.81 kB 7.81 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.36 kB 1.36 kB
Build Dir Size 756 kB 756 kB
Click to expand serverless stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 15.5s 15.1s -416ms
node_modules Size 45.4 MB 45.5 MB ⚠️ +5.32 kB
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 68.8 kB 68.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 222 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 23.7 kB 23.7 kB
Client main gzip Size 7.81 kB 7.81 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 338 kB 338 kB ⚠️ +314 B
Serverless pages/link gzip Size 86.7 kB 86.9 kB ⚠️ +155 B
Serverless pages/index Size Error getting size Error getting size
Serverless pages/index gzip Size Error getting size Error getting size
Serverless pages/_error Size 328 kB 329 kB ⚠️ +314 B
Serverless pages/_error gzip Size 84 kB 84.2 kB ⚠️ +159 B
Serverless pages/routerDirect Size 329 kB 330 kB ⚠️ +314 B
Serverless pages/routerDirect gzip Size 84.3 kB 84.5 kB ⚠️ +155 B
Serverless pages/withRouter Size 329 kB 330 kB ⚠️ +314 B
Serverless pages/withRouter gzip Size 84.3 kB 84.4 kB ⚠️ +151 B
Build Dir Size 1.94 MB 1.94 MB ⚠️ +1.31 kB

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.5s 13.3s -135ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +5.63 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 222 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 19.8 kB 19.8 kB
Client main gzip Size 6.78 kB 6.78 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.36 kB 1.36 kB
Build Dir Size 737 kB 737 kB
Click to expand serverless stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.9s 15.2s ⚠️ +276ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +5.63 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 222 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 19.8 kB 19.8 kB
Client main gzip Size 6.78 kB 6.78 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 338 kB 338 kB ⚠️ +314 B
Serverless pages/link gzip Size 86.9 kB 87 kB ⚠️ +158 B
Serverless pages/index Size Error getting size Error getting size
Serverless pages/index gzip Size Error getting size Error getting size
Serverless pages/_error Size 329 kB 329 kB ⚠️ +314 B
Serverless pages/_error gzip Size 84.2 kB 84.3 kB ⚠️ +157 B
Serverless pages/routerDirect Size 330 kB 330 kB ⚠️ +314 B
Serverless pages/routerDirect gzip Size 84.4 kB 84.6 kB ⚠️ +160 B
Serverless pages/withRouter Size 330 kB 330 kB ⚠️ +314 B
Serverless pages/withRouter gzip Size 84.4 kB 84.5 kB ⚠️ +154 B
Build Dir Size 1.94 MB 1.94 MB ⚠️ +1.31 kB

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.1s 12.6s -515ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +5.63 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 19.8 kB 19.8 kB
Client main gzip Size 6.78 kB 6.78 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.34 kB 1.34 kB
Build Dir Size 738 kB 738 kB
Click to expand serverless stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.3s 14.6s ⚠️ +357ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +5.63 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.14 kB 4.14 kB
Client pages/link gzip Size 1.82 kB 1.82 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 19.8 kB 19.8 kB
Client main gzip Size 6.78 kB 6.78 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 338 kB 338 kB ⚠️ +314 B
Serverless pages/link gzip Size 86.9 kB 87 kB ⚠️ +156 B
Serverless pages/index Size 329 kB 329 kB ⚠️ +314 B
Serverless pages/index gzip Size 84.4 kB 84.6 kB ⚠️ +155 B
Serverless pages/_error Size 329 kB 329 kB ⚠️ +314 B
Serverless pages/_error gzip Size 84.2 kB 84.3 kB ⚠️ +157 B
Serverless pages/routerDirect Size 330 kB 330 kB ⚠️ +314 B
Serverless pages/routerDirect gzip Size 84.4 kB 84.6 kB ⚠️ +161 B
Serverless pages/withRouter Size 330 kB 330 kB ⚠️ +314 B
Serverless pages/withRouter gzip Size 84.4 kB 84.5 kB ⚠️ +154 B
Build Dir Size 2.26 MB 2.27 MB ⚠️ +1.63 kB

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13s 13.1s ⚠️ +104ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +7.64 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 67.9 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 20 kB 20 kB
Client main gzip Size 6.86 kB 6.86 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 704 kB 704 kB
Click to expand serverless stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 15.2s 15.3s ⚠️ +116ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +7.64 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 67.9 kB ⚠️ +2 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB ⚠️ +1 B
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 300 B 301 B ⚠️ +1 B
Client main Size 20 kB 20 kB
Client main gzip Size 6.85 kB 6.86 kB ⚠️ +1 B
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 252 kB ⚠️ +387 B
Serverless pages/link gzip Size 67.9 kB 68 kB ⚠️ +132 B
Serverless pages/index Size 245 kB 245 kB ⚠️ +387 B
Serverless pages/index gzip Size 65.7 kB 65.9 kB ⚠️ +126 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +387 B
Serverless pages/_error gzip Size 65.5 kB 65.6 kB ⚠️ +127 B
Serverless pages/routerDirect Size 245 kB 246 kB ⚠️ +387 B
Serverless pages/routerDirect gzip Size 65.7 kB 65.8 kB ⚠️ +131 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +387 B
Serverless pages/withRouter gzip Size 65.8 kB 65.9 kB ⚠️ +119 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +1.99 kB

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.4s 13.2s -198ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +7.74 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 67.9 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 20 kB 20 kB
Client main gzip Size 6.86 kB 6.86 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 704 kB 704 kB
Click to expand serverless stats
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.8s 14.5s -240ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +7.74 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 67.9 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 20 kB 20 kB
Client main gzip Size 6.86 kB 6.86 kB
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 252 kB ⚠️ +387 B
Serverless pages/link gzip Size 67.9 kB 68 kB ⚠️ +134 B
Serverless pages/index Size 245 kB 245 kB ⚠️ +387 B
Serverless pages/index gzip Size 65.7 kB 65.9 kB ⚠️ +128 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +387 B
Serverless pages/_error gzip Size 65.5 kB 65.6 kB ⚠️ +128 B
Serverless pages/routerDirect Size 245 kB 246 kB ⚠️ +387 B
Serverless pages/routerDirect gzip Size 65.7 kB 65.8 kB ⚠️ +132 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +387 B
Serverless pages/withRouter gzip Size 65.8 kB 65.9 kB ⚠️ +120 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +1.99 kB

@ijjk ijjk force-pushed the update/prerender branch from 2d618f3 to 1725ad8 Compare July 28, 2019 06:41
@vercel vercel deleted a comment from github-actions bot Jul 28, 2019
@ijjk ijjk force-pushed the update/prerender branch from 1725ad8 to dd8a763 Compare July 28, 2019 06:53
@vercel vercel deleted a comment from github-actions bot Jul 28, 2019
@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.5s 13.1s -355ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +10.8 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +172 B
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 67.9 kB ⚠️ +55 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB -1 B
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 300 B -1 B
Client main Size 20 kB 20.1 kB ⚠️ +172 B
Client main gzip Size 6.86 kB 6.91 kB ⚠️ +56 B
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 704 kB 705 kB ⚠️ +863 B
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.2s 14.3s ⚠️ +100ms
node_modules Size 45.5 MB 45.5 MB ⚠️ +10.8 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +172 B
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 67.9 kB ⚠️ +56 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 20 kB 20.1 kB ⚠️ +172 B
Client main gzip Size 6.86 kB 6.91 kB ⚠️ +56 B
Client commons Size 184 kB 184 kB
Client commons gzip Size 59.7 kB 59.7 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 253 kB ⚠️ +710 B
Serverless pages/link gzip Size 67.9 kB 68.2 kB ⚠️ +238 B
Serverless pages/index Size 245 kB 245 kB ⚠️ +710 B
Serverless pages/index gzip Size 65.7 kB 66 kB ⚠️ +234 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +710 B
Serverless pages/_error gzip Size 65.5 kB 65.7 kB ⚠️ +232 B
Serverless pages/routerDirect Size 245 kB 246 kB ⚠️ +710 B
Serverless pages/routerDirect gzip Size 65.7 kB 65.9 kB ⚠️ +235 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +710 B
Serverless pages/withRouter gzip Size 65.8 kB 66 kB ⚠️ +212 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +4.47 kB
Diff for main.js
@@ -399,7 +399,7 @@ var _dataManager = __webpack_require__("cuFY");
 var _querystring = __webpack_require__("s4NR");
 
 var _isDynamic = __webpack_require__("kcOw");
-/* global location */
+/* global location, __NEXT_DATA__ */
 // Polyfill Promise globally
 // This is needed because Webpack's dynamic loading(common chunks) code
 // depends on Promise.
@@ -532,7 +532,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -612,16 +612,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(__NEXT_DATA__.skeleton && Component.__nextOrigGip)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.__nextOrigGip({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@ijjk ijjk force-pushed the update/prerender branch from d40da61 to 5c7f7f5 Compare July 29, 2019 21:01
@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 12.7s 12.6s -49ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +6.67 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +100 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB ⚠️ +64 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +172 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +56 B
Client commons Size 188 kB 188 kB -72 B
Client commons gzip Size 61.1 kB 61.1 kB ⚠️ +8 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 705 kB 705 kB ⚠️ +506 B
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.8s 13.9s ⚠️ +145ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +6.67 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +100 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB ⚠️ +64 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +172 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +56 B
Client commons Size 188 kB 188 kB -72 B
Client commons gzip Size 61.1 kB 61.1 kB ⚠️ +8 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 253 kB ⚠️ +430 B
Serverless pages/link gzip Size 68 kB 68.1 kB ⚠️ +154 B
Serverless pages/index Size 245 kB 245 kB ⚠️ +430 B
Serverless pages/index gzip Size 65.8 kB 65.9 kB ⚠️ +154 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +430 B
Serverless pages/_error gzip Size 65.5 kB 65.7 kB ⚠️ +151 B
Serverless pages/routerDirect Size 246 kB 246 kB ⚠️ +430 B
Serverless pages/routerDirect gzip Size 65.7 kB 65.9 kB ⚠️ +155 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +430 B
Serverless pages/withRouter gzip Size 65.9 kB 66 kB ⚠️ +138 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +2.51 kB
Diff for commons.js
@@ -3368,11 +3368,6 @@ function () {
           };
 
           _this3.getInitialProps(Component, ctx).then(function (props) {
-            // if data is inlined during prerender it is a string
-            if (props && typeof props.pageProps === 'string') {
-              props.pageProps = JSON.parse(props.pageProps);
-            }
-
             routeInfo.props = props;
             _this3.components[route] = routeInfo;
             resolve(routeInfo);
Diff for main.js
@@ -370,7 +370,7 @@ var _dataManager = __webpack_require__("cuFY");
 var _querystring = __webpack_require__("s4NR");
 
 var _isDynamic = __webpack_require__("kcOw");
-/* global location */
+/* global location, __NEXT_DATA__ */
 // Polyfill Promise globally
 // This is needed because Webpack's dynamic loading(common chunks) code
 // depends on Promise.
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -583,16 +583,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(__NEXT_DATA__.skeleton && Component.__nextOrigGip)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.__nextOrigGip({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 12.9s 12.8s -138ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +6.67 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +100 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB ⚠️ +64 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +172 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +56 B
Client commons Size 188 kB 188 kB -72 B
Client commons gzip Size 61.1 kB 61.1 kB ⚠️ +8 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 705 kB 705 kB ⚠️ +506 B
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.8s 14s ⚠️ +235ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +6.67 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +100 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 67.8 kB ⚠️ +64 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +172 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +56 B
Client commons Size 188 kB 188 kB -72 B
Client commons gzip Size 61.1 kB 61.1 kB ⚠️ +8 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 253 kB ⚠️ +430 B
Serverless pages/link gzip Size 68 kB 68.1 kB ⚠️ +151 B
Serverless pages/index Size 245 kB 245 kB ⚠️ +430 B
Serverless pages/index gzip Size 65.8 kB 65.9 kB ⚠️ +151 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +430 B
Serverless pages/_error gzip Size 65.5 kB 65.7 kB ⚠️ +148 B
Serverless pages/routerDirect Size 246 kB 246 kB ⚠️ +430 B
Serverless pages/routerDirect gzip Size 65.7 kB 65.9 kB ⚠️ +149 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +430 B
Serverless pages/withRouter gzip Size 65.9 kB 66 kB ⚠️ +135 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +2.51 kB
Diff for commons.js
@@ -3368,11 +3368,6 @@ function () {
           };
 
           _this3.getInitialProps(Component, ctx).then(function (props) {
-            // if data is inlined during prerender it is a string
-            if (props && typeof props.pageProps === 'string') {
-              props.pageProps = JSON.parse(props.pageProps);
-            }
-
             routeInfo.props = props;
             _this3.components[route] = routeInfo;
             resolve(routeInfo);
Diff for main.js
@@ -1,4 +1,4 @@
-(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[8],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{
 
 /***/ "+iuc":
 /***/ (function(module, exports, __webpack_require__) {
@@ -370,7 +370,7 @@ var _dataManager = __webpack_require__("cuFY");
 var _querystring = __webpack_require__("s4NR");
 
 var _isDynamic = __webpack_require__("kcOw");
-/* global location */
+/* global location, __NEXT_DATA__ */
 // Polyfill Promise globally
 // This is needed because Webpack's dynamic loading(common chunks) code
 // depends on Promise.
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -583,16 +583,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(__NEXT_DATA__.skeleton && Component.__nextOrigGip)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.__nextOrigGip({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.2s 12.9s -242ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +3.71 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +508 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +258 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +176 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +50 B
Client commons Size 188 kB 188 kB ⚠️ +332 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +208 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 705 kB 707 kB ⚠️ +2.67 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.1s 14.2s ⚠️ +161ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +3.71 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +508 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +258 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +176 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +50 B
Client commons Size 188 kB 188 kB ⚠️ +332 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +208 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 253 kB ⚠️ +888 B
Serverless pages/link gzip Size 68 kB 68.3 kB ⚠️ +296 B
Serverless pages/index Size 245 kB 246 kB ⚠️ +888 B
Serverless pages/index gzip Size 65.8 kB 66.1 kB ⚠️ +302 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +888 B
Serverless pages/_error gzip Size 65.5 kB 65.8 kB ⚠️ +294 B
Serverless pages/routerDirect Size 246 kB 246 kB ⚠️ +888 B
Serverless pages/routerDirect gzip Size 65.7 kB 66 kB ⚠️ +297 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +888 B
Serverless pages/withRouter gzip Size 65.9 kB 66.2 kB ⚠️ +293 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +7.44 kB
Diff for commons.js
@@ -3368,11 +3368,6 @@ function () {
           };
 
           _this3.getInitialProps(Component, ctx).then(function (props) {
-            // if data is inlined during prerender it is a string
-            if (props && typeof props.pageProps === 'string') {
-              props.pageProps = JSON.parse(props.pageProps);
-            }
-
             routeInfo.props = props;
             _this3.components[route] = routeInfo;
             resolve(routeInfo);
@@ -3596,7 +3591,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3609,22 +3604,71 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json();
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
                   Component: Component,
                   router: this,
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3632,10 +3676,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for main.js
@@ -370,7 +370,7 @@ var _dataManager = __webpack_require__("cuFY");
 var _querystring = __webpack_require__("s4NR");
 
 var _isDynamic = __webpack_require__("kcOw");
-/* global location */
+/* global location, __NEXT_DATA__ */
 // Polyfill Promise globally
 // This is needed because Webpack's dynamic loading(common chunks) code
 // depends on Promise.
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -583,16 +583,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.getInitialProps({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.1s 14.3s ⚠️ +129ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +3.71 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +508 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +258 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +176 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +50 B
Client commons Size 188 kB 188 kB ⚠️ +332 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +208 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 705 kB 707 kB ⚠️ +2.67 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 15.2s 15.4s ⚠️ +174ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +3.71 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +508 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +258 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +176 B
Client main gzip Size 5.33 kB 5.38 kB ⚠️ +50 B
Client commons Size 188 kB 188 kB ⚠️ +332 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +208 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 253 kB ⚠️ +888 B
Serverless pages/link gzip Size 68 kB 68.3 kB ⚠️ +295 B
Serverless pages/index Size 245 kB 246 kB ⚠️ +888 B
Serverless pages/index gzip Size 65.8 kB 66.1 kB ⚠️ +301 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +888 B
Serverless pages/_error gzip Size 65.5 kB 65.8 kB ⚠️ +293 B
Serverless pages/routerDirect Size 246 kB 246 kB ⚠️ +888 B
Serverless pages/routerDirect gzip Size 65.7 kB 66 kB ⚠️ +297 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +888 B
Serverless pages/withRouter gzip Size 65.9 kB 66.2 kB ⚠️ +293 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +7.44 kB
Diff for commons.js
@@ -3368,11 +3368,6 @@ function () {
           };
 
           _this3.getInitialProps(Component, ctx).then(function (props) {
-            // if data is inlined during prerender it is a string
-            if (props && typeof props.pageProps === 'string') {
-              props.pageProps = JSON.parse(props.pageProps);
-            }
-
             routeInfo.props = props;
             _this3.components[route] = routeInfo;
             resolve(routeInfo);
@@ -3596,7 +3591,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3609,22 +3604,71 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json();
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
                   Component: Component,
                   router: this,
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3632,10 +3676,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for main.js
@@ -370,7 +370,7 @@ var _dataManager = __webpack_require__("cuFY");
 var _querystring = __webpack_require__("s4NR");
 
 var _isDynamic = __webpack_require__("kcOw");
-/* global location */
+/* global location, __NEXT_DATA__ */
 // Polyfill Promise globally
 // This is needed because Webpack's dynamic loading(common chunks) code
 // depends on Promise.
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -583,16 +583,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.getInitialProps({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@github-actions
Copy link
Contributor

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 12.8s 13.2s ⚠️ +399ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +3.62 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +508 B
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 68.1 kB ⚠️ +230 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.6 kB 15.8 kB ⚠️ +176 B
Client main gzip Size 5.39 kB 5.45 kB ⚠️ +55 B
Client commons Size 188 kB 188 kB ⚠️ +332 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +175 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 703 kB 706 kB ⚠️ +2.67 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.6s 13.7s ⚠️ +103ms
node_modules Size 45.9 MB 45.9 MB ⚠️ +3.62 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +508 B
Total Bundle (main, webpack, commons) gzip Size 67.9 kB 68.1 kB ⚠️ +228 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB -1 B
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 300 B -1 B
Client main Size 15.6 kB 15.8 kB ⚠️ +176 B
Client main gzip Size 5.39 kB 5.45 kB ⚠️ +54 B
Client commons Size 188 kB 188 kB ⚠️ +332 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +175 B
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 252 kB 252 kB ⚠️ +836 B
Serverless pages/link gzip Size 67.9 kB 68.2 kB ⚠️ +270 B
Serverless pages/index Size 244 kB 245 kB ⚠️ +836 B
Serverless pages/index gzip Size 65.8 kB 66 kB ⚠️ +273 B
Serverless pages/_error Size 244 kB 245 kB ⚠️ +836 B
Serverless pages/_error gzip Size 65.5 kB 65.8 kB ⚠️ +266 B
Serverless pages/routerDirect Size 245 kB 246 kB ⚠️ +836 B
Serverless pages/routerDirect gzip Size 65.7 kB 66 kB ⚠️ +267 B
Serverless pages/withRouter Size 245 kB 246 kB ⚠️ +836 B
Serverless pages/withRouter gzip Size 65.8 kB 66.1 kB ⚠️ +259 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +7.18 kB
Diff for commons.js
@@ -3340,11 +3340,6 @@ function () {
           };
 
           _this3.getInitialProps(Component, ctx).then(function (props) {
-            // if data is inlined during prerender it is a string
-            if (props && typeof props.pageProps === 'string') {
-              props.pageProps = JSON.parse(props.pageProps);
-            }
-
             routeInfo.props = props;
             _this3.components[route] = routeInfo;
             resolve(routeInfo);
@@ -3568,7 +3563,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3581,23 +3576,72 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json();
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
-                  AppTree: this._wrapApp(App),
                   Component: Component,
+                  AppTree: this._wrapApp(App),
                   router: this,
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3605,10 +3649,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for main.js
@@ -370,7 +370,7 @@ var _dataManager = __webpack_require__("cuFY");
 var _querystring = __webpack_require__("s4NR");
 
 var _isDynamic = __webpack_require__("kcOw");
-/* global location */
+/* global location, __NEXT_DATA__ */
 // Polyfill Promise globally
 // This is needed because Webpack's dynamic loading(common chunks) code
 // depends on Promise.
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -584,16 +584,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.getInitialProps({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@Timer Timer changed the title Update experimentalPrerender with additional mode Implement experimentalPrerender option Aug 4, 2019
@ijjk
Copy link
Member Author

ijjk commented Aug 5, 2019

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14s 13.6s -399ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +8.44 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +631 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +259 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +183 B
Client main gzip Size 5.35 kB 5.4 kB ⚠️ +52 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 702 kB 705 kB ⚠️ +3.26 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.8s 15.7s ⚠️ +920ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +8.44 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +631 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +259 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +183 B
Client main gzip Size 5.35 kB 5.4 kB ⚠️ +52 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Serverless pages/link Size 251 kB 252 kB ⚠️ +1.27 kB
Serverless pages/link gzip Size 67.8 kB 68.2 kB ⚠️ +387 B
Serverless pages/index Size 244 kB 245 kB ⚠️ +1.27 kB
Serverless pages/index gzip Size 65.6 kB 66 kB ⚠️ +389 B
Serverless pages/_error Size 243 kB 245 kB ⚠️ +1.27 kB
Serverless pages/_error gzip Size 65.4 kB 65.8 kB ⚠️ +384 B
Serverless pages/routerDirect Size 244 kB 246 kB ⚠️ +1.27 kB
Serverless pages/routerDirect gzip Size 65.6 kB 66 kB ⚠️ +385 B
Serverless pages/withRouter Size 244 kB 246 kB ⚠️ +1.27 kB
Serverless pages/withRouter gzip Size 65.7 kB 66.1 kB ⚠️ +370 B
Build Dir Size 1.89 MB 1.9 MB ⚠️ +10.2 kB
Diff for commons.js
@@ -3563,7 +3563,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3576,7 +3576,59 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json()["catch"](function (err) {
+                  return {
+                    error: err.message
+                  };
+                });
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
                   AppTree: this._wrapApp(App),
                   Component: Component,
@@ -3584,15 +3636,16 @@ function () {
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3600,10 +3653,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for main.js
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -584,16 +584,35 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
+            };
+            render(renderCtx);
+
+            if (!(window.__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 31;
+              break;
+            }
+
+            _context.next = 29;
+            return Component.getInitialProps({
+              pathname: page,
+              asPath: asPath,
+              query: query
             });
+
+          case 29:
+            props.pageProps = _context.sent;
+            render(renderCtx);
+
+          case 31:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 32:
           case "end":
             return _context.stop();
         }

@ijjk ijjk requested a review from Timer August 5, 2019 17:38
@ijjk
Copy link
Member Author

ijjk commented Aug 6, 2019

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.2s 14s -255ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +9.32 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +688 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +268 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +240 B
Client main gzip Size 5.35 kB 5.41 kB ⚠️ +61 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 700 kB 704 kB ⚠️ +3.56 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.9s 15.1s ⚠️ +265ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +9.32 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +688 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +268 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +240 B
Client main gzip Size 5.35 kB 5.41 kB ⚠️ +61 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Serverless pages/link Size 251 kB 252 kB ⚠️ +1.27 kB
Serverless pages/link gzip Size 67.8 kB 68.1 kB ⚠️ +385 B
Serverless pages/index Size 243 kB 245 kB ⚠️ +1.27 kB
Serverless pages/index gzip Size 65.6 kB 66 kB ⚠️ +387 B
Serverless pages/_error Size 243 kB 244 kB ⚠️ +1.27 kB
Serverless pages/_error gzip Size 65.3 kB 65.7 kB ⚠️ +380 B
Serverless pages/routerDirect Size 244 kB 245 kB ⚠️ +1.27 kB
Serverless pages/routerDirect gzip Size 65.5 kB 65.9 kB ⚠️ +382 B
Serverless pages/withRouter Size 244 kB 245 kB ⚠️ +1.27 kB
Serverless pages/withRouter gzip Size 65.7 kB 66 kB ⚠️ +368 B
Build Dir Size 1.88 MB 1.89 MB ⚠️ +10.5 kB
Diff for commons.js
@@ -3563,7 +3563,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3576,7 +3576,59 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json()["catch"](function (err) {
+                  return {
+                    error: err.message
+                  };
+                });
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
                   AppTree: this._wrapApp(App),
                   Component: Component,
@@ -3584,15 +3636,16 @@ function () {
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3600,10 +3653,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for main.js
@@ -1,4 +1,4 @@
-(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[8],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{
 
 /***/ "+iuc":
 /***/ (function(module, exports, __webpack_require__) {
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx, appCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -584,16 +584,41 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
-            });
+            };
+            render(renderCtx);
+
+            if (!(window.__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 32;
+              break;
+            }
+
+            appCtx = {
+              router: router,
+              AppTree: wrapApp(App),
+              Component: Component,
+              ctx: {
+                pathname: page,
+                asPath: asPath,
+                query: query
+              }
+            };
+            _context.next = 30;
+            return App.getInitialProps(appCtx);
+
+          case 30:
+            props.pageProps = _context.sent.pageProps;
+            render(renderCtx);
+
+          case 32:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 33:
           case "end":
             return _context.stop();
         }

@ijjk
Copy link
Member Author

ijjk commented Aug 6, 2019

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 13.2s 12.8s -408ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +9.52 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +688 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +268 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +240 B
Client main gzip Size 5.35 kB 5.41 kB ⚠️ +61 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Base Rendered Size 1.35 kB 1.35 kB
Build Dir Size 700 kB 704 kB ⚠️ +3.56 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 14.1s 14.1s ⚠️ +86ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +9.52 kB
Total Bundle (main, webpack, commons) Size 206 kB 206 kB ⚠️ +688 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68 kB ⚠️ +268 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client main Size 15.4 kB 15.6 kB ⚠️ +240 B
Client main gzip Size 5.35 kB 5.41 kB ⚠️ +61 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Serverless pages/link Size 251 kB 252 kB ⚠️ +1.37 kB
Serverless pages/link gzip Size 67.8 kB 68.2 kB ⚠️ +421 B
Serverless pages/index Size 243 kB 245 kB ⚠️ +1.37 kB
Serverless pages/index gzip Size 65.6 kB 66 kB ⚠️ +425 B
Serverless pages/_error Size 243 kB 244 kB ⚠️ +1.37 kB
Serverless pages/_error gzip Size 65.3 kB 65.7 kB ⚠️ +415 B
Serverless pages/routerDirect Size 244 kB 245 kB ⚠️ +1.37 kB
Serverless pages/routerDirect gzip Size 65.5 kB 65.9 kB ⚠️ +418 B
Serverless pages/withRouter Size 244 kB 245 kB ⚠️ +1.37 kB
Serverless pages/withRouter gzip Size 65.7 kB 66.1 kB ⚠️ +402 B
Build Dir Size 1.88 MB 1.89 MB ⚠️ +11 kB
Diff for commons.js
@@ -3563,7 +3563,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3576,7 +3576,59 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json()["catch"](function (err) {
+                  return {
+                    error: err.message
+                  };
+                });
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
                   AppTree: this._wrapApp(App),
                   Component: Component,
@@ -3584,15 +3636,16 @@ function () {
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3600,10 +3653,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for main.js
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx, appCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -584,16 +584,41 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
-            });
+            };
+            render(renderCtx);
+
+            if (!(window.__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 32;
+              break;
+            }
+
+            appCtx = {
+              router: router,
+              AppTree: wrapApp(App),
+              Component: Component,
+              ctx: {
+                pathname: page,
+                asPath: asPath,
+                query: query
+              }
+            };
+            _context.next = 30;
+            return App.getInitialProps(appCtx);
+
+          case 30:
+            props.pageProps = _context.sent.pageProps;
+            render(renderCtx);
+
+          case 32:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 33:
           case "end":
             return _context.stop();
         }

@Timer Timer added this to the 9.1.0 milestone Aug 6, 2019
@ijjk
Copy link
Member Author

ijjk commented Aug 6, 2019

Stats from current PR

Click to expand stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 22.6s 22.2s -437ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +9.52 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +688 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68.1 kB ⚠️ +270 B
Total Bundle (main, webpack, commons) Modern Size 181 kB 181 kB ⚠️ +465 B
Total Bundle (main, webpack, commons) Modern gzip Size 59.7 kB 59.9 kB ⚠️ +199 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _app Modern Size 1.83 kB 1.83 kB
Client _app gzip Modern Size 890 B 890 B
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client _error Modern Size 5.85 kB 5.85 kB
Client _error gzip Modern Size 2.33 kB 2.33 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.7 kB 3.7 kB
Client pages/link gzip Modern Size 1.7 kB 1.7 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 15.6 kB 15.8 kB ⚠️ +240 B
Client main gzip Size 5.39 kB 5.46 kB ⚠️ +63 B
Client main Modern Size 12.7 kB 12.8 kB ⚠️ +197 B
Client main Modern gzip Size 4.77 kB 4.83 kB ⚠️ +65 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client commons Modern Size 168 kB 169 kB ⚠️ +268 B
Client commons Modern gzip Size 54.9 kB 55.1 kB ⚠️ +134 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Base Rendered Size 2.76 kB 2.76 kB
Build Dir Size 1.38 MB 1.39 MB ⚠️ +5.93 kB
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
zeit/next.js canary ijjk/next.js update/prerender Change
Build Duration 22.9s 22.9s ⚠️ +56ms
node_modules Size 43.6 MB 43.6 MB ⚠️ +9.52 kB
Total Bundle (main, webpack, commons) Size 206 kB 207 kB ⚠️ +688 B
Total Bundle (main, webpack, commons) gzip Size 67.8 kB 68.1 kB ⚠️ +270 B
Total Bundle (main, webpack, commons) Modern Size 181 kB 181 kB ⚠️ +465 B
Total Bundle (main, webpack, commons) Modern gzip Size 59.7 kB 59.9 kB ⚠️ +199 B
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _app Modern Size 1.83 kB 1.83 kB
Client _app gzip Modern Size 890 B 890 B
Client _error Size 8.22 kB 8.22 kB
Client _error gzip Size 3.16 kB 3.16 kB
Client _error Modern Size 5.85 kB 5.85 kB
Client _error gzip Modern Size 2.33 kB 2.33 kB
Client pages/index Size 343 B 343 B
Client pages/index gzip Size 246 B 246 B
Client pages/index Modern Size 319 B 319 B
Client pages/index gzip Modern Size 254 B 254 B
Client pages/link Size 4.08 kB 4.08 kB
Client pages/link gzip Size 1.8 kB 1.8 kB
Client pages/link Modern Size 3.7 kB 3.7 kB
Client pages/link gzip Modern Size 1.7 kB 1.7 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/routerDirect Modern Size 411 B 411 B
Client pages/routerDirect gzip Modern Size 314 B 314 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 301 B
Client pages/withRouter Modern Size 423 B 423 B
Client pages/withRouter gzip Modern Size 309 B 309 B
Client main Size 15.6 kB 15.8 kB ⚠️ +240 B
Client main gzip Size 5.39 kB 5.46 kB ⚠️ +63 B
Client main Modern Size 12.7 kB 12.8 kB ⚠️ +197 B
Client main Modern gzip Size 4.77 kB 4.83 kB ⚠️ +65 B
Client commons Size 188 kB 188 kB ⚠️ +448 B
Client commons gzip Size 61.1 kB 61.3 kB ⚠️ +207 B
Client commons Modern Size 168 kB 169 kB ⚠️ +268 B
Client commons Modern gzip Size 54.9 kB 55.1 kB ⚠️ +134 B
Client webpack Size 1.53 kB 1.53 kB
Client webpack gzip Size 778 B 778 B
Client webpack Modern Size 1.53 kB 1.53 kB
Client webpack Modern gzip Size 785 B 785 B
Serverless pages/link Size 253 kB 255 kB ⚠️ +1.37 kB
Serverless pages/link gzip Size 68.1 kB 68.5 kB ⚠️ +397 B
Serverless pages/index Size 246 kB 247 kB ⚠️ +1.37 kB
Serverless pages/index gzip Size 65.9 kB 66.3 kB ⚠️ +400 B
Serverless pages/_error Size 246 kB 247 kB ⚠️ +1.37 kB
Serverless pages/_error gzip Size 65.7 kB 66.1 kB ⚠️ +396 B
Serverless pages/routerDirect Size 247 kB 248 kB ⚠️ +1.37 kB
Serverless pages/routerDirect gzip Size 65.9 kB 66.3 kB ⚠️ +398 B
Serverless pages/withRouter Size 247 kB 248 kB ⚠️ +1.37 kB
Serverless pages/withRouter gzip Size 66 kB 66.4 kB ⚠️ +396 B
Build Dir Size 2.58 MB 2.59 MB ⚠️ +13.4 kB
Diff for main.js
@@ -503,7 +503,7 @@ function () {
   var _ref2 = (0, _asyncToGenerator2["default"])(
   /*#__PURE__*/
   _regenerator["default"].mark(function _callee(_temp) {
-    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType;
+    var _ref, passedWebpackHMR, initialErr, _require, isValidElementType, renderCtx, appCtx;
 
     return _regenerator["default"].wrap(function _callee$(_context) {
       while (1) {
@@ -584,16 +584,41 @@ function () {
                 });
               }
             });
-            render({
+            renderCtx = {
               App: App,
               Component: Component,
               props: props,
               err: initialErr,
               emitter: emitter
-            });
+            };
+            render(renderCtx);
+
+            if (!(window.__NEXT_DATA__.skeleton && Component.getInitialProps)) {
+              _context.next = 32;
+              break;
+            }
+
+            appCtx = {
+              router: router,
+              AppTree: wrapApp(App),
+              Component: Component,
+              ctx: {
+                pathname: page,
+                asPath: asPath,
+                query: query
+              }
+            };
+            _context.next = 30;
+            return App.getInitialProps(appCtx);
+
+          case 30:
+            props.pageProps = _context.sent.pageProps;
+            render(renderCtx);
+
+          case 32:
             return _context.abrupt("return", emitter);
 
-          case 26:
+          case 33:
           case "end":
             return _context.stop();
         }
Diff for commons.js
@@ -3563,7 +3563,7 @@ function () {
       var _getInitialProps = (0, _asyncToGenerator2["default"])(
       /*#__PURE__*/
       _regenerator["default"].mark(function _callee2(Component, ctx) {
-        var cancelled, cancel, App, props, err;
+        var cancelled, cancel, App, props, url, res, err;
         return _regenerator["default"].wrap(function _callee2$(_context2) {
           while (1) {
             switch (_context2.prev = _context2.next) {
@@ -3576,7 +3576,59 @@ function () {
 
                 this.clc = cancel;
                 App = this.components['/_app'].Component;
-                _context2.next = 6;
+
+                if (!Component.__NEXT_PRERENDER) {
+                  _context2.next = 20;
+                  break;
+                }
+
+                url = url_1.format({
+                  pathname: ctx.asPath,
+                  query: ctx.query
+                });
+                _context2.next = 8;
+                return fetch(url, {
+                  headers: {
+                    'content-type': 'application/json'
+                  }
+                });
+
+              case 8:
+                res = _context2.sent;
+
+                if (!res.ok) {
+                  _context2.next = 15;
+                  break;
+                }
+
+                _context2.next = 12;
+                return res.json()["catch"](function (err) {
+                  return {
+                    error: err.message
+                  };
+                });
+
+              case 12:
+                _context2.t0 = _context2.sent;
+                _context2.next = 16;
+                break;
+
+              case 15:
+                _context2.t0 = {
+                  error: 'failed to load prerender',
+                  statusCode: res.status
+                };
+
+              case 16:
+                _context2.t1 = _context2.t0;
+                props = {
+                  pageProps: _context2.t1
+                };
+                _context2.next = 23;
+                break;
+
+              case 20:
+                _context2.next = 22;
                 return utils_1.loadGetInitialProps(App, {
                   AppTree: this._wrapApp(App),
                   Component: Component,
@@ -3584,15 +3636,16 @@ function () {
                   ctx: ctx
                 });
 
-              case 6:
+              case 22:
                 props = _context2.sent;
 
+              case 23:
                 if (cancel === this.clc) {
                   this.clc = null;
                 }
 
                 if (!cancelled) {
-                  _context2.next = 12;
+                  _context2.next = 28;
                   break;
                 }
 
@@ -3600,10 +3653,10 @@ function () {
                 err.cancelled = true;
                 throw err;
 
-              case 12:
+              case 28:
                 return _context2.abrupt("return", props);
 
-              case 13:
+              case 29:
               case "end":
                 return _context2.stop();
             }
Diff for mainModern.js
@@ -495,13 +495,30 @@ function () {
         });
       }
     });
-    render({
+    const renderCtx = {
       App,
       Component,
       props,
       err: initialErr,
       emitter
-    });
+    };
+    render(renderCtx);
+
+    if (window.__NEXT_DATA__.skeleton && Component.getInitialProps) {
+      const appCtx = {
+        router,
+        AppTree: wrapApp(App),
+        Component: Component,
+        ctx: {
+          pathname: page,
+          asPath,
+          query
+        }
+      };
+      props.pageProps = (yield App.getInitialProps(appCtx)).pageProps;
+      render(renderCtx);
+    }
+
     return emitter;
   });
 
Diff for commonsModern.js
@@ -2989,12 +2989,34 @@ class Router {
     const {
       Component: App
     } = this.components['/_app'];
-    const props = await utils_1.loadGetInitialProps(App, {
-      AppTree: this._wrapApp(App),
-      Component,
-      router: this,
-      ctx
-    });
+    let props;
+
+    if (Component.__NEXT_PRERENDER) {
+      const url = url_1.format({
+        pathname: ctx.asPath,
+        query: ctx.query
+      });
+      const res = await fetch(url, {
+        headers: {
+          'content-type': 'application/json'
+        }
+      });
+      props = {
+        pageProps: res.ok ? await res.json().catch(err => ({
+          error: err.message
+        })) : {
+          error: 'failed to load prerender',
+          statusCode: res.status
+        }
+      };
+    } else {
+      props = await utils_1.loadGetInitialProps(App, {
+        AppTree: this._wrapApp(App),
+        Component,
+        router: this,
+        ctx
+      });
+    }
 
     if (cancel === this.clc) {
       this.clc = null;

@ijjk ijjk merged commit ca13752 into vercel:canary Aug 6, 2019
@ijjk ijjk deleted the update/prerender branch August 6, 2019 20:26
@vercel vercel locked as resolved and limited conversation to collaborators Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants