-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Implement experimentalPrerender option
#7983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Stats from current PRClick to expand stats
Click to expand serverless stats
|
Contributor
Stats from current PRClick to expand stats
Click to expand serverless stats
|
Contributor
Stats from current PRClick to expand stats
Click to expand serverless stats
|
Contributor
Stats from current PRClick to expand stats
Click to expand serverless stats
|
Contributor
Stats from current PRClick to expand stats
Click to expand serverless stats
|
Contributor
Stats from current PRClick to expand stats
Click to expand serverless stats
|
Contributor
Stats from current PRClick to expand stats
|
| 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 | |
| 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 | -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 | |
Client main gzip Size |
6.86 kB | 6.91 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 | 705 kB |
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 | |
node_modules Size |
45.5 MB | 45.5 MB | |
| 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.1 kB | |
Client main gzip Size |
6.86 kB | 6.91 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 | 253 kB | |
Serverless pages/link gzip Size |
67.9 kB | 68.2 kB | |
Serverless pages/index Size |
245 kB | 245 kB | |
Serverless pages/index gzip Size |
65.7 kB | 66 kB | |
Serverless pages/_error Size |
244 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.5 kB | 65.7 kB | |
Serverless pages/routerDirect Size |
245 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.7 kB | 65.9 kB | |
Serverless pages/withRouter Size |
245 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.8 kB | 66 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
Contributor
Stats from current PRClick to expand stats
|
| 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 | |
| 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.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 | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | -72 B |
Client commons gzip Size |
61.1 kB | 61.1 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 | 705 kB | 705 kB |
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 | |
node_modules Size |
45.9 MB | 45.9 MB | |
| 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.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 | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | -72 B |
Client commons gzip Size |
61.1 kB | 61.1 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 | |
Serverless pages/link gzip Size |
68 kB | 68.1 kB | |
Serverless pages/index Size |
245 kB | 245 kB | |
Serverless pages/index gzip Size |
65.8 kB | 65.9 kB | |
Serverless pages/_error Size |
244 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.5 kB | 65.7 kB | |
Serverless pages/routerDirect Size |
246 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.7 kB | 65.9 kB | |
Serverless pages/withRouter Size |
245 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.9 kB | 66 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
Contributor
Stats from current PRClick to expand stats
|
| 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 | |
| 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.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 | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | -72 B |
Client commons gzip Size |
61.1 kB | 61.1 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 | 705 kB | 705 kB |
Click to expand serverless stats ⚠️ Total Bundle Size Increase ⚠️
| zeit/next.js canary | ijjk/next.js update/prerender | Change | |
|---|---|---|---|
| Build Duration | 13.8s | 14s | |
node_modules Size |
45.9 MB | 45.9 MB | |
| 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.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 | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | -72 B |
Client commons gzip Size |
61.1 kB | 61.1 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 | |
Serverless pages/link gzip Size |
68 kB | 68.1 kB | |
Serverless pages/index Size |
245 kB | 245 kB | |
Serverless pages/index gzip Size |
65.8 kB | 65.9 kB | |
Serverless pages/_error Size |
244 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.5 kB | 65.7 kB | |
Serverless pages/routerDirect Size |
246 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.7 kB | 65.9 kB | |
Serverless pages/withRouter Size |
245 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.9 kB | 66 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
Contributor
Stats from current PRClick to expand stats
|
| 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 | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 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 | 705 kB | 707 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 | |
node_modules Size |
45.9 MB | 45.9 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 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 | |
Serverless pages/link gzip Size |
68 kB | 68.3 kB | |
Serverless pages/index Size |
245 kB | 246 kB | |
Serverless pages/index gzip Size |
65.8 kB | 66.1 kB | |
Serverless pages/_error Size |
244 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.5 kB | 65.8 kB | |
Serverless pages/routerDirect Size |
246 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.7 kB | 66 kB | |
Serverless pages/withRouter Size |
245 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.9 kB | 66.2 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
Contributor
Stats from current PRClick to expand stats
|
| zeit/next.js canary | ijjk/next.js update/prerender | Change | |
|---|---|---|---|
| Build Duration | 14.1s | 14.3s | |
node_modules Size |
45.9 MB | 45.9 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 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 | 705 kB | 707 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 | |
node_modules Size |
45.9 MB | 45.9 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.33 kB | 5.38 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 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 | |
Serverless pages/link gzip Size |
68 kB | 68.3 kB | |
Serverless pages/index Size |
245 kB | 246 kB | |
Serverless pages/index gzip Size |
65.8 kB | 66.1 kB | |
Serverless pages/_error Size |
244 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.5 kB | 65.8 kB | |
Serverless pages/routerDirect Size |
246 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.7 kB | 66 kB | |
Serverless pages/withRouter Size |
245 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.9 kB | 66.2 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
Contributor
Stats from current PRClick to expand stats
|
| zeit/next.js canary | ijjk/next.js update/prerender | Change | |
|---|---|---|---|
| Build Duration | 12.8s | 13.2s | |
node_modules Size |
45.9 MB | 45.9 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.9 kB | 68.1 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 |
15.6 kB | 15.8 kB | |
Client main gzip Size |
5.39 kB | 5.45 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 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 | 703 kB | 706 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 | |
node_modules Size |
45.9 MB | 45.9 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.9 kB | 68.1 kB | |
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 | |
Client main gzip Size |
5.39 kB | 5.45 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 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 | |
Serverless pages/link gzip Size |
67.9 kB | 68.2 kB | |
Serverless pages/index Size |
244 kB | 245 kB | |
Serverless pages/index gzip Size |
65.8 kB | 66 kB | |
Serverless pages/_error Size |
244 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.5 kB | 65.8 kB | |
Serverless pages/routerDirect Size |
245 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.7 kB | 66 kB | |
Serverless pages/withRouter Size |
245 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.8 kB | 66.1 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
experimentalPrerender with additional modeexperimentalPrerender option
Timer
requested changes
Aug 4, 2019
Member
Author
Stats from current PRClick to expand stats
|
| 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 | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.35 kB | 5.4 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
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 |
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 | |
node_modules Size |
43.6 MB | 43.6 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.35 kB | 5.4 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
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 | |
Serverless pages/link gzip Size |
67.8 kB | 68.2 kB | |
Serverless pages/index Size |
244 kB | 245 kB | |
Serverless pages/index gzip Size |
65.6 kB | 66 kB | |
Serverless pages/_error Size |
243 kB | 245 kB | |
Serverless pages/_error gzip Size |
65.4 kB | 65.8 kB | |
Serverless pages/routerDirect Size |
244 kB | 246 kB | |
Serverless pages/routerDirect gzip Size |
65.6 kB | 66 kB | |
Serverless pages/withRouter Size |
244 kB | 246 kB | |
Serverless pages/withRouter gzip Size |
65.7 kB | 66.1 kB | |
| Build Dir Size | 1.89 MB | 1.9 MB |
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();
}
Timer
requested changes
Aug 5, 2019
Member
Author
Stats from current PRClick to expand stats
|
| 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 | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.35 kB | 5.41 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
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 |
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 | |
node_modules Size |
43.6 MB | 43.6 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.35 kB | 5.41 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
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 | |
Serverless pages/link gzip Size |
67.8 kB | 68.1 kB | |
Serverless pages/index Size |
243 kB | 245 kB | |
Serverless pages/index gzip Size |
65.6 kB | 66 kB | |
Serverless pages/_error Size |
243 kB | 244 kB | |
Serverless pages/_error gzip Size |
65.3 kB | 65.7 kB | |
Serverless pages/routerDirect Size |
244 kB | 245 kB | |
Serverless pages/routerDirect gzip Size |
65.5 kB | 65.9 kB | |
Serverless pages/withRouter Size |
244 kB | 245 kB | |
Serverless pages/withRouter gzip Size |
65.7 kB | 66 kB | |
| Build Dir Size | 1.88 MB | 1.89 MB |
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();
}
Member
Author
Stats from current PRClick to expand stats
|
| 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 | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.35 kB | 5.41 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
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 |
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 | |
node_modules Size |
43.6 MB | 43.6 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 206 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68 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 |
15.4 kB | 15.6 kB | |
Client main gzip Size |
5.35 kB | 5.41 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
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 | |
Serverless pages/link gzip Size |
67.8 kB | 68.2 kB | |
Serverless pages/index Size |
243 kB | 245 kB | |
Serverless pages/index gzip Size |
65.6 kB | 66 kB | |
Serverless pages/_error Size |
243 kB | 244 kB | |
Serverless pages/_error gzip Size |
65.3 kB | 65.7 kB | |
Serverless pages/routerDirect Size |
244 kB | 245 kB | |
Serverless pages/routerDirect gzip Size |
65.5 kB | 65.9 kB | |
Serverless pages/withRouter Size |
244 kB | 245 kB | |
Serverless pages/withRouter gzip Size |
65.7 kB | 66.1 kB | |
| Build Dir Size | 1.88 MB | 1.89 MB |
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();
}
This was referenced Aug 6, 2019
Timer
approved these changes
Aug 6, 2019
Member
Author
Stats from current PRClick to expand stats
|
| 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 | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68.1 kB | |
| Total Bundle (main, webpack, commons) Modern Size | 181 kB | 181 kB | |
| Total Bundle (main, webpack, commons) Modern gzip Size | 59.7 kB | 59.9 kB | |
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 | |
Client main gzip Size |
5.39 kB | 5.46 kB | |
Client main Modern Size |
12.7 kB | 12.8 kB | |
Client main Modern gzip Size |
4.77 kB | 4.83 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
Client commons Modern Size |
168 kB | 169 kB | |
Client commons Modern gzip Size |
54.9 kB | 55.1 kB | |
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 |
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 | |
node_modules Size |
43.6 MB | 43.6 MB | |
| Total Bundle (main, webpack, commons) Size | 206 kB | 207 kB | |
| Total Bundle (main, webpack, commons) gzip Size | 67.8 kB | 68.1 kB | |
| Total Bundle (main, webpack, commons) Modern Size | 181 kB | 181 kB | |
| Total Bundle (main, webpack, commons) Modern gzip Size | 59.7 kB | 59.9 kB | |
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 | |
Client main gzip Size |
5.39 kB | 5.46 kB | |
Client main Modern Size |
12.7 kB | 12.8 kB | |
Client main Modern gzip Size |
4.77 kB | 4.83 kB | |
Client commons Size |
188 kB | 188 kB | |
Client commons gzip Size |
61.1 kB | 61.3 kB | |
Client commons Modern Size |
168 kB | 169 kB | |
Client commons Modern gzip Size |
54.9 kB | 55.1 kB | |
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 | |
Serverless pages/link gzip Size |
68.1 kB | 68.5 kB | |
Serverless pages/index Size |
246 kB | 247 kB | |
Serverless pages/index gzip Size |
65.9 kB | 66.3 kB | |
Serverless pages/_error Size |
246 kB | 247 kB | |
Serverless pages/_error gzip Size |
65.7 kB | 66.1 kB | |
Serverless pages/routerDirect Size |
247 kB | 248 kB | |
Serverless pages/routerDirect gzip Size |
65.9 kB | 66.3 kB | |
Serverless pages/withRouter Size |
247 kB | 248 kB | |
Serverless pages/withRouter gzip Size |
66 kB | 66.4 kB | |
| Build Dir Size | 2.58 MB | 2.59 MB |
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;
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds an additional
experimentalPrerendermode for an alternative optimization.