-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Fix asPath of rewrite without basePath #15760
Merged
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
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
buildDuration | 14.5s | 15s | |
nodeModulesSize | 65.5 MB | 65.5 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.676 | 2.783 | |
/ avg req/sec | 934.34 | 898.17 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.657 | 1.691 | |
/error-in-render avg req/sec | 1508.63 | 1478.12 |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
677f882d2ed8..9e81.js gzip | 10.2 kB | 10.2 kB | |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-8dccf8c..edef.js gzip | 6.76 kB | 6.73 kB | -33 B |
webpack-488d..c0e7.js gzip | 751 B | 751 B | ✓ |
Overall change | 56.8 kB | 56.8 kB | -11 B |
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
677f882d2ed8..dule.js gzip | 6.09 kB | 6.12 kB | |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-85e7a5d..dule.js gzip | 5.84 kB | 5.81 kB | -31 B |
webpack-4f62..dule.js gzip | 751 B | 751 B | ✓ |
Overall change | 51.8 kB | 51.8 kB | -4 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
polyfills-05..1236.js gzip | 30.8 kB | 30.8 kB | ✓ |
Overall change | 30.8 kB | 30.8 kB | ✓ |
Client Pages
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_app-8f5f611..1f7b.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-a98d9..5cb7.js gzip | 3.45 kB | 3.45 kB | ✓ |
hooks-f7f3d0..7465.js gzip | 887 B | 887 B | ✓ |
index-08fb3f..c0e9.js gzip | 227 B | 227 B | ✓ |
link-6f8445b..99e1.js gzip | 1.3 kB | 1.3 kB | ✓ |
routerDirect..8aa1.js gzip | 284 B | 284 B | ✓ |
withRouter-f..e777.js gzip | 284 B | 284 B | ✓ |
Overall change | 7.72 kB | 7.72 kB | ✓ |
Client Pages Modern
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_app-669dbe5..dule.js gzip | 626 B | 626 B | ✓ |
_error-d5979..dule.js gzip | 2.3 kB | 2.3 kB | ✓ |
hooks-805c40..dule.js gzip | 387 B | 387 B | ✓ |
index-6ba5a4..dule.js gzip | 226 B | 226 B | ✓ |
link-91516ae..dule.js gzip | 1.25 kB | 1.25 kB | ✓ |
routerDirect..dule.js gzip | 284 B | 284 B | ✓ |
withRouter-d..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 5.36 kB | 5.36 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_buildManifest.js gzip | 274 B | 274 B | ✓ |
_buildManife..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 556 B | 556 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
index.html gzip | 944 B | 948 B | |
link.html gzip | 951 B | 953 B | |
withRouter.html gzip | 939 B | 940 B | |
Overall change | 2.83 kB | 2.84 kB |
Diffs
Diff for 677f882d2ed8..a64f02486.js
@@ -667,6 +667,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
var _createClass = __webpack_require__("W8MJ");
exports.__esModule = true;
+ exports.hasBasePath = hasBasePath;
exports.addBasePath = addBasePath;
exports.delBasePath = delBasePath;
exports.resolveHref = resolveHref;
@@ -706,6 +707,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
});
}
+ function hasBasePath(path) {
+ return path === basePath || path.startsWith(basePath + "/");
+ }
+
function addBasePath(path) {
return basePath
? path === "/"
@@ -1107,7 +1112,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.abortComponentLoad(this._inFlightRoute);
}
- cleanedAs = delBasePath(as);
+ cleanedAs = hasBasePath(as)
+ ? delBasePath(as)
+ : as;
this._inFlightRoute = as; // If the url change is only related to a hash change
// We should not proceed. We should only change the state.
// WARNING: `_h` is an internal option for handing Next.js client-side
Diff for 677f882d2ed8..e4.module.js
@@ -536,6 +536,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
"use strict";
exports.__esModule = true;
+ exports.hasBasePath = hasBasePath;
exports.addBasePath = addBasePath;
exports.delBasePath = delBasePath;
exports.resolveHref = resolveHref;
@@ -575,6 +576,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
});
}
+ function hasBasePath(path) {
+ return path === basePath || path.startsWith(basePath + "/");
+ }
+
function addBasePath(path) {
return basePath
? path === "/"
@@ -919,7 +924,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.abortComponentLoad(this._inFlightRoute);
}
- var cleanedAs = delBasePath(as);
+ var cleanedAs = hasBasePath(as) ? delBasePath(as) : as;
this._inFlightRoute = as; // If the url change is only related to a hash change
// We should not proceed. We should only change the state.
// WARNING: `_h` is an internal option for handing Next.js client-side
Diff for main-092ccd6..1a29504b9.js
@@ -317,15 +317,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
});
var asPath = (0, _utils.getURL)(); // make sure not to attempt stripping basePath for 404s
- if (
- page !== "/404" &&
- !(
- page === "/_error" &&
- hydrateProps &&
- hydrateProps.pageProps &&
- hydrateProps.pageProps.statusCode === 404
- )
- ) {
+ if ((0, _router2.hasBasePath)(asPath)) {
asPath = (0, _router2.delBasePath)(asPath);
}
Diff for main-62a1247..37.module.js
@@ -237,15 +237,7 @@
});
var asPath = (0, _utils.getURL)(); // make sure not to attempt stripping basePath for 404s
- if (
- page !== "/404" &&
- !(
- page === "/_error" &&
- hydrateProps &&
- hydrateProps.pageProps &&
- hydrateProps.pageProps.statusCode === 404
- )
- ) {
+ if ((0, _router2.hasBasePath)(asPath)) {
asPath = (0, _router2.delBasePath)(asPath);
}
Diff for index.html
@@ -6,7 +6,7 @@
<meta name="next-head-count" content="2" />
<link
rel="preload"
- href="/_next/static/chunks/main-62a124753b6705b60b37.module.js"
+ href="/_next/static/chunks/main-63a645b327ebfc44d4e0.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef6cc8889408a3d818e4.module.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4e14fd48cc5b066cb405.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -81,13 +81,13 @@
src="/_next/static/chunks/polyfills-cdbbd579644400b29b58.js"
></script>
<script
- src="/_next/static/chunks/main-092ccd6c8111a29504b9.js"
+ src="/_next/static/chunks/main-11db2adbacdc8afcd350.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/main-62a124753b6705b60b37.module.js"
+ src="/_next/static/chunks/main-63a645b327ebfc44d4e0.module.js"
async=""
crossorigin="anonymous"
type="module"
@@ -117,13 +117,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.41d5d7ded3aa64f02486.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d37adacf5052ad5ed26c.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef6cc8889408a3d818e4.module.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4e14fd48cc5b066cb405.module.js"
async=""
crossorigin="anonymous"
type="module"
Diff for link.html
@@ -6,7 +6,7 @@
<meta name="next-head-count" content="2" />
<link
rel="preload"
- href="/_next/static/chunks/main-62a124753b6705b60b37.module.js"
+ href="/_next/static/chunks/main-63a645b327ebfc44d4e0.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef6cc8889408a3d818e4.module.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4e14fd48cc5b066cb405.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -86,13 +86,13 @@
src="/_next/static/chunks/polyfills-cdbbd579644400b29b58.js"
></script>
<script
- src="/_next/static/chunks/main-092ccd6c8111a29504b9.js"
+ src="/_next/static/chunks/main-11db2adbacdc8afcd350.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/main-62a124753b6705b60b37.module.js"
+ src="/_next/static/chunks/main-63a645b327ebfc44d4e0.module.js"
async=""
crossorigin="anonymous"
type="module"
@@ -122,13 +122,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.41d5d7ded3aa64f02486.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d37adacf5052ad5ed26c.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef6cc8889408a3d818e4.module.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4e14fd48cc5b066cb405.module.js"
async=""
crossorigin="anonymous"
type="module"
Diff for withRouter.html
@@ -6,7 +6,7 @@
<meta name="next-head-count" content="2" />
<link
rel="preload"
- href="/_next/static/chunks/main-62a124753b6705b60b37.module.js"
+ href="/_next/static/chunks/main-63a645b327ebfc44d4e0.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -24,7 +24,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef6cc8889408a3d818e4.module.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4e14fd48cc5b066cb405.module.js"
as="script"
crossorigin="anonymous"
/>
@@ -81,13 +81,13 @@
src="/_next/static/chunks/polyfills-cdbbd579644400b29b58.js"
></script>
<script
- src="/_next/static/chunks/main-092ccd6c8111a29504b9.js"
+ src="/_next/static/chunks/main-11db2adbacdc8afcd350.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/main-62a124753b6705b60b37.module.js"
+ src="/_next/static/chunks/main-63a645b327ebfc44d4e0.module.js"
async=""
crossorigin="anonymous"
type="module"
@@ -117,13 +117,13 @@
type="module"
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.41d5d7ded3aa64f02486.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d37adacf5052ad5ed26c.js"
async=""
crossorigin="anonymous"
nomodule=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef6cc8889408a3d818e4.module.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4e14fd48cc5b066cb405.module.js"
async=""
crossorigin="anonymous"
type="module"
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
buildDuration | 16.3s | 16.5s | |
nodeModulesSize | 65.5 MB | 65.5 MB |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
677f882d2ed8..9e81.js gzip | 10.2 kB | N/A | N/A |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-8dccf8c..edef.js gzip | 6.76 kB | N/A | N/A |
webpack-488d..c0e7.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..70d8.js gzip | N/A | 10.2 kB | N/A |
main-06588f2..f65e.js gzip | N/A | 6.73 kB | N/A |
Overall change | 56.8 kB | 56.8 kB | -11 B |
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
677f882d2ed8..dule.js gzip | 6.09 kB | N/A | N/A |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
main-85e7a5d..dule.js gzip | 5.84 kB | N/A | N/A |
webpack-4f62..dule.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..dule.js gzip | N/A | 6.12 kB | N/A |
main-62e1f09..dule.js gzip | N/A | 5.81 kB | N/A |
Overall change | 51.8 kB | 51.8 kB | -4 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
polyfills-05..1236.js gzip | 30.8 kB | 30.8 kB | ✓ |
Overall change | 30.8 kB | 30.8 kB | ✓ |
Client Pages
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_app-8f5f611..1f7b.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-a98d9..5cb7.js gzip | 3.45 kB | 3.45 kB | ✓ |
hooks-f7f3d0..7465.js gzip | 887 B | 887 B | ✓ |
index-08fb3f..c0e9.js gzip | 227 B | 227 B | ✓ |
link-6f8445b..99e1.js gzip | 1.3 kB | 1.3 kB | ✓ |
routerDirect..8aa1.js gzip | 284 B | 284 B | ✓ |
withRouter-f..e777.js gzip | 284 B | 284 B | ✓ |
Overall change | 7.72 kB | 7.72 kB | ✓ |
Client Pages Modern
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_app-669dbe5..dule.js gzip | 626 B | 626 B | ✓ |
_error-d5979..dule.js gzip | 2.3 kB | 2.3 kB | ✓ |
hooks-805c40..dule.js gzip | 387 B | 387 B | ✓ |
index-6ba5a4..dule.js gzip | 226 B | 226 B | ✓ |
link-91516ae..dule.js gzip | 1.25 kB | 1.25 kB | ✓ |
routerDirect..dule.js gzip | 284 B | 284 B | ✓ |
withRouter-d..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 5.36 kB | 5.36 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_buildManifest.js gzip | 274 B | 274 B | ✓ |
_buildManife..dule.js gzip | 282 B | 282 B | ✓ |
Overall change | 556 B | 556 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | Janpot/next.js basepath2 | Change | |
---|---|---|---|
_error.js | 1.02 MB | 1.02 MB | ✓ |
404.html | 4.18 kB | 4.18 kB | ✓ |
hooks.html | 3.82 kB | 3.82 kB | ✓ |
index.js | 1.02 MB | 1.02 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.2 MB | 5.2 MB |
Janpot
requested review from
ijjk,
lfades,
Timer and
timneutkens
as code owners
August 1, 2020 02:59
timneutkens
approved these changes
Aug 1, 2020
Closed
LauraBeatris
pushed a commit
to LauraBeatris/next.js
that referenced
this pull request
Sep 1, 2020
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.
Fixes #15755