-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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 handling fo beforeFiles, afterFiles, and fallback rewrites #23407
Merged
Conversation
This file contains 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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ijjk
requested review from
divmain,
leerob,
lfades,
shuding and
timneutkens
as code owners
March 25, 2021 21:23
This comment has been minimized.
This comment has been minimized.
I think this would fix #23244. |
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.
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.
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/rewrites-override | Change | |
---|---|---|---|
buildDuration | 15.6s | 15.7s | |
nodeModulesSize | 61.7 MB | 61.8 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.117 | 2.07 | -0.05 |
/ avg req/sec | 1180.99 | 1207.81 | +26.82 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.277 | 1.324 | |
/error-in-render avg req/sec | 1958.37 | 1887.91 |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
597-ec2335c0..e105.js gzip | 13.3 kB | 13.3 kB | -39 B |
778-b85ea97d..1a55.js gzip | 7.06 kB | 7.05 kB | -16 B |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 151 B | 151 B | ✓ |
webpack-HASH.js gzip | 993 B | 993 B | ✓ |
Overall change | 60.8 kB | 60.8 kB | -55 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_app-bdbd9e6..6cfe.js gzip | 1.3 kB | 1.3 kB | ✓ |
_error-b58c1..9b8e.js gzip | 3.4 kB | 3.4 kB | ✓ |
amp-89a5460c..567f.js gzip | 558 B | 558 B | ✓ |
hooks-8c2e74..be37.js gzip | 924 B | 924 B | ✓ |
index-fec729..83b2.js gzip | 243 B | 243 B | ✓ |
link-d124373..c521.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..5759.js gzip | 336 B | 336 B | ✓ |
withRouter-1..98bf.js gzip | 334 B | 334 B | ✓ |
Overall change | 8.76 kB | 8.76 kB | ✓ |
Client Build Manifests Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_buildManifest.js gzip | 323 B | 349 B | |
Overall change | 323 B | 349 B |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
index.html gzip | 608 B | 609 B | |
link.html gzip | 615 B | 615 B | ✓ |
withRouter.html gzip | 603 B | 603 B | ✓ |
Overall change | 1.83 kB | 1.83 kB |
Diffs
Diff for _buildManifest.js
@@ -1,5 +1,5 @@
self.__BUILD_MANIFEST = {
- __rewrites: [],
+ __rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },
"/": ["static\u002Fchunks\u002Fpages\u002Findex-b1738b6c9dd4aa373c84.js"],
"/_error": [
"static\u002Fchunks\u002Fpages\u002F_error-6fc12bd74dc2417101e6.js"
Diff for 677f882d2ed8..29e58243f.js
@@ -1496,21 +1496,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
};
}
- function resolveDynamicRoute(parsedHref, pages) {
- var applyBasePath =
- arguments.length > 2 && arguments[2] !== undefined
- ? arguments[2]
- : true;
- var pathname = parsedHref.pathname;
+ function resolveDynamicRoute(pathname, pages) {
var cleanPathname = (0,
_normalizeTrailingSlash.removePathTrailingSlash)(
- (0, _denormalizePagePath.denormalizePagePath)(
- applyBasePath ? delBasePath(pathname) : pathname
- )
+ (0, _denormalizePagePath.denormalizePagePath)(pathname)
);
if (cleanPathname === "/404" || cleanPathname === "/_error") {
- return parsedHref;
+ return pathname;
} // handle resolving href for dynamic routes
if (!pages.includes(cleanPathname)) {
@@ -1520,15 +1513,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(0, _isDynamic.isDynamicRoute)(page) &&
(0, _routeRegex.getRouteRegex)(page).re.test(cleanPathname)
) {
- parsedHref.pathname = applyBasePath ? addBasePath(page) : page;
+ pathname = page;
return true;
}
});
}
- parsedHref.pathname = (0,
- _normalizeTrailingSlash.removePathTrailingSlash)(parsedHref.pathname);
- return parsedHref;
+ return (0, _normalizeTrailingSlash.removePathTrailingSlash)(pathname);
}
var manualScrollRestoration = false && false;
@@ -1881,15 +1872,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
routeProps,
cleanedAs,
parsed,
- _parsed,
pathname,
query,
pages,
rewrites,
_yield,
- route,
resolvedAs,
rewritesResult,
+ route,
_parsedAs,
asPathname,
routeRegex,
@@ -2075,9 +2065,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
url
);
- (_parsed = parsed),
- (pathname = _parsed.pathname),
- (query = _parsed.query); // The build manifest needs to be loaded before auto-static dynamic pages
+ (pathname = parsed.pathname),
+ (query = parsed.query); // The build manifest needs to be loaded before auto-static dynamic pages
// get their query parameters to allow ensuring they can be parsed properly
// when rewritten to
@@ -2105,12 +2094,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _context.abrupt("return", false);
case 50:
- parsed = resolveDynamicRoute(parsed, pages);
+ // If asked to change the current URL we should reload the current page
+ // (not location.reload() but reload getInitialProps and other Next.js stuffs)
+ // We also need to set the method = replaceState always
+ // as this should not go into the history (That's how browsers work)
+ // We should compare the new asPath to the current asPath, not the url
+ if (!this.urlIsNew(cleanedAs) && !localeChange) {
+ method = "replaceState";
+ } // we need to resolve the as value using rewrites for dynamic SSG
+ // pages to allow building the data URL correctly
- if (parsed.pathname !== pathname) {
- pathname = parsed.pathname;
- url = (0, _utils.formatWithValidation)(parsed);
- } // url and as should always be prefixed with basePath by this
+ resolvedAs = as; // url and as should always be prefixed with basePath by this
// point by either next/link or router.push/replace so strip the
// basePath from the pathname to match the pages dir 1-to-1
@@ -2119,34 +2113,37 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_normalizeTrailingSlash.removePathTrailingSlash)(
delBasePath(pathname)
)
- : pathname; // If asked to change the current URL we should reload the current page
- // (not location.reload() but reload getInitialProps and other Next.js stuffs)
- // We also need to set the method = replaceState always
- // as this should not go into the history (That's how browsers work)
- // We should compare the new asPath to the current asPath, not the url
+ : pathname;
- if (!this.urlIsNew(cleanedAs) && !localeChange) {
- method = "replaceState";
+ if (pathname !== "/_error") {
+ if (false) {
+ } else {
+ parsed.pathname = resolveDynamicRoute(
+ pathname,
+ pages
+ );
+
+ if (parsed.pathname !== pathname) {
+ pathname = parsed.pathname;
+ url = (0, _utils.formatWithValidation)(
+ parsed
+ );
+ }
+ }
}
route = (0,
_normalizeTrailingSlash.removePathTrailingSlash)(
pathname
- ); // we need to resolve the as value using rewrites for dynamic SSG
- // pages to allow building the data URL correctly
-
- resolvedAs = as;
-
- if (false) {
- }
+ );
if (isLocalURL(as)) {
- _context.next = 62;
+ _context.next = 60;
break;
}
if (true) {
- _context.next = 60;
+ _context.next = 58;
break;
}
@@ -2160,18 +2157,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
"\nSee more info: https://err.sh/next.js/invalid-relative-url-external-as"
);
- case 60:
+ case 58:
window.location.href = as;
return _context.abrupt("return", false);
- case 62:
+ case 60:
resolvedAs = delLocale(
delBasePath(resolvedAs),
this.locale
);
if (!(0, _isDynamic.isDynamicRoute)(route)) {
- _context.next = 78;
+ _context.next = 76;
break;
}
@@ -2194,7 +2191,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
(shouldInterpolate && !interpolatedAs.result)
)
) {
- _context.next = 77;
+ _context.next = 75;
break;
}
@@ -2205,7 +2202,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
});
if (!(missingParams.length > 0)) {
- _context.next = 75;
+ _context.next = 73;
break;
}
@@ -2236,11 +2233,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
)
);
- case 75:
- _context.next = 78;
+ case 73:
+ _context.next = 76;
break;
- case 77:
+ case 75:
if (shouldInterpolate) {
as = (0, _utils.formatWithValidation)(
Object.assign({}, _parsedAs, {
@@ -2256,14 +2253,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Object.assign(query, routeMatch);
}
- case 78:
+ case 76:
Router.events.emit(
"routeChangeStart",
as,
routeProps
);
- _context.prev = 79;
- _context.next = 82;
+ _context.prev = 77;
+ _context.next = 80;
return this.getRouteInfo(
route,
pathname,
@@ -2273,7 +2270,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
routeProps
);
- case 82:
+ case 80:
routeInfo = _context.sent;
(_routeInfo = routeInfo),
(error = _routeInfo.error),
@@ -2282,14 +2279,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 = 109;
+ _context.next = 107;
break;
}
if (
!(props.pageProps && props.pageProps.__N_REDIRECT)
) {
- _context.next = 95;
+ _context.next = 93;
break;
}
@@ -2298,16 +2295,19 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
// it's not
if (!destination.startsWith("/")) {
- _context.next = 93;
+ _context.next = 91;
break;
}
parsedHref = (0,
_parseRelativeUrl.parseRelativeUrl)(destination);
- resolveDynamicRoute(parsedHref, pages, false);
+ parsedHref.pathname = resolveDynamicRoute(
+ parsedHref.pathname,
+ pages
+ );
if (!pages.includes(parsedHref.pathname)) {
- _context.next = 93;
+ _context.next = 91;
break;
}
@@ -2323,37 +2323,37 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.change(method, newUrl, newAs, options)
);
- case 93:
+ case 91:
window.location.href = destination;
return _context.abrupt(
"return",
new Promise(function() {})
);
- case 95:
+ case 93:
this.isPreview = !!props.__N_PREVIEW; // handle SSG data 404
if (!(props.notFound === SSG_DATA_NOT_FOUND)) {
- _context.next = 109;
+ _context.next = 107;
break;
}
- _context.prev = 97;
- _context.next = 100;
+ _context.prev = 95;
+ _context.next = 98;
return this.fetchComponent("/404");
- case 100:
+ case 98:
notFoundRoute = "/404";
- _context.next = 106;
+ _context.next = 104;
break;
- case 103:
- _context.prev = 103;
- _context.t1 = _context["catch"](97);
+ case 101:
+ _context.prev = 101;
+ _context.t1 = _context["catch"](95);
notFoundRoute = "/_error";
- case 106:
- _context.next = 108;
+ case 104:
+ _context.next = 106;
return this.getRouteInfo(
notFoundRoute,
notFoundRoute,
@@ -2365,10 +2365,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
);
- case 108:
+ case 106:
routeInfo = _context.sent;
- case 109:
+ case 107:
Router.events.emit(
"beforeHistoryChange",
as,
@@ -2400,7 +2400,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
props.pageProps.statusCode = 500;
}
- _context.next = 116;
+ _context.next = 114;
return this.set(
route,
pathname,
@@ -2419,9 +2419,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
else throw e;
});
- case 116:
+ case 114:
if (!error) {
- _context.next = 119;
+ _context.next = 117;
break;
}
@@ -2433,7 +2433,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 119:
+ case 117:
if (false) {
}
@@ -2444,21 +2444,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 124:
- _context.prev = 124;
- _context.t2 = _context["catch"](79);
+ case 122:
+ _context.prev = 122;
+ _context.t2 = _context["catch"](77);
if (!_context.t2.cancelled) {
- _context.next = 128;
+ _context.next = 126;
break;
}
return _context.abrupt("return", false);
- case 128:
+ case 126:
throw _context.t2;
- case 129:
+ case 127:
case "end":
return _context.stop();
}
@@ -2468,8 +2468,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this,
[
[36, 46],
- [79, 124],
- [97, 103]
+ [77, 122],
+ [95, 101]
]
);
})
@@ -2956,16 +2956,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
var asPath,
options,
parsed,
- _parsed2,
pathname,
parsedAs,
localePathResult,
pages,
- route,
resolvedAs,
rewrites,
_yield2,
rewritesResult,
+ route,
_args4 = arguments;
return _regeneratorRuntime.wrap(
@@ -2984,7 +2983,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
url
);
- (_parsed2 = parsed), (pathname = _parsed2.pathname);
+ pathname = parsed.pathname;
if (false) {
}
@@ -2994,17 +2993,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
case 7:
pages = _context4.sent;
- parsed = resolveDynamicRoute(parsed, pages, false);
-
- if (parsed.pathname !== pathname) {
- pathname = parsed.pathname;
- url = (0, _utils.formatWithValidation)(parsed);
- }
-
- route = (0,
- _normalizeTrailingSlash.removePathTrailingSlash)(
- pathname
- );
resolvedAs = asPath;
if (true) {
@@ -3012,29 +3000,26 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
break;
}
- _context4.next = 15;
+ _context4.next = 12;
return (0, _routeLoader.getClientBuildManifest)();
- case 15:
+ case 12:
_yield2 = _context4.sent;
rewrites = _yield2.__rewrites;
rewritesResult = (0, _resolveRewrites["default"])(
- addBasePath(
- addLocale(delBasePath(asPath), this.locale)
- ),
+ addBasePath(addLocale(asPath, this.locale)),
pages,
rewrites,
parsed.query,
function(p) {
- return resolveDynamicRoute(
- {
- pathname: p
- },
- pages
- ).pathname;
+ return resolveDynamicRoute(p, pages);
},
this.locales
);
+ resolvedAs = delLocale(
+ delBasePath(rewritesResult.asPath),
+ this.locale
+ );
if (
rewritesResult.matchedPage &&
@@ -3042,44 +3027,63 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
) {
// if this directly matches a page we need to update the href to
// allow the correct page chunk to be loaded
- route = rewritesResult.resolvedHref;
pathname = rewritesResult.resolvedHref;
parsed.pathname = pathname;
url = (0, _utils.formatWithValidation)(parsed);
- resolvedAs = rewritesResult.asPath;
}
+ _context4.next = 21;
+ break;
+
case 19:
+ parsed.pathname = resolveDynamicRoute(
+ parsed.pathname,
+ pages
+ );
+
+ if (parsed.pathname !== pathname) {
+ pathname = parsed.pathname;
+ url = (0, _utils.formatWithValidation)(parsed);
+ }
+
+ case 21:
+ route = (0,
+ _normalizeTrailingSlash.removePathTrailingSlash)(
+ pathname
+ ); // Prefetch is not supported in development mode because it would trigger on-demand-entries
+
if (true) {
- _context4.next = 21;
+ _context4.next = 24;
break;
}
return _context4.abrupt("return");
- case 21:
- _context4.next = 23;
+ case 24:
+ _context4.next = 26;
return Promise.all([
- this.pageLoader._isSsg(url).then(function(isSsg) {
- return isSsg
- ? _this3._getStaticData(
- _this3.pageLoader.getDataHref(
- url,
- resolvedAs,
- true,
- typeof options.locale !== "undefined"
- ? options.locale
- : _this3.locale
+ this.pageLoader
+ ._isSsg(route)
+ .then(function(isSsg) {
+ return isSsg
+ ? _this3._getStaticData(
+ _this3.pageLoader.getDataHref(
+ url,
+ resolvedAs,
+ true,
+ typeof options.locale !== "undefined"
+ ? options.locale
+ : _this3.locale
+ )
)
- )
- : false;
- }),
+ : false;
+ }),
this.pageLoader[
options.priority ? "loadPage" : "prefetch"
](route)
]);
- case 23:
+ case 26:
case "end":
return _context4.stop();
}
Diff for main-HASH.js
@@ -1936,16 +1936,12 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
: getHrefForSlug(route);
}
/**
- * @param {string} href the route href (file-system path)
+ * @param {string} route - the route (file-system path)
*/
},
{
key: "_isSsg",
- value: function _isSsg(href) {
- var _ref3 = (0, _parseRelativeUrl.parseRelativeUrl)(href),
- hrefPathname = _ref3.pathname;
-
- var route = normalizeRoute(hrefPathname);
+ value: function _isSsg(route) {
return this.promisedSsgManifest.then(function(s) {
return s.has(route);
});
Diff for index.html
@@ -17,12 +17,12 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3f42defbaad29e58243f.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.623d7f150e977af7a4d1.js"
as="script"
/>
<link
rel="preload"
- href="/_next/static/chunks/main-1fb352c69451c1539541.js"
+ href="/_next/static/chunks/main-84067dfc91b3d7a87517.js"
as="script"
/>
<link
@@ -61,11 +61,11 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3f42defbaad29e58243f.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.623d7f150e977af7a4d1.js"
async=""
></script>
<script
- src="/_next/static/chunks/main-1fb352c69451c1539541.js"
+ src="/_next/static/chunks/main-84067dfc91b3d7a87517.js"
async=""
></script>
<script
Diff for link.html
@@ -17,12 +17,12 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3f42defbaad29e58243f.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.623d7f150e977af7a4d1.js"
as="script"
/>
<link
rel="preload"
- href="/_next/static/chunks/main-1fb352c69451c1539541.js"
+ href="/_next/static/chunks/main-84067dfc91b3d7a87517.js"
as="script"
/>
<link
@@ -66,11 +66,11 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3f42defbaad29e58243f.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.623d7f150e977af7a4d1.js"
async=""
></script>
<script
- src="/_next/static/chunks/main-1fb352c69451c1539541.js"
+ src="/_next/static/chunks/main-84067dfc91b3d7a87517.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -17,12 +17,12 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3f42defbaad29e58243f.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.623d7f150e977af7a4d1.js"
as="script"
/>
<link
rel="preload"
- href="/_next/static/chunks/main-1fb352c69451c1539541.js"
+ href="/_next/static/chunks/main-84067dfc91b3d7a87517.js"
as="script"
/>
<link
@@ -61,11 +61,11 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3f42defbaad29e58243f.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.623d7f150e977af7a4d1.js"
async=""
></script>
<script
- src="/_next/static/chunks/main-1fb352c69451c1539541.js"
+ src="/_next/static/chunks/main-84067dfc91b3d7a87517.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
buildDuration | 19.7s | 18.5s | -1.3s |
nodeModulesSize | 61.7 MB | 61.8 MB |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
597-ec2335c0..e105.js gzip | 13.3 kB | N/A | N/A |
778-b85ea97d..1a55.js gzip | 7.06 kB | N/A | N/A |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 151 B | 151 B | ✓ |
webpack-HASH.js gzip | 993 B | 993 B | ✓ |
597-31f97ebd..2557.js gzip | N/A | 13.3 kB | N/A |
778-c3d86b5d..8162.js gzip | N/A | 7.05 kB | N/A |
Overall change | 60.8 kB | 60.8 kB | -55 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_app-bdbd9e6..6cfe.js gzip | 1.3 kB | 1.3 kB | ✓ |
_error-b58c1..9b8e.js gzip | 3.4 kB | 3.4 kB | ✓ |
amp-89a5460c..567f.js gzip | 558 B | 558 B | ✓ |
hooks-8c2e74..be37.js gzip | 924 B | 924 B | ✓ |
index-fec729..83b2.js gzip | 243 B | 243 B | ✓ |
link-d124373..c521.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..5759.js gzip | 336 B | 336 B | ✓ |
withRouter-1..98bf.js gzip | 334 B | 334 B | ✓ |
Overall change | 8.76 kB | 8.76 kB | ✓ |
Client Build Manifests Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_buildManifest.js gzip | 323 B | 349 B | |
Overall change | 323 B | 349 B |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_error.js | 1.34 MB | 1.34 MB | |
404.html | 2.76 kB | 2.76 kB | ✓ |
500.html | 2.75 kB | 2.75 kB | ✓ |
amp.amp.html | 10.6 kB | 10.6 kB | ✓ |
amp.html | 1.96 kB | 1.96 kB | ✓ |
hooks.html | 2.01 kB | 2.01 kB | ✓ |
index.js | 1.34 MB | 1.34 MB | |
link.js | 1.4 MB | 1.4 MB | |
routerDirect.js | 1.39 MB | 1.39 MB | |
withRouter.js | 1.39 MB | 1.39 MB | |
Overall change | 6.89 MB | 6.89 MB |
Webpack 5 Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
buildDuration | 15.8s | 15.8s | -75ms |
nodeModulesSize | 61.7 MB | 61.8 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.062 | 2.061 | 0 |
/ avg req/sec | 1212.48 | 1212.77 | +0.29 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.366 | 1.425 | |
/error-in-render avg req/sec | 1830.29 | 1753.96 |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
597-ec2335c0..e105.js gzip | 13.3 kB | 13.3 kB | -39 B |
778-b85ea97d..1a55.js gzip | 7.06 kB | 7.05 kB | -16 B |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 151 B | 151 B | ✓ |
webpack-HASH.js gzip | 993 B | 993 B | ✓ |
Overall change | 60.8 kB | 60.8 kB | -55 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_app-bdbd9e6..6cfe.js gzip | 1.3 kB | 1.3 kB | ✓ |
_error-b58c1..9b8e.js gzip | 3.4 kB | 3.4 kB | ✓ |
amp-89a5460c..567f.js gzip | 558 B | 558 B | ✓ |
hooks-8c2e74..be37.js gzip | 924 B | 924 B | ✓ |
index-fec729..83b2.js gzip | 243 B | 243 B | ✓ |
link-d124373..c521.js gzip | 1.66 kB | 1.66 kB | ✓ |
routerDirect..5759.js gzip | 336 B | 336 B | ✓ |
withRouter-1..98bf.js gzip | 334 B | 334 B | ✓ |
Overall change | 8.76 kB | 8.76 kB | ✓ |
Client Build Manifests Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
_buildManifest.js gzip | 323 B | 349 B | |
Overall change | 323 B | 349 B |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | ijjk/next.js add/rewrites-override | Change | |
---|---|---|---|
index.html gzip | 608 B | 609 B | |
link.html gzip | 615 B | 615 B | ✓ |
withRouter.html gzip | 603 B | 603 B | ✓ |
Overall change | 1.83 kB | 1.83 kB |
Diffs
Diff for _buildManifest.js
@@ -1,5 +1,5 @@
(self.__BUILD_MANIFEST = {
- __rewrites: [],
+ __rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },
"/": ["static/chunks/pages/index-fec729acd14e4a5583b2.js"],
"/_error": ["static/chunks/pages/_error-b58c108825251cad9b8e.js"],
"/amp": ["static/chunks/pages/amp-89a5460cada4d99b567f.js"],
Diff for 597-ec2335c0..3014fe105.js
Diff too large to display
Diff for 778-b85ea97d..2c0381a55.js
@@ -265,27 +265,27 @@
C = p(r(7365)),
A = p(r(4829)),
k = r(6975),
- R = r(2441),
- M = JSON.parse(document.getElementById("__NEXT_DATA__").textContent);
- window.__NEXT_DATA__ = M;
+ M = r(2441),
+ R = JSON.parse(document.getElementById("__NEXT_DATA__").textContent);
+ window.__NEXT_DATA__ = R;
t.version = "10.0.10-canary.11";
var N = function(e) {
return [].slice.call(e);
},
- L = M.props,
- F = M.err,
- D = M.page,
- I = M.query,
- j = M.buildId,
- O = M.assetPrefix,
- B = M.runtimeConfig,
- q = M.dynamicIds,
- H = M.isFallback,
- U = M.locale,
- X = M.locales,
- G = M.domainLocales,
- V = M.isPreview,
- W = M.defaultLocale,
+ L = R.props,
+ F = R.err,
+ D = R.page,
+ I = R.query,
+ j = R.buildId,
+ O = R.assetPrefix,
+ B = R.runtimeConfig,
+ q = R.dynamicIds,
+ H = R.isFallback,
+ X = R.locale,
+ U = R.locales,
+ G = R.domainLocales,
+ V = R.isPreview,
+ W = R.defaultLocale,
J = O || "";
(r.p = "".concat(J, "/_next/")),
E.setConfig({ serverRuntimeConfig: {}, publicRuntimeConfig: B || {} });
@@ -334,7 +334,7 @@
this.scrollToHash(),
K.isSsr &&
(H ||
- (M.nextExport &&
+ (R.nextExport &&
((0, _.isDynamicRoute)(K.pathname) ||
location.search)) ||
(L && L.__N_SSG && location.search)) &&
@@ -472,7 +472,7 @@
return (e.next = 36), window.__NEXT_PRELOADREADY(q);
case 36:
return (
- (t.router = K = (0, R.createRouter)(D, I, Y, {
+ (t.router = K = (0, M.createRouter)(D, I, Y, {
initialProps: L,
pageLoader: Q,
App: Z,
@@ -485,8 +485,8 @@
Object.assign({}, e, { App: t, scroll: r })
);
},
- locale: U,
- locales: X,
+ locale: X,
+ locales: U,
defaultLocale: W,
domainLocales: G,
isPreview: V
@@ -666,7 +666,7 @@
},
h.default.createElement(
b.RouterContext.Provider,
- { value: (0, R.makePublicRouterInstance)(K) },
+ { value: (0, M.makePublicRouterInstance)(K) },
h.default.createElement(
y.HeadManagerContext.Provider,
{ value: te },
@@ -848,14 +848,7 @@
l = r(4436),
f = r(6528),
d = a(r(7599));
- function p(e) {
- if ("/" !== e[0])
- throw new Error(
- 'Route name should start with a "/", got "'.concat(e, '"')
- );
- return "/" === e ? e : e.replace(/\/$/, "");
- }
- var m = (function() {
+ var p = (function() {
function e(t, r) {
n(this, e),
(this.buildId = void 0),
@@ -891,10 +884,19 @@
a = (0, l.parseRelativeUrl)(e),
i = a.pathname,
d = a.query,
- m = a.search,
- h = (0, l.parseRelativeUrl)(t).pathname,
- v = p(i),
- y = function(e) {
+ p = a.search,
+ m = (0, l.parseRelativeUrl)(t).pathname,
+ h = (function(e) {
+ if ("/" !== e[0])
+ throw new Error(
+ 'Route name should start with a "/", got "'.concat(
+ e,
+ '"'
+ )
+ );
+ return "/" === e ? e : e.replace(/\/$/, "");
+ })(i),
+ v = function(e) {
var t = (0, c.default)(
(0, f.removePathTrailingSlash)((0, u.addLocale)(e, n)),
".json"
@@ -903,20 +905,19 @@
"/_next/data/"
.concat(o.buildId)
.concat(t)
- .concat(r ? "" : m)
+ .concat(r ? "" : p)
);
},
- g = (0, s.isDynamicRoute)(v),
- b = g ? (0, u.interpolateAs)(i, h, d).result : "";
- return g ? b && y(b) : y(v);
+ y = (0, s.isDynamicRoute)(h),
+ g = y ? (0, u.interpolateAs)(i, m, d).result : "";
+ return y ? g && v(g) : v(h);
}
},
{
key: "_isSsg",
value: function(e) {
- var t = p((0, l.parseRelativeUrl)(e).pathname);
- return this.promisedSsgManifest.then(function(e) {
- return e.has(t);
+ return this.promisedSsgManifest.then(function(t) {
+ return t.has(e);
});
}
},
@@ -946,7 +947,7 @@
e
);
})();
- t.default = m;
+ t.default = p;
},
4829: function(e, t, r) {
"use strict";
Diff for index.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/webpack-078e49533a0386ca09e1.js"
+ href="/_next/static/chunks/webpack-dfd546105f3c6dd0d838.js"
as="script"
/>
<link
@@ -17,12 +17,12 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/597-ec2335c0d7f3014fe105.js"
+ href="/_next/static/chunks/597-31f97ebd636980de2557.js"
as="script"
/>
<link
rel="preload"
- href="/_next/static/chunks/778-b85ea97d3ac2c0381a55.js"
+ href="/_next/static/chunks/778-c3d86b5d4f0b8d5b8162.js"
as="script"
/>
<link
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/",
"query": {},
- "buildId": "MrAtSW_zrMsFRu_QDo-30",
+ "buildId": "RiynqajgHkpyuSjSQLvBP",
"isFallback": false,
"gip": true
}
@@ -58,7 +58,7 @@
src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
></script>
<script
- src="/_next/static/chunks/webpack-078e49533a0386ca09e1.js"
+ src="/_next/static/chunks/webpack-dfd546105f3c6dd0d838.js"
async=""
></script>
<script
@@ -66,11 +66,11 @@
async=""
></script>
<script
- src="/_next/static/chunks/597-ec2335c0d7f3014fe105.js"
+ src="/_next/static/chunks/597-31f97ebd636980de2557.js"
async=""
></script>
<script
- src="/_next/static/chunks/778-b85ea97d3ac2c0381a55.js"
+ src="/_next/static/chunks/778-c3d86b5d4f0b8d5b8162.js"
async=""
></script>
<script
@@ -86,11 +86,11 @@
async=""
></script>
<script
- src="/_next/static/MrAtSW_zrMsFRu_QDo-30/_buildManifest.js"
+ src="/_next/static/RiynqajgHkpyuSjSQLvBP/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/MrAtSW_zrMsFRu_QDo-30/_ssgManifest.js"
+ src="/_next/static/RiynqajgHkpyuSjSQLvBP/_ssgManifest.js"
async=""
></script>
</body>
Diff for link.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/webpack-078e49533a0386ca09e1.js"
+ href="/_next/static/chunks/webpack-dfd546105f3c6dd0d838.js"
as="script"
/>
<link
@@ -17,12 +17,12 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/597-ec2335c0d7f3014fe105.js"
+ href="/_next/static/chunks/597-31f97ebd636980de2557.js"
as="script"
/>
<link
rel="preload"
- href="/_next/static/chunks/778-b85ea97d3ac2c0381a55.js"
+ href="/_next/static/chunks/778-c3d86b5d4f0b8d5b8162.js"
as="script"
/>
<link
@@ -53,7 +53,7 @@
"props": { "pageProps": {} },
"page": "/link",
"query": {},
- "buildId": "MrAtSW_zrMsFRu_QDo-30",
+ "buildId": "RiynqajgHkpyuSjSQLvBP",
"isFallback": false,
"gip": true
}
@@ -63,7 +63,7 @@
src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
></script>
<script
- src="/_next/static/chunks/webpack-078e49533a0386ca09e1.js"
+ src="/_next/static/chunks/webpack-dfd546105f3c6dd0d838.js"
async=""
></script>
<script
@@ -71,11 +71,11 @@
async=""
></script>
<script
- src="/_next/static/chunks/597-ec2335c0d7f3014fe105.js"
+ src="/_next/static/chunks/597-31f97ebd636980de2557.js"
async=""
></script>
<script
- src="/_next/static/chunks/778-b85ea97d3ac2c0381a55.js"
+ src="/_next/static/chunks/778-c3d86b5d4f0b8d5b8162.js"
async=""
></script>
<script
@@ -91,11 +91,11 @@
async=""
></script>
<script
- src="/_next/static/MrAtSW_zrMsFRu_QDo-30/_buildManifest.js"
+ src="/_next/static/RiynqajgHkpyuSjSQLvBP/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/MrAtSW_zrMsFRu_QDo-30/_ssgManifest.js"
+ src="/_next/static/RiynqajgHkpyuSjSQLvBP/_ssgManifest.js"
async=""
></script>
</body>
Diff for withRouter.html
@@ -7,7 +7,7 @@
<noscript data-n-css=""></noscript>
<link
rel="preload"
- href="/_next/static/chunks/webpack-078e49533a0386ca09e1.js"
+ href="/_next/static/chunks/webpack-dfd546105f3c6dd0d838.js"
as="script"
/>
<link
@@ -17,12 +17,12 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/597-ec2335c0d7f3014fe105.js"
+ href="/_next/static/chunks/597-31f97ebd636980de2557.js"
as="script"
/>
<link
rel="preload"
- href="/_next/static/chunks/778-b85ea97d3ac2c0381a55.js"
+ href="/_next/static/chunks/778-c3d86b5d4f0b8d5b8162.js"
as="script"
/>
<link
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/withRouter",
"query": {},
- "buildId": "MrAtSW_zrMsFRu_QDo-30",
+ "buildId": "RiynqajgHkpyuSjSQLvBP",
"isFallback": false,
"gip": true
}
@@ -58,7 +58,7 @@
src="/_next/static/chunks/polyfills-8683bd742a84c1edd48c.js"
></script>
<script
- src="/_next/static/chunks/webpack-078e49533a0386ca09e1.js"
+ src="/_next/static/chunks/webpack-dfd546105f3c6dd0d838.js"
async=""
></script>
<script
@@ -66,11 +66,11 @@
async=""
></script>
<script
- src="/_next/static/chunks/597-ec2335c0d7f3014fe105.js"
+ src="/_next/static/chunks/597-31f97ebd636980de2557.js"
async=""
></script>
<script
- src="/_next/static/chunks/778-b85ea97d3ac2c0381a55.js"
+ src="/_next/static/chunks/778-c3d86b5d4f0b8d5b8162.js"
async=""
></script>
<script
@@ -86,11 +86,11 @@
async=""
></script>
<script
- src="/_next/static/MrAtSW_zrMsFRu_QDo-30/_buildManifest.js"
+ src="/_next/static/RiynqajgHkpyuSjSQLvBP/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/MrAtSW_zrMsFRu_QDo-30/_ssgManifest.js"
+ src="/_next/static/RiynqajgHkpyuSjSQLvBP/_ssgManifest.js"
async=""
></script>
</body>
ijjk
changed the title
Add support for override field for rewrites
Add handling fo beforeFiles, afterFiles, and fallback rewrites
Mar 26, 2021
shuding
approved these changes
Mar 26, 2021
7 tasks
SokratisVidros
pushed a commit
to SokratisVidros/next.js
that referenced
this pull request
Apr 20, 2021
…l#23407) This adds support for returning an object from `rewrites` in `next.config.js` with `beforeFiles`, `afterFiles`, and `fallback` to allow specifying rewrites at different stages of routing. The existing support for returning an array for rewrites is still supported and behaves the same way. The documentation has been updated to include information on these new stages that can be rewritten and removes the outdated note of rewrites not being able to override pages. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added ## 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` - [x] Integration tests added - [x] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. ## Documentation / Examples - [ ] Make sure the linting passes
flybayer
pushed a commit
to blitz-js/next.js
that referenced
this pull request
Apr 29, 2021
…l#23407) This adds support for returning an object from `rewrites` in `next.config.js` with `beforeFiles`, `afterFiles`, and `fallback` to allow specifying rewrites at different stages of routing. The existing support for returning an array for rewrites is still supported and behaves the same way. The documentation has been updated to include information on these new stages that can be rewritten and removes the outdated note of rewrites not being able to override pages. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added ## 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` - [x] Integration tests added - [x] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. ## Documentation / Examples - [ ] Make sure the linting passes
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.
This adds support for returning an object from
rewrites
innext.config.js
withbeforeFiles
,afterFiles
, andfallback
to allow specifying rewrites at different stages of routing. The existing support for returning an array for rewrites is still supported and behaves the same way. The documentation has been updated to include information on these new stages that can be rewritten and removes the outdated note of rewrites not being able to override pages.Bug
fixes #number
Feature
fixes #number
Documentation / Examples