-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Add isReady field on router #20628
Add isReady field on router #20628
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
buildDuration | 8.8s | 8.8s | |
nodeModulesSize | 83 MB | 83 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.786 | 1.722 | -0.06 |
/ avg req/sec | 1399.79 | 1451.98 | +52.19 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.139 | 1.081 | -0.06 |
/error-in-render avg req/sec | 2195.22 | 2313.27 | +118.05 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
677f882d2ed8..6cec.js gzip | 12.8 kB | 12.8 kB | |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-b45d971..6435.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-7193..1446.js gzip | 751 B | 751 B | ✓ |
Overall change | 59.1 kB | 59.2 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
polyfills-67..b7d1.js gzip | 31.2 kB | 31.2 kB | ✓ |
Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_app-6220e08..9a40.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-4b0b5..2c91.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-5f309a..7282.js gzip | 887 B | 887 B | ✓ |
index-57f580..c562.js gzip | 227 B | 227 B | ✓ |
link-1a1f628..eeb5.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..bd82.js gzip | 303 B | 303 B | ✓ |
withRouter-2..e384.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.05 kB | 8.05 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
index.html gzip | 617 B | 616 B | -1 B |
link.html gzip | 622 B | 621 B | -1 B |
withRouter.html gzip | 610 B | 609 B | -1 B |
Overall change | 1.85 kB | 1.85 kB | -3 B |
Diffs
Diff for 677f882d2ed8..74301f1c8.js
@@ -1549,6 +1549,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.locales = void 0;
this.defaultLocale = void 0;
this.domainLocales = void 0;
+ this.isReady = void 0;
this.onPopState = function(e) {
var state = e.state;
@@ -1647,9 +1648,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.query = _query; // if auto prerendered and dynamic route wait to update asPath
// until after mount to prevent hydration mismatch
- this.asPath = // @ts-ignore this is temporarily global (attached to window)
+ this.asPath =
(0, _isDynamic.isDynamicRoute)(_pathname) &&
- __NEXT_DATA__.autoExport
+ self.__NEXT_DATA__.autoExport
? _pathname
: _as;
this.basePath = basePath;
@@ -1660,6 +1661,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.isSsr = true;
this.isFallback = isFallback;
+ this.isReady = !!(
+ self.__NEXT_DATA__.gssp ||
+ self.__NEXT_DATA__.gip ||
+ !self.location.search
+ );
if (false) {
}
@@ -1817,9 +1823,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _context.abrupt("return", false);
case 3:
- // Default to scroll reset behavior unless explicitly specified to be
+ // for static pages with query params in the URL we delay
+ // marking the router ready until after the query is updated
+ if (options._h) {
+ this.isReady = true;
+ } // Default to scroll reset behavior unless explicitly specified to be
// `false`! This makes the behavior between using `Router#push` and a
// `<Link />` consistent.
+
options.scroll = !!((_options$scroll =
options.scroll) != null
? _options$scroll
@@ -1827,7 +1838,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
localeChange = options.locale !== this.locale;
if (true) {
- _context.next = 17;
+ _context.next = 18;
break;
}
@@ -1880,7 +1891,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
if (!didNavigate) {
- _context.next = 17;
+ _context.next = 18;
break;
}
@@ -1889,7 +1900,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
new Promise(function() {})
);
- case 17:
+ case 18:
if (!options._h) {
this.isSsr = false;
} // marking route changes as a navigation start entry
@@ -1934,7 +1945,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (
!(!options._h && this.onlyAHashChange(cleanedAs))
) {
- _context.next = 33;
+ _context.next = 34;
break;
}
@@ -1955,7 +1966,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 33:
+ case 34:
parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
url
);
@@ -1965,30 +1976,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// get their query parameters to allow ensuring they can be parsed properly
// when rewritten to
- _context.prev = 35;
- _context.next = 38;
+ _context.prev = 36;
+ _context.next = 39;
return this.pageLoader.getPageList();
- case 38:
+ case 39:
pages = _context.sent;
- _context.next = 41;
+ _context.next = 42;
return (0, _routeLoader.getClientBuildManifest)();
- case 41:
+ case 42:
_yield = _context.sent;
rewrites = _yield.__rewrites;
- _context.next = 49;
+ _context.next = 50;
break;
- case 45:
- _context.prev = 45;
- _context.t0 = _context["catch"](35);
+ case 46:
+ _context.prev = 46;
+ _context.t0 = _context["catch"](36);
// If we fail to resolve the page list or client-build manifest, we must
// do a server-side transition:
window.location.href = as;
return _context.abrupt("return", false);
- case 49:
+ case 50:
parsed = this._resolveHref(parsed, pages);
if (parsed.pathname !== pathname) {
@@ -2030,7 +2041,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
if (!(0, _isDynamic.isDynamicRoute)(route)) {
- _context.next = 72;
+ _context.next = 73;
break;
}
@@ -2053,7 +2064,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(shouldInterpolate && !interpolatedAs.result)
)
) {
- _context.next = 71;
+ _context.next = 72;
break;
}
@@ -2064,7 +2075,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
});
if (!(missingParams.length > 0)) {
- _context.next = 69;
+ _context.next = 70;
break;
}
@@ -2095,11 +2106,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
)
);
- case 69:
- _context.next = 72;
+ case 70:
+ _context.next = 73;
break;
- case 71:
+ case 72:
if (shouldInterpolate) {
as = (0, _utils.formatWithValidation)(
Object.assign({}, _parsedAs, {
@@ -2115,14 +2126,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Object.assign(query, routeMatch);
}
- case 72:
+ case 73:
Router.events.emit(
"routeChangeStart",
as,
routeProps
);
- _context.prev = 73;
- _context.next = 76;
+ _context.prev = 74;
+ _context.next = 77;
return this.getRouteInfo(
route,
pathname,
@@ -2131,7 +2142,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
routeProps
);
- case 76:
+ case 77:
routeInfo = _context.sent;
(_routeInfo = routeInfo),
(error = _routeInfo.error),
@@ -2140,14 +2151,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(__N_SSP = _routeInfo.__N_SSP); // handle redirect on client-transition
if (!((__N_SSG || __N_SSP) && props)) {
- _context.next = 102;
+ _context.next = 103;
break;
}
if (
!(props.pageProps && props.pageProps.__N_REDIRECT)
) {
- _context.next = 89;
+ _context.next = 90;
break;
}
@@ -2156,7 +2167,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// it's not
if (!destination.startsWith("/")) {
- _context.next = 87;
+ _context.next = 88;
break;
}
@@ -2166,7 +2177,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this._resolveHref(parsedHref, pages, false);
if (!pages.includes(parsedHref.pathname)) {
- _context.next = 87;
+ _context.next = 88;
break;
}
@@ -2182,35 +2193,35 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.change(method, newUrl, newAs, options)
);
- case 87:
+ case 88:
window.location.href = destination;
return _context.abrupt(
"return",
new Promise(function() {})
);
- case 89:
+ case 90:
if (!(props.notFound === SSG_DATA_NOT_FOUND)) {
- _context.next = 102;
+ _context.next = 103;
break;
}
- _context.prev = 90;
- _context.next = 93;
+ _context.prev = 91;
+ _context.next = 94;
return this.fetchComponent("/404");
- case 93:
+ case 94:
notFoundRoute = "/404";
- _context.next = 99;
+ _context.next = 100;
break;
- case 96:
- _context.prev = 96;
- _context.t1 = _context["catch"](90);
+ case 97:
+ _context.prev = 97;
+ _context.t1 = _context["catch"](91);
notFoundRoute = "/_error";
- case 99:
- _context.next = 101;
+ case 100:
+ _context.next = 102;
return this.getRouteInfo(
notFoundRoute,
notFoundRoute,
@@ -2221,10 +2232,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
);
- case 101:
+ case 102:
routeInfo = _context.sent;
- case 102:
+ case 103:
Router.events.emit(
"beforeHistoryChange",
as,
@@ -2235,7 +2246,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (false) {
}
- _context.next = 107;
+ _context.next = 108;
return this.set(
route,
pathname,
@@ -2248,9 +2259,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
else throw e;
});
- case 107:
+ case 108:
if (!error) {
- _context.next = 110;
+ _context.next = 111;
break;
}
@@ -2262,7 +2273,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 110:
+ case 111:
if (false) {
}
@@ -2276,21 +2287,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 116:
- _context.prev = 116;
- _context.t2 = _context["catch"](73);
+ case 117:
+ _context.prev = 117;
+ _context.t2 = _context["catch"](74);
if (!_context.t2.cancelled) {
- _context.next = 120;
+ _context.next = 121;
break;
}
return _context.abrupt("return", false);
- case 120:
+ case 121:
throw _context.t2;
- case 121:
+ case 122:
case "end":
return _context.stop();
}
@@ -2299,9 +2310,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_callee,
this,
[
- [35, 45],
- [73, 116],
- [90, 96]
+ [36, 46],
+ [74, 117],
+ [91, 97]
]
);
})
@@ -4326,7 +4337,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
"basePath",
"locale",
"locales",
- "defaultLocale"
+ "defaultLocale",
+ "isReady"
];
var routerEvents = [
"routeChangeStart",
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.91164d0d6b2fcebbf615.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.91164d0d6b2fcebbf615.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.91164d0d6b2fcebbf615.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.91164d0d6b2fcebbf615.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.91164d0d6b2fcebbf615.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.91164d0d6b2fcebbf615.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
buildDuration | 10.7s | 10.5s | -179ms |
nodeModulesSize | 83 MB | 83 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
677f882d2ed8..6cec.js gzip | 12.8 kB | N/A | N/A |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-b45d971..6435.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-7193..1446.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..a44e.js gzip | N/A | 12.8 kB | N/A |
Overall change | 59.1 kB | 59.2 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
polyfills-67..b7d1.js gzip | 31.2 kB | 31.2 kB | ✓ |
Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_app-6220e08..9a40.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-4b0b5..2c91.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-5f309a..7282.js gzip | 887 B | 887 B | ✓ |
index-57f580..c562.js gzip | 227 B | 227 B | ✓ |
link-1a1f628..eeb5.js gzip | 1.61 kB | 1.61 kB | ✓ |
routerDirect..bd82.js gzip | 303 B | 303 B | ✓ |
withRouter-2..e384.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.05 kB | 8.05 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_buildManifest.js gzip | 322 B | 322 B | ✓ |
Overall change | 322 B | 322 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | |
link.js | 1.06 MB | 1.06 MB | |
routerDirect.js | 1.05 MB | 1.05 MB | |
withRouter.js | 1.05 MB | 1.05 MB | |
Overall change | 5.17 MB | 5.17 MB |
# Conflicts: # packages/next/next-server/server/render.tsx
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
# Conflicts: # test/integration/build-output/test/index.test.js
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
buildDuration | 8.8s | 8.8s | |
nodeModulesSize | 83 MB | 83 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.732 | 1.774 | |
/ avg req/sec | 1443.39 | 1409.48 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.095 | 1.06 | -0.03 |
/error-in-render avg req/sec | 2283.24 | 2358.29 | +75.05 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
677f882d2ed8..381c.js gzip | 12.9 kB | 12.9 kB | |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-212f85f..f23b.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-7193..1446.js gzip | 751 B | 751 B | ✓ |
Overall change | 59.2 kB | 59.2 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
polyfills-67..b7d1.js gzip | 31.2 kB | 31.2 kB | ✓ |
Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_app-6220e08..9a40.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-4b0b5..2c91.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-5f309a..7282.js gzip | 887 B | 887 B | ✓ |
index-57f580..c562.js gzip | 227 B | 227 B | ✓ |
link-b862cd7..dba8.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bd82.js gzip | 303 B | 303 B | ✓ |
withRouter-2..e384.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.08 kB | 8.08 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
index.html gzip | 616 B | 617 B | |
link.html gzip | 622 B | 622 B | ✓ |
withRouter.html gzip | 609 B | 610 B | |
Overall change | 1.85 kB | 1.85 kB |
Diffs
Diff for 677f882d2ed8..f7195fca6.js
@@ -1558,6 +1558,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.locales = void 0;
this.defaultLocale = void 0;
this.domainLocales = void 0;
+ this.isReady = void 0;
this._idx = 0;
this.onPopState = function(e) {
@@ -1666,9 +1667,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.query = _query; // if auto prerendered and dynamic route wait to update asPath
// until after mount to prevent hydration mismatch
- this.asPath = // @ts-ignore this is temporarily global (attached to window)
+ this.asPath =
(0, _isDynamic.isDynamicRoute)(_pathname) &&
- __NEXT_DATA__.autoExport
+ self.__NEXT_DATA__.autoExport
? _pathname
: _as;
this.basePath = basePath;
@@ -1679,6 +1680,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.isSsr = true;
this.isFallback = isFallback;
+ this.isReady = !!(
+ self.__NEXT_DATA__.gssp ||
+ self.__NEXT_DATA__.gip ||
+ !self.location.search
+ );
if (false) {
}
@@ -1840,9 +1846,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _context.abrupt("return", false);
case 3:
- // Default to scroll reset behavior unless explicitly specified to be
+ // for static pages with query params in the URL we delay
+ // marking the router ready until after the query is updated
+ if (options._h) {
+ this.isReady = true;
+ } // Default to scroll reset behavior unless explicitly specified to be
// `false`! This makes the behavior between using `Router#push` and a
// `<Link />` consistent.
+
options.scroll = !!((_options$scroll =
options.scroll) != null
? _options$scroll
@@ -1850,7 +1861,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
localeChange = options.locale !== this.locale;
if (true) {
- _context.next = 17;
+ _context.next = 18;
break;
}
@@ -1903,7 +1914,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
if (!didNavigate) {
- _context.next = 17;
+ _context.next = 18;
break;
}
@@ -1912,7 +1923,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
new Promise(function() {})
);
- case 17:
+ case 18:
if (!options._h) {
this.isSsr = false;
} // marking route changes as a navigation start entry
@@ -1957,7 +1968,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (
!(!options._h && this.onlyAHashChange(cleanedAs))
) {
- _context.next = 33;
+ _context.next = 34;
break;
}
@@ -1978,7 +1989,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 33:
+ case 34:
parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
url
);
@@ -1988,30 +1999,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// get their query parameters to allow ensuring they can be parsed properly
// when rewritten to
- _context.prev = 35;
- _context.next = 38;
+ _context.prev = 36;
+ _context.next = 39;
return this.pageLoader.getPageList();
- case 38:
+ case 39:
pages = _context.sent;
- _context.next = 41;
+ _context.next = 42;
return (0, _routeLoader.getClientBuildManifest)();
- case 41:
+ case 42:
_yield = _context.sent;
rewrites = _yield.__rewrites;
- _context.next = 49;
+ _context.next = 50;
break;
- case 45:
- _context.prev = 45;
- _context.t0 = _context["catch"](35);
+ case 46:
+ _context.prev = 46;
+ _context.t0 = _context["catch"](36);
// If we fail to resolve the page list or client-build manifest, we must
// do a server-side transition:
window.location.href = as;
return _context.abrupt("return", false);
- case 49:
+ case 50:
parsed = this._resolveHref(parsed, pages);
if (parsed.pathname !== pathname) {
@@ -2053,7 +2064,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
if (!(0, _isDynamic.isDynamicRoute)(route)) {
- _context.next = 72;
+ _context.next = 73;
break;
}
@@ -2076,7 +2087,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(shouldInterpolate && !interpolatedAs.result)
)
) {
- _context.next = 71;
+ _context.next = 72;
break;
}
@@ -2087,7 +2098,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
});
if (!(missingParams.length > 0)) {
- _context.next = 69;
+ _context.next = 70;
break;
}
@@ -2118,11 +2129,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
)
);
- case 69:
- _context.next = 72;
+ case 70:
+ _context.next = 73;
break;
- case 71:
+ case 72:
if (shouldInterpolate) {
as = (0, _utils.formatWithValidation)(
Object.assign({}, _parsedAs, {
@@ -2138,14 +2149,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Object.assign(query, routeMatch);
}
- case 72:
+ case 73:
Router.events.emit(
"routeChangeStart",
as,
routeProps
);
- _context.prev = 73;
- _context.next = 76;
+ _context.prev = 74;
+ _context.next = 77;
return this.getRouteInfo(
route,
pathname,
@@ -2154,7 +2165,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
routeProps
);
- case 76:
+ case 77:
routeInfo = _context.sent;
(_routeInfo = routeInfo),
(error = _routeInfo.error),
@@ -2163,14 +2174,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(__N_SSP = _routeInfo.__N_SSP); // handle redirect on client-transition
if (!((__N_SSG || __N_SSP) && props)) {
- _context.next = 102;
+ _context.next = 103;
break;
}
if (
!(props.pageProps && props.pageProps.__N_REDIRECT)
) {
- _context.next = 89;
+ _context.next = 90;
break;
}
@@ -2179,7 +2190,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// it's not
if (!destination.startsWith("/")) {
- _context.next = 87;
+ _context.next = 88;
break;
}
@@ -2189,7 +2200,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this._resolveHref(parsedHref, pages, false);
if (!pages.includes(parsedHref.pathname)) {
- _context.next = 87;
+ _context.next = 88;
break;
}
@@ -2205,35 +2216,35 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.change(method, newUrl, newAs, options)
);
- case 87:
+ case 88:
window.location.href = destination;
return _context.abrupt(
"return",
new Promise(function() {})
);
- case 89:
+ case 90:
if (!(props.notFound === SSG_DATA_NOT_FOUND)) {
- _context.next = 102;
+ _context.next = 103;
break;
}
- _context.prev = 90;
- _context.next = 93;
+ _context.prev = 91;
+ _context.next = 94;
return this.fetchComponent("/404");
- case 93:
+ case 94:
notFoundRoute = "/404";
- _context.next = 99;
+ _context.next = 100;
break;
- case 96:
- _context.prev = 96;
- _context.t1 = _context["catch"](90);
+ case 97:
+ _context.prev = 97;
+ _context.t1 = _context["catch"](91);
notFoundRoute = "/_error";
- case 99:
- _context.next = 101;
+ case 100:
+ _context.next = 102;
return this.getRouteInfo(
notFoundRoute,
notFoundRoute,
@@ -2244,10 +2255,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
);
- case 101:
+ case 102:
routeInfo = _context.sent;
- case 102:
+ case 103:
Router.events.emit(
"beforeHistoryChange",
as,
@@ -2258,7 +2269,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (false) {
}
- _context.next = 107;
+ _context.next = 108;
return this.set(
route,
pathname,
@@ -2277,9 +2288,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
else throw e;
});
- case 107:
+ case 108:
if (!error) {
- _context.next = 110;
+ _context.next = 111;
break;
}
@@ -2291,7 +2302,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 110:
+ case 111:
if (false) {
}
@@ -2302,21 +2313,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 115:
- _context.prev = 115;
- _context.t2 = _context["catch"](73);
+ case 116:
+ _context.prev = 116;
+ _context.t2 = _context["catch"](74);
if (!_context.t2.cancelled) {
- _context.next = 119;
+ _context.next = 120;
break;
}
return _context.abrupt("return", false);
- case 119:
+ case 120:
throw _context.t2;
- case 120:
+ case 121:
case "end":
return _context.stop();
}
@@ -2325,9 +2336,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_callee,
this,
[
- [35, 45],
- [73, 115],
- [90, 96]
+ [36, 46],
+ [74, 116],
+ [91, 97]
]
);
})
@@ -4354,7 +4365,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
"basePath",
"locale",
"locales",
- "defaultLocale"
+ "defaultLocale",
+ "isReady"
];
var routerEvents = [
"routeChangeStart",
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
buildDuration | 10.4s | 10.4s | -26ms |
nodeModulesSize | 83 MB | 83 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
677f882d2ed8..381c.js gzip | 12.9 kB | N/A | N/A |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-212f85f..f23b.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-7193..1446.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..2428.js gzip | N/A | 12.9 kB | N/A |
Overall change | 59.2 kB | 59.2 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
polyfills-67..b7d1.js gzip | 31.2 kB | 31.2 kB | ✓ |
Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_app-6220e08..9a40.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-4b0b5..2c91.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-5f309a..7282.js gzip | 887 B | 887 B | ✓ |
index-57f580..c562.js gzip | 227 B | 227 B | ✓ |
link-b862cd7..dba8.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bd82.js gzip | 303 B | 303 B | ✓ |
withRouter-2..e384.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.08 kB | 8.08 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | |
link.js | 1.06 MB | 1.06 MB | |
routerDirect.js | 1.05 MB | 1.05 MB | |
withRouter.js | 1.05 MB | 1.05 MB | |
Overall change | 5.17 MB | 5.17 MB |
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
buildDuration | 10.2s | 10.1s | -94ms |
nodeModulesSize | 83 MB | 83 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.98 | 2.033 | |
/ avg req/sec | 1262.61 | 1229.84 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.243 | 1.216 | -0.03 |
/error-in-render avg req/sec | 2011.97 | 2055.76 | +43.79 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
677f882d2ed8..381c.js gzip | 12.9 kB | 12.9 kB | |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-212f85f..f23b.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-7193..1446.js gzip | 751 B | 751 B | ✓ |
Overall change | 59.2 kB | 59.2 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
polyfills-67..b7d1.js gzip | 31.2 kB | 31.2 kB | ✓ |
Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_app-6220e08..9a40.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-4b0b5..2c91.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-5f309a..7282.js gzip | 887 B | 887 B | ✓ |
index-57f580..c562.js gzip | 227 B | 227 B | ✓ |
link-b862cd7..dba8.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bd82.js gzip | 303 B | 303 B | ✓ |
withRouter-2..e384.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.08 kB | 8.08 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
index.html gzip | 616 B | 617 B | |
link.html gzip | 622 B | 622 B | ✓ |
withRouter.html gzip | 609 B | 610 B | |
Overall change | 1.85 kB | 1.85 kB |
Diffs
Diff for 677f882d2ed8..f7195fca6.js
@@ -1558,6 +1558,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.locales = void 0;
this.defaultLocale = void 0;
this.domainLocales = void 0;
+ this.isReady = void 0;
this._idx = 0;
this.onPopState = function(e) {
@@ -1666,9 +1667,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.query = _query; // if auto prerendered and dynamic route wait to update asPath
// until after mount to prevent hydration mismatch
- this.asPath = // @ts-ignore this is temporarily global (attached to window)
+ this.asPath =
(0, _isDynamic.isDynamicRoute)(_pathname) &&
- __NEXT_DATA__.autoExport
+ self.__NEXT_DATA__.autoExport
? _pathname
: _as;
this.basePath = basePath;
@@ -1679,6 +1680,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.isSsr = true;
this.isFallback = isFallback;
+ this.isReady = !!(
+ self.__NEXT_DATA__.gssp ||
+ self.__NEXT_DATA__.gip ||
+ !self.location.search
+ );
if (false) {
}
@@ -1840,9 +1846,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _context.abrupt("return", false);
case 3:
- // Default to scroll reset behavior unless explicitly specified to be
+ // for static pages with query params in the URL we delay
+ // marking the router ready until after the query is updated
+ if (options._h) {
+ this.isReady = true;
+ } // Default to scroll reset behavior unless explicitly specified to be
// `false`! This makes the behavior between using `Router#push` and a
// `<Link />` consistent.
+
options.scroll = !!((_options$scroll =
options.scroll) != null
? _options$scroll
@@ -1850,7 +1861,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
localeChange = options.locale !== this.locale;
if (true) {
- _context.next = 17;
+ _context.next = 18;
break;
}
@@ -1903,7 +1914,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
if (!didNavigate) {
- _context.next = 17;
+ _context.next = 18;
break;
}
@@ -1912,7 +1923,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
new Promise(function() {})
);
- case 17:
+ case 18:
if (!options._h) {
this.isSsr = false;
} // marking route changes as a navigation start entry
@@ -1957,7 +1968,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (
!(!options._h && this.onlyAHashChange(cleanedAs))
) {
- _context.next = 33;
+ _context.next = 34;
break;
}
@@ -1978,7 +1989,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 33:
+ case 34:
parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
url
);
@@ -1988,30 +1999,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// get their query parameters to allow ensuring they can be parsed properly
// when rewritten to
- _context.prev = 35;
- _context.next = 38;
+ _context.prev = 36;
+ _context.next = 39;
return this.pageLoader.getPageList();
- case 38:
+ case 39:
pages = _context.sent;
- _context.next = 41;
+ _context.next = 42;
return (0, _routeLoader.getClientBuildManifest)();
- case 41:
+ case 42:
_yield = _context.sent;
rewrites = _yield.__rewrites;
- _context.next = 49;
+ _context.next = 50;
break;
- case 45:
- _context.prev = 45;
- _context.t0 = _context["catch"](35);
+ case 46:
+ _context.prev = 46;
+ _context.t0 = _context["catch"](36);
// If we fail to resolve the page list or client-build manifest, we must
// do a server-side transition:
window.location.href = as;
return _context.abrupt("return", false);
- case 49:
+ case 50:
parsed = this._resolveHref(parsed, pages);
if (parsed.pathname !== pathname) {
@@ -2053,7 +2064,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
if (!(0, _isDynamic.isDynamicRoute)(route)) {
- _context.next = 72;
+ _context.next = 73;
break;
}
@@ -2076,7 +2087,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(shouldInterpolate && !interpolatedAs.result)
)
) {
- _context.next = 71;
+ _context.next = 72;
break;
}
@@ -2087,7 +2098,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
});
if (!(missingParams.length > 0)) {
- _context.next = 69;
+ _context.next = 70;
break;
}
@@ -2118,11 +2129,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
)
);
- case 69:
- _context.next = 72;
+ case 70:
+ _context.next = 73;
break;
- case 71:
+ case 72:
if (shouldInterpolate) {
as = (0, _utils.formatWithValidation)(
Object.assign({}, _parsedAs, {
@@ -2138,14 +2149,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Object.assign(query, routeMatch);
}
- case 72:
+ case 73:
Router.events.emit(
"routeChangeStart",
as,
routeProps
);
- _context.prev = 73;
- _context.next = 76;
+ _context.prev = 74;
+ _context.next = 77;
return this.getRouteInfo(
route,
pathname,
@@ -2154,7 +2165,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
routeProps
);
- case 76:
+ case 77:
routeInfo = _context.sent;
(_routeInfo = routeInfo),
(error = _routeInfo.error),
@@ -2163,14 +2174,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(__N_SSP = _routeInfo.__N_SSP); // handle redirect on client-transition
if (!((__N_SSG || __N_SSP) && props)) {
- _context.next = 102;
+ _context.next = 103;
break;
}
if (
!(props.pageProps && props.pageProps.__N_REDIRECT)
) {
- _context.next = 89;
+ _context.next = 90;
break;
}
@@ -2179,7 +2190,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// it's not
if (!destination.startsWith("/")) {
- _context.next = 87;
+ _context.next = 88;
break;
}
@@ -2189,7 +2200,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this._resolveHref(parsedHref, pages, false);
if (!pages.includes(parsedHref.pathname)) {
- _context.next = 87;
+ _context.next = 88;
break;
}
@@ -2205,35 +2216,35 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.change(method, newUrl, newAs, options)
);
- case 87:
+ case 88:
window.location.href = destination;
return _context.abrupt(
"return",
new Promise(function() {})
);
- case 89:
+ case 90:
if (!(props.notFound === SSG_DATA_NOT_FOUND)) {
- _context.next = 102;
+ _context.next = 103;
break;
}
- _context.prev = 90;
- _context.next = 93;
+ _context.prev = 91;
+ _context.next = 94;
return this.fetchComponent("/404");
- case 93:
+ case 94:
notFoundRoute = "/404";
- _context.next = 99;
+ _context.next = 100;
break;
- case 96:
- _context.prev = 96;
- _context.t1 = _context["catch"](90);
+ case 97:
+ _context.prev = 97;
+ _context.t1 = _context["catch"](91);
notFoundRoute = "/_error";
- case 99:
- _context.next = 101;
+ case 100:
+ _context.next = 102;
return this.getRouteInfo(
notFoundRoute,
notFoundRoute,
@@ -2244,10 +2255,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
);
- case 101:
+ case 102:
routeInfo = _context.sent;
- case 102:
+ case 103:
Router.events.emit(
"beforeHistoryChange",
as,
@@ -2258,7 +2269,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
if (false) {
}
- _context.next = 107;
+ _context.next = 108;
return this.set(
route,
pathname,
@@ -2277,9 +2288,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
else throw e;
});
- case 107:
+ case 108:
if (!error) {
- _context.next = 110;
+ _context.next = 111;
break;
}
@@ -2291,7 +2302,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 110:
+ case 111:
if (false) {
}
@@ -2302,21 +2313,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 115:
- _context.prev = 115;
- _context.t2 = _context["catch"](73);
+ case 116:
+ _context.prev = 116;
+ _context.t2 = _context["catch"](74);
if (!_context.t2.cancelled) {
- _context.next = 119;
+ _context.next = 120;
break;
}
return _context.abrupt("return", false);
- case 119:
+ case 120:
throw _context.t2;
- case 120:
+ case 121:
case "end":
return _context.stop();
}
@@ -2325,9 +2336,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_callee,
this,
[
- [35, 45],
- [73, 115],
- [90, 96]
+ [36, 46],
+ [74, 116],
+ [91, 97]
]
);
})
@@ -4354,7 +4365,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
"basePath",
"locale",
"locales",
- "defaultLocale"
+ "defaultLocale",
+ "isReady"
];
var routerEvents = [
"routeChangeStart",
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8fc8494a87d09954e463.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
buildDuration | 11.8s | 11.6s | -260ms |
nodeModulesSize | 83 MB | 83 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
677f882d2ed8..381c.js gzip | 12.9 kB | N/A | N/A |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-212f85f..f23b.js gzip | 6.59 kB | 6.59 kB | ✓ |
webpack-7193..1446.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..2428.js gzip | N/A | 12.9 kB | N/A |
Overall change | 59.2 kB | 59.2 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
polyfills-67..b7d1.js gzip | 31.2 kB | 31.2 kB | ✓ |
Overall change | 31.2 kB | 31.2 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_app-6220e08..9a40.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-4b0b5..2c91.js gzip | 3.44 kB | 3.44 kB | ✓ |
hooks-5f309a..7282.js gzip | 887 B | 887 B | ✓ |
index-57f580..c562.js gzip | 227 B | 227 B | ✓ |
link-b862cd7..dba8.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bd82.js gzip | 303 B | 303 B | ✓ |
withRouter-2..e384.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.08 kB | 8.08 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/router-ready | Change | |
---|---|---|---|
_error.js | 1 MB | 1 MB | |
404.html | 2.67 kB | 2.67 kB | ✓ |
hooks.html | 1.92 kB | 1.92 kB | ✓ |
index.js | 1 MB | 1 MB | |
link.js | 1.06 MB | 1.06 MB | |
routerDirect.js | 1.05 MB | 1.05 MB | |
withRouter.js | 1.05 MB | 1.05 MB | |
Overall change | 5.17 MB | 5.17 MB |
@Timer @ijjk hi there, I have been testing the isReady boolean behavior in latest canary release |
Hi @shufflemattdev thanks for testing this out, this does sound to be correct and |
Follow-up to #20628 this ensures `isReady` is not initially true when the query isn't present but the page is an automatically statically optimized dynamic route
@ijjk no problem, just wanted to make sure you caught it before the next stable release. Just tried on |
@ijjk we have a system that runs tests on a page with a router that we inject manually, using the next.js import { createRouter } from 'next/router';
const createMockedRouter = (path, query, as) => {
const nextRouter = createRouter(path, query, as, {});
return nextRouter;
};
export default createMockedRouter; This function started failing when running it server-side (since 10.0.5). This PR makes import { createRouter } from 'next/router';
const createMockedRouter = (path, query, as) => {
global.self = {
__NEXT_DATA__: {},
location: { search: {} },
};
const nextRouter = createRouter(path, query, as, {});
return nextRouter;
};
export default createMockedRouter; Luckily this is only a test script, so nothing that would fail under production, but maybe we can add the |
@PepijnSenders the router from Note: |
From #20628, when the page is rendered server-side, `Router`'s `isReady` field needs to be initially set to `true`. However, when `_app` has custom `getInitialProps`, it seems that it is not the case, even though the page is rendered on the server. This leads to a bug that `Router.isReady` is never set to `true`. This pull request fixes the problem by fixing the initial calculation logic of `isReady` of `Router`. ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes
…#27473) From vercel#20628, when the page is rendered server-side, `Router`'s `isReady` field needs to be initially set to `true`. However, when `_app` has custom `getInitialProps`, it seems that it is not the case, even though the page is rendered on the server. This leads to a bug that `Router.isReady` is never set to `true`. This pull request fixes the problem by fixing the initial calculation logic of `isReady` of `Router`. ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes
Adds an
isReady
field onnext/router
specifying whether the router fields are updated client-side and ready for use. Should only be used inside ofuseEffect
methods and not for conditionally rendering on the server.Closes: #8259
Closes: #9370