Skip to content
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 basePath in link component and add/remove it consistently #9988

Merged
merged 13 commits into from
Apr 14, 2020

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Jan 8, 2020

As discussed with @timneutkens, this makes sure to call addBasePath for the Link component and apply it consistently in the router. It also makes sure to strip the basePath before attempting to call prefetch and loadPage since we don't nest the pages under the basePath e.g. _next/static/BUILD_ID/pages and not _next/static/BUILD_ID/BASE_PATH/pages.

This also makes sure we 404 when a basePath is set but is not present on a request

@ijjk
Copy link
Member Author

ijjk commented Jan 8, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.9s 12.8s -103ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +717 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..7ed0.js gzip 13.7 kB 13.8 kB ⚠️ +43 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 67.4 kB 67.5 kB ⚠️ +43 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.5 kB ⚠️ +42 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.1 kB ⚠️ +42 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB ⚠️ +2 B
link.html gzip 1.03 kB 1.03 kB ⚠️ +1 B
withRouter.html gzip 1.01 kB 1.02 kB ⚠️ +1 B
Overall change 3.06 kB 3.06 kB ⚠️ +4 B

Diffs

Diff for link.js
@@ -449,6 +449,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -562,8 +564,10 @@
 
             _this.formatUrls = memoizedFormatUrl(function(href, asHref) {
               return {
-                href: formatUrl(href),
-                as: asHref ? formatUrl(asHref) : asHref,
+                href: (0, _router2.addBasePath)(formatUrl(href)),
+                as: asHref
+                  ? (0, _router2.addBasePath)(formatUrl(asHref))
+                  : asHref,
               }
             })
Diff for link.module.js
@@ -324,6 +324,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -426,8 +428,10 @@
 
           this.formatUrls = memoizedFormatUrl((href, asHref) => {
             return {
-              href: formatUrl(href),
-              as: asHref ? formatUrl(asHref) : asHref,
+              href: (0, _router2.addBasePath)(formatUrl(href)),
+              as: asHref
+                ? (0, _router2.addBasePath)(formatUrl(asHref))
+                : asHref,
             }
           })
Diff for de003c3a9d30..1a52f8812.js
@@ -1444,12 +1444,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.replace(new RegExp('^'.concat(basePath)), '')
       }
 
       function toRoute(path) {
@@ -1715,7 +1721,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     var as =
                       typeof _as === 'object'
                         ? utils_1.formatWithValidation(_as)
-                        : _as // Add the ending slash to the paths. So, we can serve the
+                        : _as
+                    url = addBasePath(url)
+                    as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
                     // "<page>/index.html" directly for the SSR page.
 
                     if (false) {
@@ -1732,7 +1740,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                       _this2.asPath = as
                       Router.events.emit('hashChangeStart', as)
 
-                      _this2.changeState(method, url, addBasePath(as))
+                      _this2.changeState(method, url, as)
 
                       _this2.scrollToHash(as)
 
@@ -1808,12 +1816,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                         Router.events.emit('beforeHistoryChange', as)
 
-                        _this2.changeState(
-                          method,
-                          url,
-                          addBasePath(as),
-                          options
-                        )
+                        _this2.changeState(method, url, as, options)
 
                         var hash = window.location.hash.substring(1)
 
@@ -2092,9 +2095,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
                     if (false) {
-                    } // @ts-ignore pathname is always defined
+                    }
 
-                    var route = toRoute(pathname)
+                    var route = delBasePath(toRoute(pathname))
 
                     _this4.pageLoader.prefetch(route).then(resolve, reject)
                   })
@@ -2115,16 +2118,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               cancelled = true
                             }
 
-                            _context.next = 4
+                            route = delBasePath(route)
+                            _context.next = 5
                             return _regeneratorRuntime.awrap(
                               this.pageLoader.loadPage(route)
                             )
 
-                          case 4:
+                          case 5:
                             Component = _context.sent
 
                             if (!cancelled) {
-                              _context.next = 9
+                              _context.next = 10
                               break
                             }
 
@@ -2137,14 +2141,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             error.cancelled = true
                             throw error
 
-                          case 9:
+                          case 10:
                             if (cancel === this.clc) {
                               this.clc = null
                             }
 
                             return _context.abrupt('return', Component)
 
-                          case 11:
+                          case 12:
                           case 'end':
                             return _context.stop()
                         }
Diff for de003c3a9d30..94.module.js
@@ -1789,12 +1789,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.replace(new RegExp('^'.concat(basePath)), '')
       }
 
       function toRoute(path) {
@@ -2036,7 +2042,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 ? utils_1.formatWithValidation(_url)
                 : _url
             var as =
-              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as // Add the ending slash to the paths. So, we can serve the
+              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as
+            url = addBasePath(url)
+            as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
 
             if (false) {
@@ -2052,7 +2060,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             if (!options._h && this.onlyAHashChange(as)) {
               this.asPath = as
               Router.events.emit('hashChangeStart', as)
-              this.changeState(method, url, addBasePath(as))
+              this.changeState(method, url, as)
               this.scrollToHash(as)
               Router.events.emit('hashChangeComplete', as)
               return resolve(true)
@@ -2117,7 +2125,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 Router.events.emit('beforeHistoryChange', as)
-                this.changeState(method, url, addBasePath(as), options)
+                this.changeState(method, url, as, options)
                 var hash = window.location.hash.substring(1)
 
                 if (false) {
@@ -2357,9 +2365,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
             if (false) {
-            } // @ts-ignore pathname is always defined
+            }
 
-            var route = toRoute(pathname)
+            var route = delBasePath(toRoute(pathname))
             this.pageLoader.prefetch(route).then(resolve, reject)
           })
         }
@@ -2371,6 +2379,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             cancelled = true
           })
 
+          route = delBasePath(route)
           var Component = await this.pageLoader.loadPage(route)
 
           if (cancelled) {
Diff for index.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.81d530ce41345e943b94.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.018351ff1349baf8f995.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.70c66df54d21a52f8812.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6b5671fdfa1315bdea21.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.81d530ce41345e943b94.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.018351ff1349baf8f995.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.81d530ce41345e943b94.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.018351ff1349baf8f995.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -156,13 +156,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.70c66df54d21a52f8812.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6b5671fdfa1315bdea21.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.81d530ce41345e943b94.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.018351ff1349baf8f995.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.81d530ce41345e943b94.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.018351ff1349baf8f995.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.70c66df54d21a52f8812.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6b5671fdfa1315bdea21.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.81d530ce41345e943b94.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.018351ff1349baf8f995.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 13s 13.6s ⚠️ +590ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +717 B
Client Bundles (main, webpack, commons)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..7ed0.js gzip 13.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..8094.js gzip N/A 13.8 kB N/A
Overall change 67.4 kB 67.5 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.5 kB N/A
Overall change 62.1 kB 62.1 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 77.8 kB 77.8 kB ⚠️ +51 B
hooks.html gzip 1.05 kB 1.05 kB ⚠️ +3 B
index.js gzip 78 kB 78 kB ⚠️ +47 B
link.js gzip 80.4 kB 80.4 kB ⚠️ +71 B
routerDirect.js gzip 78 kB 78.1 kB ⚠️ +52 B
withRouter.js gzip 78.1 kB 78.2 kB ⚠️ +51 B
Overall change 393 kB 394 kB ⚠️ +275 B

Commit: 32c26be

@Janpot
Copy link
Contributor

Janpot commented Jan 8, 2020

As a user I may have the need to do something like addBasePath in my code as well. Would it make sense to expose this function somewhere? Or expose the basePath value somewhere? Maybe on the Router instance?

@ijjk
Copy link
Member Author

ijjk commented Jan 8, 2020

Exposed addBasePath as a Router method

@ijjk
Copy link
Member Author

ijjk commented Jan 8, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 11.9s 11.9s -66ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.12 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB 13.8 kB ⚠️ +53 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 67.4 kB 67.5 kB ⚠️ +53 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.5 kB ⚠️ +50 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.1 kB ⚠️ +50 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB -2 B
link.html gzip 1.03 kB 1.03 kB -2 B
withRouter.html gzip 1.01 kB 1.01 kB -2 B
Overall change 3.06 kB 3.06 kB -6 B

Diffs

Diff for link.js
@@ -449,6 +449,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -562,8 +564,10 @@
 
             _this.formatUrls = memoizedFormatUrl(function(href, asHref) {
               return {
-                href: formatUrl(href),
-                as: asHref ? formatUrl(asHref) : asHref,
+                href: (0, _router2.addBasePath)(formatUrl(href)),
+                as: asHref
+                  ? (0, _router2.addBasePath)(formatUrl(asHref))
+                  : asHref,
               }
             })
Diff for link.module.js
@@ -324,6 +324,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -426,8 +428,10 @@
 
           this.formatUrls = memoizedFormatUrl((href, asHref) => {
             return {
-              href: formatUrl(href),
-              as: asHref ? formatUrl(asHref) : asHref,
+              href: (0, _router2.addBasePath)(formatUrl(href)),
+              as: asHref
+                ? (0, _router2.addBasePath)(formatUrl(asHref))
+                : asHref,
             }
           })
Diff for de003c3a9d30..26.module.js
@@ -1789,12 +1789,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1814,6 +1822,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           } = _ref
           // Static Data Cache
           this.sdc = {}
+          this.addBasePath = addBasePath
 
           this.onPopState = e => {
             if (!e.state) {
@@ -2036,7 +2045,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 ? utils_1.formatWithValidation(_url)
                 : _url
             var as =
-              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as // Add the ending slash to the paths. So, we can serve the
+              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as
+            url = addBasePath(url)
+            as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
 
             if (false) {
@@ -2052,7 +2063,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             if (!options._h && this.onlyAHashChange(as)) {
               this.asPath = as
               Router.events.emit('hashChangeStart', as)
-              this.changeState(method, url, addBasePath(as))
+              this.changeState(method, url, as)
               this.scrollToHash(as)
               Router.events.emit('hashChangeComplete', as)
               return resolve(true)
@@ -2117,7 +2128,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 Router.events.emit('beforeHistoryChange', as)
-                this.changeState(method, url, addBasePath(as), options)
+                this.changeState(method, url, as, options)
                 var hash = window.location.hash.substring(1)
 
                 if (false) {
@@ -2357,9 +2368,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
             if (false) {
-            } // @ts-ignore pathname is always defined
+            }
 
-            var route = toRoute(pathname)
+            var route = delBasePath(toRoute(pathname))
             this.pageLoader.prefetch(route).then(resolve, reject)
           })
         }
@@ -2371,6 +2382,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             cancelled = true
           })
 
+          route = delBasePath(route)
           var Component = await this.pageLoader.loadPage(route)
 
           if (cancelled) {
@@ -3063,6 +3075,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'back',
         'prefetch',
         'beforePopState',
+        'addBasePath',
       ] // Events is a static property on the router, the router doesn't have to be initialized to use it
 
       ;(0, _defineProperty.default)(singletonRouter, 'events', {
Diff for de003c3a9d30..ba6a65095.js
@@ -1444,12 +1444,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1474,6 +1482,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
             // Static Data Cache
             this.sdc = {}
+            this.addBasePath = addBasePath
 
             this.onPopState = function(e) {
               if (!e.state) {
@@ -1715,7 +1724,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     var as =
                       typeof _as === 'object'
                         ? utils_1.formatWithValidation(_as)
-                        : _as // Add the ending slash to the paths. So, we can serve the
+                        : _as
+                    url = addBasePath(url)
+                    as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
                     // "<page>/index.html" directly for the SSR page.
 
                     if (false) {
@@ -1732,7 +1743,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                       _this2.asPath = as
                       Router.events.emit('hashChangeStart', as)
 
-                      _this2.changeState(method, url, addBasePath(as))
+                      _this2.changeState(method, url, as)
 
                       _this2.scrollToHash(as)
 
@@ -1808,12 +1819,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                         Router.events.emit('beforeHistoryChange', as)
 
-                        _this2.changeState(
-                          method,
-                          url,
-                          addBasePath(as),
-                          options
-                        )
+                        _this2.changeState(method, url, as, options)
 
                         var hash = window.location.hash.substring(1)
 
@@ -2092,9 +2098,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
                     if (false) {
-                    } // @ts-ignore pathname is always defined
+                    }
 
-                    var route = toRoute(pathname)
+                    var route = delBasePath(toRoute(pathname))
 
                     _this4.pageLoader.prefetch(route).then(resolve, reject)
                   })
@@ -2115,16 +2121,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               cancelled = true
                             }
 
-                            _context.next = 4
+                            route = delBasePath(route)
+                            _context.next = 5
                             return _regeneratorRuntime.awrap(
                               this.pageLoader.loadPage(route)
                             )
 
-                          case 4:
+                          case 5:
                             Component = _context.sent
 
                             if (!cancelled) {
-                              _context.next = 9
+                              _context.next = 10
                               break
                             }
 
@@ -2137,14 +2144,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             error.cancelled = true
                             throw error
 
-                          case 9:
+                          case 10:
                             if (cancel === this.clc) {
                               this.clc = null
                             }
 
                             return _context.abrupt('return', Component)
 
-                          case 11:
+                          case 12:
                           case 'end':
                             return _context.stop()
                         }
@@ -3671,6 +3678,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'back',
         'prefetch',
         'beforePopState',
+        'addBasePath',
       ] // Events is a static property on the router, the router doesn't have to be initialized to use it
 
       ;(0, _defineProperty['default'])(singletonRouter, 'events', {
Diff for index.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e7d31744fad00e576f71.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -156,13 +156,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e7d31744fad00e576f71.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e7d31744fad00e576f71.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.3s 12.3s ⚠️ +39ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.12 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..799b.js gzip N/A 13.8 kB N/A
Overall change 67.4 kB 67.5 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.5 kB N/A
Overall change 62.1 kB 62.1 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 77.8 kB 77.8 kB ⚠️ +81 B
hooks.html gzip 1.05 kB 1.05 kB
index.js gzip 78 kB 78 kB ⚠️ +76 B
link.js gzip 80.4 kB 80.5 kB ⚠️ +98 B
routerDirect.js gzip 78 kB 78.1 kB ⚠️ +80 B
withRouter.js gzip 78.1 kB 78.2 kB ⚠️ +81 B
Overall change 393 kB 394 kB ⚠️ +416 B

Commit: 40fed59

@timneutkens
Copy link
Member

addBasePath shouldn't be exposed. basePath on the router sounds more logical to me.

@ijjk
Copy link
Member Author

ijjk commented Jan 8, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.7s 12.9s ⚠️ +126ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.12 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB 13.8 kB ⚠️ +53 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 67.4 kB 67.5 kB ⚠️ +53 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.5 kB ⚠️ +50 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.1 kB ⚠️ +50 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB -2 B
link.html gzip 1.03 kB 1.03 kB -2 B
withRouter.html gzip 1.01 kB 1.01 kB -2 B
Overall change 3.06 kB 3.06 kB -6 B

Diffs

Diff for link.js
@@ -449,6 +449,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -562,8 +564,10 @@
 
             _this.formatUrls = memoizedFormatUrl(function(href, asHref) {
               return {
-                href: formatUrl(href),
-                as: asHref ? formatUrl(asHref) : asHref,
+                href: (0, _router2.addBasePath)(formatUrl(href)),
+                as: asHref
+                  ? (0, _router2.addBasePath)(formatUrl(asHref))
+                  : asHref,
               }
             })
Diff for link.module.js
@@ -324,6 +324,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -426,8 +428,10 @@
 
           this.formatUrls = memoizedFormatUrl((href, asHref) => {
             return {
-              href: formatUrl(href),
-              as: asHref ? formatUrl(asHref) : asHref,
+              href: (0, _router2.addBasePath)(formatUrl(href)),
+              as: asHref
+                ? (0, _router2.addBasePath)(formatUrl(asHref))
+                : asHref,
             }
           })
Diff for de003c3a9d30..26.module.js
@@ -1789,12 +1789,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1814,6 +1822,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           } = _ref
           // Static Data Cache
           this.sdc = {}
+          this.addBasePath = addBasePath
 
           this.onPopState = e => {
             if (!e.state) {
@@ -2036,7 +2045,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 ? utils_1.formatWithValidation(_url)
                 : _url
             var as =
-              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as // Add the ending slash to the paths. So, we can serve the
+              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as
+            url = addBasePath(url)
+            as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
 
             if (false) {
@@ -2052,7 +2063,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             if (!options._h && this.onlyAHashChange(as)) {
               this.asPath = as
               Router.events.emit('hashChangeStart', as)
-              this.changeState(method, url, addBasePath(as))
+              this.changeState(method, url, as)
               this.scrollToHash(as)
               Router.events.emit('hashChangeComplete', as)
               return resolve(true)
@@ -2117,7 +2128,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 Router.events.emit('beforeHistoryChange', as)
-                this.changeState(method, url, addBasePath(as), options)
+                this.changeState(method, url, as, options)
                 var hash = window.location.hash.substring(1)
 
                 if (false) {
@@ -2357,9 +2368,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
             if (false) {
-            } // @ts-ignore pathname is always defined
+            }
 
-            var route = toRoute(pathname)
+            var route = delBasePath(toRoute(pathname))
             this.pageLoader.prefetch(route).then(resolve, reject)
           })
         }
@@ -2371,6 +2382,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             cancelled = true
           })
 
+          route = delBasePath(route)
           var Component = await this.pageLoader.loadPage(route)
 
           if (cancelled) {
@@ -3063,6 +3075,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'back',
         'prefetch',
         'beforePopState',
+        'addBasePath',
       ] // Events is a static property on the router, the router doesn't have to be initialized to use it
 
       ;(0, _defineProperty.default)(singletonRouter, 'events', {
Diff for de003c3a9d30..ba6a65095.js
@@ -1444,12 +1444,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1474,6 +1482,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
             // Static Data Cache
             this.sdc = {}
+            this.addBasePath = addBasePath
 
             this.onPopState = function(e) {
               if (!e.state) {
@@ -1715,7 +1724,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     var as =
                       typeof _as === 'object'
                         ? utils_1.formatWithValidation(_as)
-                        : _as // Add the ending slash to the paths. So, we can serve the
+                        : _as
+                    url = addBasePath(url)
+                    as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
                     // "<page>/index.html" directly for the SSR page.
 
                     if (false) {
@@ -1732,7 +1743,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                       _this2.asPath = as
                       Router.events.emit('hashChangeStart', as)
 
-                      _this2.changeState(method, url, addBasePath(as))
+                      _this2.changeState(method, url, as)
 
                       _this2.scrollToHash(as)
 
@@ -1808,12 +1819,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                         Router.events.emit('beforeHistoryChange', as)
 
-                        _this2.changeState(
-                          method,
-                          url,
-                          addBasePath(as),
-                          options
-                        )
+                        _this2.changeState(method, url, as, options)
 
                         var hash = window.location.hash.substring(1)
 
@@ -2092,9 +2098,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
                     if (false) {
-                    } // @ts-ignore pathname is always defined
+                    }
 
-                    var route = toRoute(pathname)
+                    var route = delBasePath(toRoute(pathname))
 
                     _this4.pageLoader.prefetch(route).then(resolve, reject)
                   })
@@ -2115,16 +2121,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               cancelled = true
                             }
 
-                            _context.next = 4
+                            route = delBasePath(route)
+                            _context.next = 5
                             return _regeneratorRuntime.awrap(
                               this.pageLoader.loadPage(route)
                             )
 
-                          case 4:
+                          case 5:
                             Component = _context.sent
 
                             if (!cancelled) {
-                              _context.next = 9
+                              _context.next = 10
                               break
                             }
 
@@ -2137,14 +2144,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             error.cancelled = true
                             throw error
 
-                          case 9:
+                          case 10:
                             if (cancel === this.clc) {
                               this.clc = null
                             }
 
                             return _context.abrupt('return', Component)
 
-                          case 11:
+                          case 12:
                           case 'end':
                             return _context.stop()
                         }
@@ -3671,6 +3678,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'back',
         'prefetch',
         'beforePopState',
+        'addBasePath',
       ] // Events is a static property on the router, the router doesn't have to be initialized to use it
 
       ;(0, _defineProperty['default'])(singletonRouter, 'events', {
Diff for index.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e7d31744fad00e576f71.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -156,13 +156,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e7d31744fad00e576f71.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e7d31744fad00e576f71.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.2274b5b146a0ab930cc0.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 13.2s 13.3s ⚠️ +138ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.12 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..799b.js gzip N/A 13.8 kB N/A
Overall change 67.4 kB 67.5 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.5 kB N/A
Overall change 62.1 kB 62.1 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 77.8 kB 77.8 kB ⚠️ +81 B
hooks.html gzip 1.05 kB 1.05 kB
index.js gzip 78 kB 78 kB ⚠️ +76 B
link.js gzip 80.4 kB 80.5 kB ⚠️ +98 B
routerDirect.js gzip 78 kB 78.1 kB ⚠️ +80 B
withRouter.js gzip 78.1 kB 78.2 kB ⚠️ +81 B
Overall change 393 kB 394 kB ⚠️ +416 B

Commit: 4b5bf8a

@ijjk
Copy link
Member Author

ijjk commented Jan 8, 2020

Updated to expose a basePath field on the Router instead of the addBasePath method and added a test for it

@ijjk
Copy link
Member Author

ijjk commented Jan 8, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.3s 12.7s ⚠️ +324ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.52 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB 13.8 kB ⚠️ +55 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 67.4 kB 67.5 kB ⚠️ +55 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.5 kB ⚠️ +52 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.1 kB ⚠️ +52 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB
link.html gzip 1.03 kB 1.03 kB -1 B
withRouter.html gzip 1.01 kB 1.02 kB ⚠️ +1 B
Overall change 3.06 kB 3.06 kB

Diffs

Diff for link.js
@@ -449,6 +449,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -562,8 +564,10 @@
 
             _this.formatUrls = memoizedFormatUrl(function(href, asHref) {
               return {
-                href: formatUrl(href),
-                as: asHref ? formatUrl(asHref) : asHref,
+                href: (0, _router2.addBasePath)(formatUrl(href)),
+                as: asHref
+                  ? (0, _router2.addBasePath)(formatUrl(asHref))
+                  : asHref,
               }
             })
Diff for link.module.js
@@ -324,6 +324,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -426,8 +428,10 @@
 
           this.formatUrls = memoizedFormatUrl((href, asHref) => {
             return {
-              href: formatUrl(href),
-              as: asHref ? formatUrl(asHref) : asHref,
+              href: (0, _router2.addBasePath)(formatUrl(href)),
+              as: asHref
+                ? (0, _router2.addBasePath)(formatUrl(asHref))
+                : asHref,
             }
           })
Diff for de003c3a9d30..26.module.js
@@ -1789,12 +1789,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1919,6 +1927,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport
               ? pathname
               : as
+          this.basePath = basePath
           this.sub = subscription
           this.clc = null
           this._wrapApp = wrapApp // make sure to ignore extra popState in safari on navigating
@@ -2036,7 +2045,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 ? utils_1.formatWithValidation(_url)
                 : _url
             var as =
-              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as // Add the ending slash to the paths. So, we can serve the
+              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as
+            url = addBasePath(url)
+            as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
 
             if (false) {
@@ -2052,7 +2063,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             if (!options._h && this.onlyAHashChange(as)) {
               this.asPath = as
               Router.events.emit('hashChangeStart', as)
-              this.changeState(method, url, addBasePath(as))
+              this.changeState(method, url, as)
               this.scrollToHash(as)
               Router.events.emit('hashChangeComplete', as)
               return resolve(true)
@@ -2117,7 +2128,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 Router.events.emit('beforeHistoryChange', as)
-                this.changeState(method, url, addBasePath(as), options)
+                this.changeState(method, url, as, options)
                 var hash = window.location.hash.substring(1)
 
                 if (false) {
@@ -2357,9 +2368,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
             if (false) {
-            } // @ts-ignore pathname is always defined
+            }
 
-            var route = toRoute(pathname)
+            var route = delBasePath(toRoute(pathname))
             this.pageLoader.prefetch(route).then(resolve, reject)
           })
         }
@@ -2371,6 +2382,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             cancelled = true
           })
 
+          route = delBasePath(route)
           var Component = await this.pageLoader.loadPage(route)
 
           if (cancelled) {
@@ -3047,6 +3059,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'query',
         'asPath',
         'components',
+        'basePath',
       ]
       var routerEvents = [
         'routeChangeStart',
Diff for de003c3a9d30..ba6a65095.js
@@ -1444,12 +1444,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_matcher_1 = __webpack_require__('gguc')
 
-      var route_regex_1 = __webpack_require__('YTqd')
+      var route_regex_1 = __webpack_require__('YTqd') // @ts-ignore variable is always a string
+
+      var basePath = ''
 
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1585,6 +1593,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport
                 ? pathname
                 : as
+            this.basePath = basePath
             this.sub = subscription
             this.clc = null
             this._wrapApp = wrapApp // make sure to ignore extra popState in safari on navigating
@@ -1715,7 +1724,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     var as =
                       typeof _as === 'object'
                         ? utils_1.formatWithValidation(_as)
-                        : _as // Add the ending slash to the paths. So, we can serve the
+                        : _as
+                    url = addBasePath(url)
+                    as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
                     // "<page>/index.html" directly for the SSR page.
 
                     if (false) {
@@ -1732,7 +1743,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                       _this2.asPath = as
                       Router.events.emit('hashChangeStart', as)
 
-                      _this2.changeState(method, url, addBasePath(as))
+                      _this2.changeState(method, url, as)
 
                       _this2.scrollToHash(as)
 
@@ -1808,12 +1819,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                         Router.events.emit('beforeHistoryChange', as)
 
-                        _this2.changeState(
-                          method,
-                          url,
-                          addBasePath(as),
-                          options
-                        )
+                        _this2.changeState(method, url, as, options)
 
                         var hash = window.location.hash.substring(1)
 
@@ -2092,9 +2098,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
                     if (false) {
-                    } // @ts-ignore pathname is always defined
+                    }
 
-                    var route = toRoute(pathname)
+                    var route = delBasePath(toRoute(pathname))
 
                     _this4.pageLoader.prefetch(route).then(resolve, reject)
                   })
@@ -2115,16 +2121,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               cancelled = true
                             }
 
-                            _context.next = 4
+                            route = delBasePath(route)
+                            _context.next = 5
                             return _regeneratorRuntime.awrap(
                               this.pageLoader.loadPage(route)
                             )
 
-                          case 4:
+                          case 5:
                             Component = _context.sent
 
                             if (!cancelled) {
-                              _context.next = 9
+                              _context.next = 10
                               break
                             }
 
@@ -2137,14 +2144,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             error.cancelled = true
                             throw error
 
-                          case 9:
+                          case 10:
                             if (cancel === this.clc) {
                               this.clc = null
                             }
 
                             return _context.abrupt('return', Component)
 
-                          case 11:
+                          case 12:
                           case 'end':
                             return _context.stop()
                         }
@@ -3655,6 +3662,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'query',
         'asPath',
         'components',
+        'basePath',
       ]
       var routerEvents = [
         'routeChangeStart',
Diff for index.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.8f79b1e44726555b5086.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e4ec660fc043b8b123b7.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.8f79b1e44726555b5086.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.8f79b1e44726555b5086.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -156,13 +156,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e4ec660fc043b8b123b7.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.8f79b1e44726555b5086.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.8f79b1e44726555b5086.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e4ec660fc043b8b123b7.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.8f79b1e44726555b5086.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.8s 12.5s -273ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.52 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..6887.js gzip N/A 13.8 kB N/A
Overall change 67.4 kB 67.5 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.5 kB N/A
Overall change 62.1 kB 62.1 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 77.8 kB 77.8 kB ⚠️ +89 B
hooks.html gzip 1.05 kB 1.05 kB ⚠️ +2 B
index.js gzip 78 kB 78 kB ⚠️ +86 B
link.js gzip 80.4 kB 80.5 kB ⚠️ +105 B
routerDirect.js gzip 78 kB 78.1 kB ⚠️ +86 B
withRouter.js gzip 78.1 kB 78.2 kB ⚠️ +89 B
Overall change 393 kB 394 kB ⚠️ +457 B

Commit: ce68478

@ijjk ijjk requested a review from Timer January 12, 2020 19:05
@ijjk
Copy link
Member Author

ijjk commented Jan 12, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 14.1s 13.9s -237ms
nodeModulesSize 49 MB 49 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB 13.8 kB ⚠️ +55 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 67.5 kB 67.5 kB ⚠️ +55 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.18 kB 4.18 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.5 kB ⚠️ +52 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.1 kB ⚠️ +52 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB ⚠️ +1 B
link.html gzip 1.03 kB 1.03 kB ⚠️ +1 B
withRouter.html gzip 1.01 kB 1.02 kB ⚠️ +1 B
Overall change 3.06 kB 3.07 kB ⚠️ +3 B

Diffs

Diff for link.js
@@ -449,6 +449,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -562,8 +564,10 @@
 
             _this.formatUrls = memoizedFormatUrl(function(href, asHref) {
               return {
-                href: formatUrl(href),
-                as: asHref ? formatUrl(asHref) : asHref,
+                href: (0, _router2.addBasePath)(formatUrl(href)),
+                as: asHref
+                  ? (0, _router2.addBasePath)(formatUrl(asHref))
+                  : asHref,
               }
             })
Diff for link.module.js
@@ -324,6 +324,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -426,8 +428,10 @@
 
           this.formatUrls = memoizedFormatUrl((href, asHref) => {
             return {
-              href: formatUrl(href),
-              as: asHref ? formatUrl(asHref) : asHref,
+              href: (0, _router2.addBasePath)(formatUrl(href)),
+              as: asHref
+                ? (0, _router2.addBasePath)(formatUrl(asHref))
+                : asHref,
             }
           })
Diff for de003c3a9d30..26.module.js
@@ -1791,10 +1791,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_regex_1 = __webpack_require__('YTqd')
 
+      var basePath = ''
+
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1919,6 +1927,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport
               ? pathname
               : as
+          this.basePath = basePath
           this.sub = subscription
           this.clc = null
           this._wrapApp = wrapApp // make sure to ignore extra popState in safari on navigating
@@ -2036,7 +2045,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 ? utils_1.formatWithValidation(_url)
                 : _url
             var as =
-              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as // Add the ending slash to the paths. So, we can serve the
+              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as
+            url = addBasePath(url)
+            as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
 
             if (false) {
@@ -2052,7 +2063,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             if (!options._h && this.onlyAHashChange(as)) {
               this.asPath = as
               Router.events.emit('hashChangeStart', as)
-              this.changeState(method, url, addBasePath(as))
+              this.changeState(method, url, as)
               this.scrollToHash(as)
               Router.events.emit('hashChangeComplete', as)
               return resolve(true)
@@ -2117,7 +2128,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 Router.events.emit('beforeHistoryChange', as)
-                this.changeState(method, url, addBasePath(as), options)
+                this.changeState(method, url, as, options)
                 var hash = window.location.hash.substring(1)
 
                 if (false) {
@@ -2357,9 +2368,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
             if (false) {
-            } // @ts-ignore pathname is always defined
+            }
 
-            var route = toRoute(pathname)
+            var route = delBasePath(toRoute(pathname))
             this.pageLoader.prefetch(route).then(resolve, reject)
           })
         }
@@ -2371,6 +2382,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             cancelled = true
           })
 
+          route = delBasePath(route)
           var Component = await this.pageLoader.loadPage(route)
 
           if (cancelled) {
@@ -3047,6 +3059,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'query',
         'asPath',
         'components',
+        'basePath',
       ]
       var routerEvents = [
         'routeChangeStart',
Diff for de003c3a9d30..ba6a65095.js
@@ -1446,10 +1446,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_regex_1 = __webpack_require__('YTqd')
 
+      var basePath = ''
+
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1585,6 +1593,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport
                 ? pathname
                 : as
+            this.basePath = basePath
             this.sub = subscription
             this.clc = null
             this._wrapApp = wrapApp // make sure to ignore extra popState in safari on navigating
@@ -1715,7 +1724,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     var as =
                       typeof _as === 'object'
                         ? utils_1.formatWithValidation(_as)
-                        : _as // Add the ending slash to the paths. So, we can serve the
+                        : _as
+                    url = addBasePath(url)
+                    as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
                     // "<page>/index.html" directly for the SSR page.
 
                     if (false) {
@@ -1732,7 +1743,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                       _this2.asPath = as
                       Router.events.emit('hashChangeStart', as)
 
-                      _this2.changeState(method, url, addBasePath(as))
+                      _this2.changeState(method, url, as)
 
                       _this2.scrollToHash(as)
 
@@ -1808,12 +1819,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                         Router.events.emit('beforeHistoryChange', as)
 
-                        _this2.changeState(
-                          method,
-                          url,
-                          addBasePath(as),
-                          options
-                        )
+                        _this2.changeState(method, url, as, options)
 
                         var hash = window.location.hash.substring(1)
 
@@ -2092,9 +2098,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
                     if (false) {
-                    } // @ts-ignore pathname is always defined
+                    }
 
-                    var route = toRoute(pathname)
+                    var route = delBasePath(toRoute(pathname))
 
                     _this4.pageLoader.prefetch(route).then(resolve, reject)
                   })
@@ -2115,16 +2121,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               cancelled = true
                             }
 
-                            _context.next = 4
+                            route = delBasePath(route)
+                            _context.next = 5
                             return _regeneratorRuntime.awrap(
                               this.pageLoader.loadPage(route)
                             )
 
-                          case 4:
+                          case 5:
                             Component = _context.sent
 
                             if (!cancelled) {
-                              _context.next = 9
+                              _context.next = 10
                               break
                             }
 
@@ -2137,14 +2144,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             error.cancelled = true
                             throw error
 
-                          case 9:
+                          case 10:
                             if (cancel === this.clc) {
                               this.clc = null
                             }
 
                             return _context.abrupt('return', Component)
 
-                          case 11:
+                          case 12:
                           case 'end':
                             return _context.stop()
                         }
@@ -3655,6 +3662,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'query',
         'asPath',
         'components',
+        'basePath',
       ]
       var routerEvents = [
         'routeChangeStart',
Diff for index.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.88d489123446fd286290.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.1270c7fd57c3a16453f2.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.88d489123446fd286290.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.88d489123446fd286290.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -156,13 +156,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.1270c7fd57c3a16453f2.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.88d489123446fd286290.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.88d489123446fd286290.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.fb89e23b574ba6a65095.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.1270c7fd57c3a16453f2.js"
       defer=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.d9b3b214074605052c26.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.88d489123446fd286290.module.js"
       defer=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 14.5s 14.3s -265ms
nodeModulesSize 49 MB 49 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..9881.js gzip 13.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..3931.js gzip N/A 13.8 kB N/A
Overall change 67.5 kB 67.5 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.18 kB 4.18 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.5 kB N/A
Overall change 62.1 kB 62.1 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.33 kB 1.33 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.89 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 757 B 757 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.41 kB 7.44 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 77.8 kB 77.8 kB ⚠️ +77 B
hooks.html gzip 1.05 kB 1.05 kB ⚠️ +1 B
index.js gzip 78 kB 78 kB ⚠️ +73 B
link.js gzip 80.4 kB 80.5 kB ⚠️ +90 B
routerDirect.js gzip 78.1 kB 78.1 kB ⚠️ +77 B
withRouter.js gzip 78.1 kB 78.2 kB ⚠️ +77 B
Overall change 393 kB 394 kB ⚠️ +395 B

Commit: 3945df6

@ijjk
Copy link
Member Author

ijjk commented Jan 19, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 11.7s 12.6s ⚠️ +813ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..fffc.js gzip 13.7 kB 13.8 kB ⚠️ +59 B
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 67.5 kB 67.5 kB ⚠️ +59 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.5 kB ⚠️ +54 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.1 kB ⚠️ +54 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.34 kB 1.34 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.9 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 769 B 769 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.42 kB 7.45 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB ⚠️ +1 B
link.html gzip 1.03 kB 1.03 kB -1 B
withRouter.html gzip 1.02 kB 1.02 kB ⚠️ +1 B
Overall change 3.07 kB 3.07 kB ⚠️ +1 B

Diffs

Diff for link.js
@@ -449,6 +449,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -562,8 +564,10 @@
 
             _this.formatUrls = memoizedFormatUrl(function(href, asHref) {
               return {
-                href: formatUrl(href),
-                as: asHref ? formatUrl(asHref) : asHref,
+                href: (0, _router2.addBasePath)(formatUrl(href)),
+                as: asHref
+                  ? (0, _router2.addBasePath)(formatUrl(asHref))
+                  : asHref,
               }
             })
Diff for link.module.js
@@ -324,6 +324,8 @@
 
       var _utils = __webpack_require__('g/15')
 
+      var _router2 = __webpack_require__('elyg')
+
       function isLocal(href) {
         var url = (0, _url.parse)(href, false, true)
         var origin = (0, _url.parse)(
@@ -426,8 +428,10 @@
 
           this.formatUrls = memoizedFormatUrl((href, asHref) => {
             return {
-              href: formatUrl(href),
-              as: asHref ? formatUrl(asHref) : asHref,
+              href: (0, _router2.addBasePath)(formatUrl(href)),
+              as: asHref
+                ? (0, _router2.addBasePath)(formatUrl(asHref))
+                : asHref,
             }
           })
Diff for de003c3a9d30..91f4552b5.js
@@ -1446,10 +1446,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_regex_1 = __webpack_require__('YTqd')
 
+      var basePath = ''
+
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1587,6 +1595,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport
                 ? pathname
                 : as
+            this.basePath = basePath
             this.sub = subscription
             this.clc = null
             this._wrapApp = wrapApp // make sure to ignore extra popState in safari on navigating
@@ -1717,7 +1726,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     var as =
                       typeof _as === 'object'
                         ? utils_1.formatWithValidation(_as)
-                        : _as // Add the ending slash to the paths. So, we can serve the
+                        : _as
+                    url = addBasePath(url)
+                    as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
                     // "<page>/index.html" directly for the SSR page.
 
                     if (false) {
@@ -1734,7 +1745,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                       _this2.asPath = as
                       Router.events.emit('hashChangeStart', as)
 
-                      _this2.changeState(method, url, addBasePath(as), options)
+                      _this2.changeState(method, url, as, options)
 
                       _this2.scrollToHash(as)
 
@@ -1810,12 +1821,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                         Router.events.emit('beforeHistoryChange', as)
 
-                        _this2.changeState(
-                          method,
-                          url,
-                          addBasePath(as),
-                          options
-                        )
+                        _this2.changeState(method, url, as, options)
 
                         var hash = window.location.hash.substring(1)
 
@@ -2094,9 +2100,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
                     if (false) {
-                    } // @ts-ignore pathname is always defined
+                    }
 
-                    var route = toRoute(pathname)
+                    var route = delBasePath(toRoute(pathname))
 
                     _this4.pageLoader.prefetch(route).then(resolve, reject)
                   })
@@ -2117,16 +2123,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               cancelled = true
                             }
 
-                            _context.next = 4
+                            route = delBasePath(route)
+                            _context.next = 5
                             return _regeneratorRuntime.awrap(
                               this.pageLoader.loadPage(route)
                             )
 
-                          case 4:
+                          case 5:
                             Component = _context.sent
 
                             if (!cancelled) {
-                              _context.next = 9
+                              _context.next = 10
                               break
                             }
 
@@ -2139,14 +2146,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             error.cancelled = true
                             throw error
 
-                          case 9:
+                          case 10:
                             if (cancel === this.clc) {
                               this.clc = null
                             }
 
                             return _context.abrupt('return', Component)
 
-                          case 11:
+                          case 12:
                           case 'end':
                             return _context.stop()
                         }
@@ -3657,6 +3664,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'query',
         'asPath',
         'components',
+        'basePath',
       ]
       var routerEvents = [
         'routeChangeStart',
Diff for de003c3a9d30..48.module.js
@@ -1791,10 +1791,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var route_regex_1 = __webpack_require__('YTqd')
 
+      var basePath = ''
+
       function addBasePath(path) {
-        // @ts-ignore variable is always a string
-        var p = ''
-        return path.indexOf(p) !== 0 ? p + path : path
+        return path.indexOf(basePath) !== 0 ? basePath + path : path
+      }
+
+      exports.addBasePath = addBasePath
+
+      function delBasePath(path) {
+        return path.indexOf(basePath) === 0
+          ? path.substr(basePath.length) || '/'
+          : path
       }
 
       function toRoute(path) {
@@ -1921,6 +1929,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport
               ? pathname
               : as
+          this.basePath = basePath
           this.sub = subscription
           this.clc = null
           this._wrapApp = wrapApp // make sure to ignore extra popState in safari on navigating
@@ -2038,7 +2047,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 ? utils_1.formatWithValidation(_url)
                 : _url
             var as =
-              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as // Add the ending slash to the paths. So, we can serve the
+              typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as
+            url = addBasePath(url)
+            as = addBasePath(as) // Add the ending slash to the paths. So, we can serve the
             // "<page>/index.html" directly for the SSR page.
 
             if (false) {
@@ -2054,7 +2065,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             if (!options._h && this.onlyAHashChange(as)) {
               this.asPath = as
               Router.events.emit('hashChangeStart', as)
-              this.changeState(method, url, addBasePath(as), options)
+              this.changeState(method, url, as, options)
               this.scrollToHash(as)
               Router.events.emit('hashChangeComplete', as)
               return resolve(true)
@@ -2119,7 +2130,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 Router.events.emit('beforeHistoryChange', as)
-                this.changeState(method, url, addBasePath(as), options)
+                this.changeState(method, url, as, options)
                 var hash = window.location.hash.substring(1)
 
                 if (false) {
@@ -2359,9 +2370,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
             if (false) {
-            } // @ts-ignore pathname is always defined
+            }
 
-            var route = toRoute(pathname)
+            var route = delBasePath(toRoute(pathname))
             this.pageLoader.prefetch(route).then(resolve, reject)
           })
         }
@@ -2373,6 +2384,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             cancelled = true
           })
 
+          route = delBasePath(route)
           var Component = await this.pageLoader.loadPage(route)
 
           if (cancelled) {
@@ -3049,6 +3061,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
         'query',
         'asPath',
         'components',
+        'basePath',
       ]
       var routerEvents = [
         'routeChangeStart',
Diff for index.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.a0d7d22cc5017428eb48.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7495a985acf3b55b7ed2.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.329e15c764091f4552b5.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0873d4a3d784ca533fa9.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.a0d7d22cc5017428eb48.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7495a985acf3b55b7ed2.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.a0d7d22cc5017428eb48.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7495a985acf3b55b7ed2.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -156,13 +156,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.329e15c764091f4552b5.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0873d4a3d784ca533fa9.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.a0d7d22cc5017428eb48.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7495a985acf3b55b7ed2.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -39,7 +39,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.a0d7d22cc5017428eb48.module.js"
+      href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7495a985acf3b55b7ed2.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -151,13 +151,13 @@
       type="module"
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.329e15c764091f4552b5.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.0873d4a3d784ca533fa9.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script
     ><script
-      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.a0d7d22cc5017428eb48.module.js"
+      src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7495a985acf3b55b7ed2.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.7s 12.5s -201ms
nodeModulesSize 48.9 MB 48.9 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.11 kB 5.11 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..fffc.js gzip 13.7 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..a986.js gzip N/A 13.8 kB N/A
Overall change 67.5 kB 67.5 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.17 kB 4.17 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.5 kB N/A
Overall change 62.1 kB 62.1 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.34 kB 1.34 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.9 kB 2.92 kB ⚠️ +24 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.87 kB 9.9 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 769 B 769 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.47 kB 2.5 kB ⚠️ +25 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.42 kB 7.45 kB ⚠️ +25 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 70.9 kB 71 kB ⚠️ +38 B
hooks.html gzip 1.05 kB 1.06 kB ⚠️ +1 B
index.js gzip 71.3 kB 71.4 kB ⚠️ +22 B
link.js gzip 80.6 kB 80.6 kB ⚠️ +89 B
routerDirect.js gzip 78.2 kB 78.3 kB ⚠️ +71 B
withRouter.js gzip 78.3 kB 78.4 kB ⚠️ +73 B
Overall change 380 kB 381 kB ⚠️ +294 B

Commit: 73b60b6

@ijjk
Copy link
Member Author

ijjk commented Jan 30, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 11.5s 11.5s -24ms
nodeModulesSize 52.1 MB 52.1 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.1 kB 5.1 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..d6ae.js gzip 16.2 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..ccab.js gzip N/A 16.2 kB N/A
Overall change 69.9 kB 70 kB ⚠️ +57 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.11 kB 4.11 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 15.1 kB 15.1 kB ⚠️ +52 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 64.6 kB 64.6 kB ⚠️ +52 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.92 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +27 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +27 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB -2 B
link.html gzip 1.03 kB 1.03 kB -3 B
withRouter.html gzip 1.02 kB 1.02 kB -1 B
Overall change 3.07 kB 3.06 kB -6 B

Diffs

Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-73f62a219051af018171.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.316cffaf82e7d78bbb63.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-f6679e4beec177d869cb.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-73f62a219051af018171.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-73f62a219051af018171.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.4f9e270759b7b592194b.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-f6679e4beec177d869cb.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-73f62a219051af018171.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-73f62a219051af018171.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.316cffaf82e7d78bbb63.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-f6679e4beec177d869cb.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-73f62a219051af018171.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-73f62a219051af018171.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.4f9e270759b7b592194b.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-f6679e4beec177d869cb.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-73f62a219051af018171.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for de003c3a9d30..2a.module.js
@@ -2772,10 +2772,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -2906,6 +2912,7 @@ class Router {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -3007,7 +3014,9 @@ class Router {
 
 
       var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+      url = addBasePath(url);
+      as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
       // "<page>/index.html" directly for the SSR page.
 
       if (false) { var rewriteUrlForNextExport; }
@@ -3021,7 +3030,7 @@ class Router {
       if (!options._h && this.onlyAHashChange(as)) {
         this.asPath = as;
         Router.events.emit('hashChangeStart', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         this.scrollToHash(as);
         Router.events.emit('hashChangeComplete', as);
         return resolve(true);
@@ -3088,7 +3097,7 @@ class Router {
         }
 
         Router.events.emit('beforeHistoryChange', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         var hash = window.location.hash.substring(1);
 
         if (false) { var appComp; } // @ts-ignore pathname is always defined
@@ -3296,10 +3305,9 @@ class Router {
       } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
 
-      if (false) {} // @ts-ignore pathname is always defined
-
+      if (false) {}
 
-      var route = toRoute(pathname);
+      var route = delBasePath(toRoute(pathname));
       this.pageLoader.prefetch(route).then(resolve, reject);
     });
   }
@@ -3311,6 +3319,7 @@ class Router {
       cancelled = true;
     };
 
+    route = delBasePath(route);
     var Component = await this.pageLoader.loadPage(route);
 
     if (cancelled) {
@@ -3904,7 +3913,7 @@ var singletonRouter = {
 
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for de003c3a9d30..7d78bbb63.js
@@ -2490,10 +2490,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -2632,6 +2638,7 @@ function () {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -2736,7 +2743,9 @@ function () {
 
 
         var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+        url = addBasePath(url);
+        as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
         // "<page>/index.html" directly for the SSR page.
 
         if (false) { var rewriteUrlForNextExport; }
@@ -2752,7 +2761,7 @@ function () {
           _this2.asPath = as;
           Router.events.emit('hashChangeStart', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           _this2.scrollToHash(as);
 
@@ -2820,7 +2829,7 @@ function () {
 
           Router.events.emit('beforeHistoryChange', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           var hash = window.location.hash.substring(1);
 
@@ -3054,10 +3063,9 @@ function () {
         } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
 
-        if (false) {} // @ts-ignore pathname is always defined
-
+        if (false) {}
 
-        var route = toRoute(pathname);
+        var route = delBasePath(toRoute(pathname));
 
         _this4.pageLoader.prefetch(route).then(resolve, reject);
       });
@@ -3076,14 +3084,15 @@ function () {
                 cancelled = true;
               };
 
-              _context.next = 4;
+              route = delBasePath(route);
+              _context.next = 5;
               return _regeneratorRuntime.awrap(this.pageLoader.loadPage(route));
 
-            case 4:
+            case 5:
               Component = _context.sent;
 
               if (!cancelled) {
-                _context.next = 9;
+                _context.next = 10;
                 break;
               }
 
@@ -3091,14 +3100,14 @@ function () {
               error.cancelled = true;
               throw error;
 
-            case 9:
+            case 10:
               if (cancel === this.clc) {
                 this.clc = null;
               }
 
               return _context.abrupt("return", Component);
 
-            case 11:
+            case 12:
             case "end":
               return _context.stop();
           }
@@ -4495,7 +4504,7 @@ var singletonRouter = {
   }
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for link.module.js
@@ -293,6 +293,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -384,8 +386,8 @@ class Link extends _react.Component {
 
     this.formatUrls = memoizedFormatUrl((href, asHref) => {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for link.js
@@ -415,6 +415,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -514,8 +516,8 @@ function (_react$Component) {
 
     _this.formatUrls = memoizedFormatUrl(function (href, asHref) {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-73f62a219051af018171.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.316cffaf82e7d78bbb63.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-f6679e4beec177d869cb.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-73f62a219051af018171.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-73f62a219051af018171.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.4f9e270759b7b592194b.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-f6679e4beec177d869cb.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-73f62a219051af018171.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 11.9s 12.1s ⚠️ +156ms
nodeModulesSize 52.1 MB 52.1 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.1 kB 5.1 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..d6ae.js gzip 16.2 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..ccab.js gzip N/A 16.2 kB N/A
Overall change 69.9 kB 70 kB ⚠️ +57 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.11 kB 4.11 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 15.1 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 15.1 kB N/A
Overall change 64.6 kB 64.6 kB ⚠️ +52 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.92 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +27 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +27 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 46.6 kB 46.7 kB ⚠️ +25 B
404.html gzip 1.42 kB 1.42 kB
hooks.html gzip 1.05 kB 1.05 kB
index.js gzip 46.8 kB 46.8 kB ⚠️ +26 B
link.js gzip 72.4 kB 72.5 kB ⚠️ +101 B
routerDirect.js gzip 70.4 kB 70.5 kB ⚠️ +80 B
withRouter.js gzip 70.5 kB 70.5 kB ⚠️ +83 B
Overall change 309 kB 309 kB ⚠️ +315 B

Commit: 84832e1

@ijjk
Copy link
Member Author

ijjk commented Feb 3, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.2s 12.1s -91ms
nodeModulesSize 52.1 MB 52.1 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.12 kB 5.12 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..d6ae.js gzip 16.2 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..ccab.js gzip N/A 16.2 kB N/A
Overall change 69.9 kB 70 kB ⚠️ +57 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.12 kB 4.12 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 15.1 kB 15.1 kB ⚠️ +52 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 64.6 kB 64.7 kB ⚠️ +52 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.92 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +27 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +27 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.02 kB 1.02 kB -3 B
link.html gzip 1.03 kB 1.03 kB -4 B
withRouter.html gzip 1.02 kB 1.01 kB -3 B
Overall change 3.07 kB 3.06 kB -10 B

Diffs

Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.316cffaf82e7d78bbb63.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-60dcd53dc0075b7cdec6.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.4f9e270759b7b592194b.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-60dcd53dc0075b7cdec6.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.316cffaf82e7d78bbb63.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-60dcd53dc0075b7cdec6.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.4f9e270759b7b592194b.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-60dcd53dc0075b7cdec6.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for de003c3a9d30..2a.module.js
@@ -2772,10 +2772,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -2906,6 +2912,7 @@ class Router {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -3007,7 +3014,9 @@ class Router {
 
 
       var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+      url = addBasePath(url);
+      as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
       // "<page>/index.html" directly for the SSR page.
 
       if (false) { var rewriteUrlForNextExport; }
@@ -3021,7 +3030,7 @@ class Router {
       if (!options._h && this.onlyAHashChange(as)) {
         this.asPath = as;
         Router.events.emit('hashChangeStart', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         this.scrollToHash(as);
         Router.events.emit('hashChangeComplete', as);
         return resolve(true);
@@ -3088,7 +3097,7 @@ class Router {
         }
 
         Router.events.emit('beforeHistoryChange', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         var hash = window.location.hash.substring(1);
 
         if (false) { var appComp; } // @ts-ignore pathname is always defined
@@ -3296,10 +3305,9 @@ class Router {
       } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
 
-      if (false) {} // @ts-ignore pathname is always defined
-
+      if (false) {}
 
-      var route = toRoute(pathname);
+      var route = delBasePath(toRoute(pathname));
       this.pageLoader.prefetch(route).then(resolve, reject);
     });
   }
@@ -3311,6 +3319,7 @@ class Router {
       cancelled = true;
     };
 
+    route = delBasePath(route);
     var Component = await this.pageLoader.loadPage(route);
 
     if (cancelled) {
@@ -3904,7 +3913,7 @@ var singletonRouter = {
 
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for de003c3a9d30..7d78bbb63.js
@@ -2490,10 +2490,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -2632,6 +2638,7 @@ function () {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -2736,7 +2743,9 @@ function () {
 
 
         var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+        url = addBasePath(url);
+        as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
         // "<page>/index.html" directly for the SSR page.
 
         if (false) { var rewriteUrlForNextExport; }
@@ -2752,7 +2761,7 @@ function () {
           _this2.asPath = as;
           Router.events.emit('hashChangeStart', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           _this2.scrollToHash(as);
 
@@ -2820,7 +2829,7 @@ function () {
 
           Router.events.emit('beforeHistoryChange', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           var hash = window.location.hash.substring(1);
 
@@ -3054,10 +3063,9 @@ function () {
         } // Prefetch is not supported in development mode because it would trigger on-demand-entries
 
 
-        if (false) {} // @ts-ignore pathname is always defined
-
+        if (false) {}
 
-        var route = toRoute(pathname);
+        var route = delBasePath(toRoute(pathname));
 
         _this4.pageLoader.prefetch(route).then(resolve, reject);
       });
@@ -3076,14 +3084,15 @@ function () {
                 cancelled = true;
               };
 
-              _context.next = 4;
+              route = delBasePath(route);
+              _context.next = 5;
               return _regeneratorRuntime.awrap(this.pageLoader.loadPage(route));
 
-            case 4:
+            case 5:
               Component = _context.sent;
 
               if (!cancelled) {
-                _context.next = 9;
+                _context.next = 10;
                 break;
               }
 
@@ -3091,14 +3100,14 @@ function () {
               error.cancelled = true;
               throw error;
 
-            case 9:
+            case 10:
               if (cancel === this.clc) {
                 this.clc = null;
               }
 
               return _context.abrupt("return", Component);
 
-            case 11:
+            case 12:
             case "end":
               return _context.stop();
           }
@@ -4495,7 +4504,7 @@ var singletonRouter = {
   }
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for link.module.js
@@ -293,6 +293,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -384,8 +386,8 @@ class Link extends _react.Component {
 
     this.formatUrls = memoizedFormatUrl((href, asHref) => {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for link.js
@@ -415,6 +415,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -514,8 +516,8 @@ function (_react$Component) {
 
     _this.formatUrls = memoizedFormatUrl(function (href, asHref) {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.316cffaf82e7d78bbb63.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3e64dc8e6d2834d1522a.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-60dcd53dc0075b7cdec6.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID"}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.4f9e270759b7b592194b.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.31982ea0b33cbd260124.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-60dcd53dc0075b7cdec6.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-26647acdcc5840f8b905.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.3s 12.8s ⚠️ +469ms
nodeModulesSize 52.1 MB 52.1 MB ⚠️ +1.44 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.12 kB 5.12 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..d6ae.js gzip 16.2 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..ccab.js gzip N/A 16.2 kB N/A
Overall change 69.9 kB 70 kB ⚠️ +57 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.12 kB 4.12 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 15.1 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 15.1 kB N/A
Overall change 64.6 kB 64.7 kB ⚠️ +52 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.92 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +27 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +27 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 46.5 kB 46.5 kB ⚠️ +27 B
404.html gzip 1.43 kB 1.43 kB -3 B
hooks.html gzip 1.06 kB 1.06 kB -2 B
index.js gzip 46.5 kB 46.6 kB ⚠️ +26 B
link.js gzip 72 kB 72.1 kB ⚠️ +108 B
routerDirect.js gzip 70.3 kB 70.3 kB ⚠️ +75 B
withRouter.js gzip 70.1 kB 70.1 kB ⚠️ +78 B
Overall change 308 kB 308 kB ⚠️ +309 B

Commit: efa2899

@ijjk
Copy link
Member Author

ijjk commented Feb 8, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.1s 12.3s ⚠️ +176ms
nodeModulesSize 52.6 MB 52.6 MB ⚠️ +1.56 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.13 kB 5.13 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..e781.js gzip 13.8 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..acd9.js gzip N/A 13.8 kB N/A
Overall change 67.5 kB 67.6 kB ⚠️ +69 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.13 kB 4.13 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.6 kB ⚠️ +59 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.2 kB ⚠️ +59 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.91 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +26 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +26 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.03 kB 1.03 kB -2 B
link.html gzip 1.04 kB 1.04 kB -2 B
withRouter.html gzip 1.03 kB 1.03 kB -3 B
Overall change 3.11 kB 3.1 kB -7 B

Diffs

Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.94ffdad0a29f46cabb19.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-43879385b82faf66a921.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.996fc117a1811dddf158.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-43879385b82faf66a921.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.94ffdad0a29f46cabb19.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-43879385b82faf66a921.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.996fc117a1811dddf158.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-43879385b82faf66a921.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for de003c3a9d30..c7.module.js
@@ -1461,10 +1461,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -1592,6 +1598,7 @@ class Router {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -1693,7 +1700,9 @@ class Router {
 
 
       var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+      url = addBasePath(url);
+      as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
       // "<page>/index.html" directly for the SSR page.
 
       if (false) { var rewriteUrlForNextExport; }
@@ -1707,7 +1716,7 @@ class Router {
       if (!options._h && this.onlyAHashChange(as)) {
         this.asPath = as;
         Router.events.emit('hashChangeStart', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         this.scrollToHash(as);
         Router.events.emit('hashChangeComplete', as);
         return resolve(true);
@@ -2031,7 +2040,7 @@ class Router {
 
       if (false) {}
 
-      var route = toRoute(pathname);
+      var route = delBasePath(toRoute(pathname));
       this.pageLoader.prefetch(route).then(resolve, reject);
     });
   }
@@ -2043,6 +2052,7 @@ class Router {
       cancelled = true;
     };
 
+    route = delBasePath(route);
     var Component = await this.pageLoader.loadPage(route);
 
     if (cancelled) {
@@ -2636,7 +2646,7 @@ var singletonRouter = {
 
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for de003c3a9d30..f46cabb19.js
@@ -1179,10 +1179,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -1318,6 +1324,7 @@ function () {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -1422,7 +1429,9 @@ function () {
 
 
         var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+        url = addBasePath(url);
+        as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
         // "<page>/index.html" directly for the SSR page.
 
         if (false) { var rewriteUrlForNextExport; }
@@ -1438,7 +1447,7 @@ function () {
           _this2.asPath = as;
           Router.events.emit('hashChangeStart', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           _this2.scrollToHash(as);
 
@@ -1800,7 +1809,7 @@ function () {
 
         if (false) {}
 
-        var route = toRoute(pathname);
+        var route = delBasePath(toRoute(pathname));
 
         _this4.pageLoader.prefetch(route).then(resolve, reject);
       });
@@ -1819,14 +1828,15 @@ function () {
                 cancelled = true;
               };
 
-              _context.next = 4;
+              route = delBasePath(route);
+              _context.next = 5;
               return _regeneratorRuntime.awrap(this.pageLoader.loadPage(route));
 
-            case 4:
+            case 5:
               Component = _context.sent;
 
               if (!cancelled) {
-                _context.next = 9;
+                _context.next = 10;
                 break;
               }
 
@@ -1834,14 +1844,14 @@ function () {
               error.cancelled = true;
               throw error;
 
-            case 9:
+            case 10:
               if (cancel === this.clc) {
                 this.clc = null;
               }
 
               return _context.abrupt("return", Component);
 
-            case 11:
+            case 12:
             case "end":
               return _context.stop();
           }
@@ -3238,7 +3248,7 @@ var singletonRouter = {
   }
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for link.module.js
@@ -293,6 +293,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -384,8 +386,8 @@ class Link extends _react.Component {
 
     this.formatUrls = memoizedFormatUrl((href, asHref) => {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for link.js
@@ -415,6 +415,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -514,8 +516,8 @@ function (_react$Component) {
 
     _this.formatUrls = memoizedFormatUrl(function (href, asHref) {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.94ffdad0a29f46cabb19.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-43879385b82faf66a921.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.996fc117a1811dddf158.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-43879385b82faf66a921.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-8ac2c8ebe7578b9fa7fb.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 12.6s 12.5s -134ms
nodeModulesSize 52.6 MB 52.6 MB ⚠️ +1.56 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.13 kB 5.13 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..e781.js gzip 13.8 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..acd9.js gzip N/A 13.8 kB N/A
Overall change 67.5 kB 67.6 kB ⚠️ +69 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.13 kB 4.13 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.6 kB N/A
Overall change 62.1 kB 62.2 kB ⚠️ +59 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.91 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +26 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +26 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 46.6 kB 46.6 kB ⚠️ +27 B
404.html gzip 1.45 kB 1.44 kB -2 B
hooks.html gzip 1.08 kB 1.08 kB
index.js gzip 46.7 kB 46.7 kB ⚠️ +23 B
link.js gzip 72.6 kB 72.7 kB ⚠️ +110 B
routerDirect.js gzip 70.8 kB 70.9 kB ⚠️ +83 B
withRouter.js gzip 70.6 kB 70.7 kB ⚠️ +93 B
Overall change 310 kB 310 kB ⚠️ +334 B

Commit: 4cc5241

@ijjk
Copy link
Member Author

ijjk commented Feb 12, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 15s 15s ⚠️ +44ms
nodeModulesSize 52.9 MB 52.9 MB ⚠️ +1.56 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.13 kB 5.13 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..e781.js gzip 13.8 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..acd9.js gzip N/A 13.8 kB N/A
Overall change 67.5 kB 67.6 kB ⚠️ +69 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.13 kB 4.13 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB 12.6 kB ⚠️ +59 B
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 62.1 kB 62.2 kB ⚠️ +59 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.91 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +26 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +26 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 1.03 kB 1.03 kB -3 B
link.html gzip 1.04 kB 1.04 kB -1 B
withRouter.html gzip 1.03 kB 1.03 kB -2 B
Overall change 3.11 kB 3.1 kB -6 B

Diffs

Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.94ffdad0a29f46cabb19.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-71617365d17c7ecb6735.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.996fc117a1811dddf158.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-71617365d17c7ecb6735.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.94ffdad0a29f46cabb19.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-71617365d17c7ecb6735.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.996fc117a1811dddf158.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-71617365d17c7ecb6735.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for de003c3a9d30..c7.module.js
@@ -1461,10 +1461,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -1592,6 +1598,7 @@ class Router {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -1693,7 +1700,9 @@ class Router {
 
 
       var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+      url = addBasePath(url);
+      as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
       // "<page>/index.html" directly for the SSR page.
 
       if (false) { var rewriteUrlForNextExport; }
@@ -1707,7 +1716,7 @@ class Router {
       if (!options._h && this.onlyAHashChange(as)) {
         this.asPath = as;
         Router.events.emit('hashChangeStart', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         this.scrollToHash(as);
         Router.events.emit('hashChangeComplete', as);
         return resolve(true);
@@ -2031,7 +2040,7 @@ class Router {
 
       if (false) {}
 
-      var route = toRoute(pathname);
+      var route = delBasePath(toRoute(pathname));
       this.pageLoader.prefetch(route).then(resolve, reject);
     });
   }
@@ -2043,6 +2052,7 @@ class Router {
       cancelled = true;
     };
 
+    route = delBasePath(route);
     var Component = await this.pageLoader.loadPage(route);
 
     if (cancelled) {
@@ -2636,7 +2646,7 @@ var singletonRouter = {
 
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for de003c3a9d30..f46cabb19.js
@@ -1179,10 +1179,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // @ts-ignore variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -1318,6 +1324,7 @@ function () {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -1422,7 +1429,9 @@ function () {
 
 
         var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+        url = addBasePath(url);
+        as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
         // "<page>/index.html" directly for the SSR page.
 
         if (false) { var rewriteUrlForNextExport; }
@@ -1438,7 +1447,7 @@ function () {
           _this2.asPath = as;
           Router.events.emit('hashChangeStart', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           _this2.scrollToHash(as);
 
@@ -1800,7 +1809,7 @@ function () {
 
         if (false) {}
 
-        var route = toRoute(pathname);
+        var route = delBasePath(toRoute(pathname));
 
         _this4.pageLoader.prefetch(route).then(resolve, reject);
       });
@@ -1819,14 +1828,15 @@ function () {
                 cancelled = true;
               };
 
-              _context.next = 4;
+              route = delBasePath(route);
+              _context.next = 5;
               return _regeneratorRuntime.awrap(this.pageLoader.loadPage(route));
 
-            case 4:
+            case 5:
               Component = _context.sent;
 
               if (!cancelled) {
-                _context.next = 9;
+                _context.next = 10;
                 break;
               }
 
@@ -1834,14 +1844,14 @@ function () {
               error.cancelled = true;
               throw error;
 
-            case 9:
+            case 10:
               if (cancel === this.clc) {
                 this.clc = null;
               }
 
               return _context.abrupt("return", Component);
 
-            case 11:
+            case 12:
             case "end":
               return _context.stop();
           }
@@ -3238,7 +3248,7 @@ var singletonRouter = {
   }
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for link.module.js
@@ -293,6 +293,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -384,8 +386,8 @@ class Link extends _react.Component {
 
     this.formatUrls = memoizedFormatUrl((href, asHref) => {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for link.js
@@ -415,6 +415,8 @@ var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
 var _utils = __webpack_require__("g/15");
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -514,8 +516,8 @@ function (_react$Component) {
 
     _this.formatUrls = memoizedFormatUrl(function (href, asHref) {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.94ffdad0a29f46cabb19.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.978383ccfbd093c75ec7.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-71617365d17c7ecb6735.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-355bc4b3077ea9d3fc7a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.c07ba8a3b0945b0f6315.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/commons.5d483f979b96e9afed5a.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.9a0caf742c992a927903.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/4952ddcd88e7185e66c9cf40e2d848b7e27f1574.6406830adfd759a39616.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.996fc117a1811dddf158.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6de8bc63e74606ddeea3.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-71617365d17c7ecb6735.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-1eb042c3b4a90e3acca8.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 16.2s 16.1s -79ms
nodeModulesSize 52.9 MB 52.9 MB ⚠️ +1.56 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 5.13 kB 5.13 kB
webpack-HASH.js gzip 746 B 746 B
4952ddcd88e7..54d3.js gzip 4.68 kB 4.68 kB
commons.HASH.js gzip 4.06 kB 4.06 kB
de003c3a9d30..e781.js gzip 13.8 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..acd9.js gzip N/A 13.8 kB N/A
Overall change 67.5 kB 67.6 kB ⚠️ +69 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.13 kB 4.13 kB
webpack-HASH..dule.js gzip 746 B 746 B
4952ddcd88e7..dule.js gzip 5.56 kB 5.56 kB
de003c3a9d30..dule.js gzip 12.5 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 12.6 kB N/A
Overall change 62.1 kB 62.2 kB ⚠️ +59 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 4.76 kB 4.76 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.15 kB 1.15 kB
_error.js gzip 4.07 kB 4.07 kB
hooks.js gzip 779 B 779 B
index.js gzip 222 B 222 B
link.js gzip 2.89 kB 2.91 kB ⚠️ +22 B
routerDirect.js gzip 283 B 283 B
withRouter.js gzip 282 B 282 B
Overall change 9.68 kB 9.7 kB ⚠️ +22 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 576 B 576 B
_error.module.js gzip 3.06 kB 3.06 kB
hooks.module.js gzip 371 B 371 B
index.module.js gzip 212 B 212 B
link.module.js gzip 2.46 kB 2.49 kB ⚠️ +26 B
routerDirect..dule.js gzip 273 B 273 B
withRouter.m..dule.js gzip 272 B 272 B
Overall change 7.22 kB 7.25 kB ⚠️ +26 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 289 kB 289 kB -143 B
404.html gzip 1.45 kB 1.45 kB -1 B
hooks.html gzip 1.08 kB 1.08 kB -1 B
index.js gzip 289 kB 289 kB ⚠️ +156 B
link.js gzip 320 kB 320 kB -4 B
routerDirect.js gzip 316 kB 316 kB ⚠️ +600 B
withRouter.js gzip 317 kB 316 kB -637 B
Overall change 1.53 MB 1.53 MB -30 B

Commit: 3fb6b0f

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk
Copy link
Member Author

ijjk commented Apr 13, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 10.3s 10.2s -173ms
nodeModulesSize 61 MB 61 MB ⚠️ +1.96 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..a4ac.js gzip 10.2 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..f272.js gzip N/A 10.3 kB N/A
Overall change 56.3 kB 56.4 kB ⚠️ +66 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 6.84 kB N/A
Overall change 51.5 kB 51.5 kB ⚠️ +60 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.06 kB ⚠️ +24 B
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.88 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.51 kB ⚠️ +23 B
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.3 kB ⚠️ +23 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
index.html gzip 925 B 928 B ⚠️ +3 B
link.html gzip 934 B 936 B ⚠️ +2 B
withRouter.html gzip 920 B 923 B ⚠️ +3 B
Overall change 2.78 kB 2.79 kB ⚠️ +8 B

Diffs

Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7af4401b5f5c700c1b0c.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false,"gip":true}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-51838dc5b2b8e0705281.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3fe4a01f56146429e3ef.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7af4401b5f5c700c1b0c.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-2b907e3a24cc9b21066c.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_ssgManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_ssgManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.19d754828701b71231d2.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false,"gip":true}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-51838dc5b2b8e0705281.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.110a005245c95e156aab.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.19d754828701b71231d2.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-2b907e3a24cc9b21066c.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_ssgManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_ssgManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7af4401b5f5c700c1b0c.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false,"gip":true}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-51838dc5b2b8e0705281.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3fe4a01f56146429e3ef.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7af4401b5f5c700c1b0c.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-2b907e3a24cc9b21066c.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_ssgManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_ssgManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.19d754828701b71231d2.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false,"gip":true}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-51838dc5b2b8e0705281.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.110a005245c95e156aab.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.19d754828701b71231d2.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-2b907e3a24cc9b21066c.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_ssgManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_ssgManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for de003c3a9d30..0c.module.js
@@ -378,10 +378,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -543,6 +549,7 @@ class Router {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -646,7 +653,9 @@ class Router {
 
 
       var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+      var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+      url = addBasePath(url);
+      as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
       // "<page>/index.html" directly for the SSR page.
 
       if (false) { var rewriteUrlForNextExport; }
@@ -660,7 +669,7 @@ class Router {
       if (!options._h && this.onlyAHashChange(as)) {
         this.asPath = as;
         Router.events.emit('hashChangeStart', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
         this.scrollToHash(as);
         Router.events.emit('hashChangeComplete', as);
         return resolve(true);
@@ -725,7 +734,7 @@ class Router {
         }
 
         Router.events.emit('beforeHistoryChange', as);
-        this.changeState(method, url, addBasePath(as), options);
+        this.changeState(method, url, as, options);
 
         if (false) { var appComp; }
 
@@ -946,7 +955,8 @@ class Router {
 
       if (false) {}
 
-      Promise.all([this.pageLoader.prefetchData(url, asPath), this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](toRoute(pathname))]).then(() => resolve(), reject);
+      var route = delBasePath(toRoute(pathname));
+      Promise.all([this.pageLoader.prefetchData(url, delBasePath(asPath)), this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]).then(() => resolve(), reject);
     });
   }
 
@@ -957,6 +967,7 @@ class Router {
       cancelled = true;
     };
 
+    route = delBasePath(route);
     var componentResult = await this.pageLoader.loadPage(route);
 
     if (cancelled) {
@@ -1332,7 +1343,7 @@ var singletonRouter = {
 
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'isFallback'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'isFallback', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for de003c3a9d30..46429e3ef.js
@@ -439,10 +439,16 @@ var route_matcher_1 = __webpack_require__("gguc");
 
 var route_regex_1 = __webpack_require__("YTqd");
 
+var basePath = "";
+
 function addBasePath(path) {
-  // variable is always a string
-  var p = "";
-  return path.indexOf(p) !== 0 ? p + path : path;
+  return path.indexOf(basePath) !== 0 ? basePath + path : path;
+}
+
+exports.addBasePath = addBasePath;
+
+function delBasePath(path) {
+  return path.indexOf(basePath) === 0 ? path.substr(basePath.length) || '/' : path;
 }
 
 function toRoute(path) {
@@ -610,6 +616,7 @@ var Router = /*#__PURE__*/function () {
 
     this.asPath = // @ts-ignore this is temporarily global (attached to window)
     is_dynamic_1.isDynamicRoute(pathname) && __NEXT_DATA__.autoExport ? pathname : as;
+    this.basePath = basePath;
     this.sub = subscription;
     this.clc = null;
     this._wrapApp = wrapApp; // make sure to ignore extra popState in safari on navigating
@@ -716,7 +723,9 @@ var Router = /*#__PURE__*/function () {
 
 
         var url = typeof _url === 'object' ? utils_1.formatWithValidation(_url) : _url;
-        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as; // Add the ending slash to the paths. So, we can serve the
+        var as = typeof _as === 'object' ? utils_1.formatWithValidation(_as) : _as;
+        url = addBasePath(url);
+        as = addBasePath(as); // Add the ending slash to the paths. So, we can serve the
         // "<page>/index.html" directly for the SSR page.
 
         if (false) { var rewriteUrlForNextExport; }
@@ -732,7 +741,7 @@ var Router = /*#__PURE__*/function () {
           _this2.asPath = as;
           Router.events.emit('hashChangeStart', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           _this2.scrollToHash(as);
 
@@ -798,7 +807,7 @@ var Router = /*#__PURE__*/function () {
 
           Router.events.emit('beforeHistoryChange', as);
 
-          _this2.changeState(method, url, addBasePath(as), options);
+          _this2.changeState(method, url, as, options);
 
           if (false) { var appComp; }
 
@@ -1044,7 +1053,8 @@ var Router = /*#__PURE__*/function () {
 
         if (false) {}
 
-        Promise.all([_this4.pageLoader.prefetchData(url, asPath), _this4.pageLoader[options.priority ? 'loadPage' : 'prefetch'](toRoute(pathname))]).then(function () {
+        var route = delBasePath(toRoute(pathname));
+        Promise.all([_this4.pageLoader.prefetchData(url, delBasePath(asPath)), _this4.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route)]).then(function () {
           return resolve();
         }, reject);
       });
@@ -1063,14 +1073,15 @@ var Router = /*#__PURE__*/function () {
                 cancelled = true;
               };
 
-              _context.next = 4;
+              route = delBasePath(route);
+              _context.next = 5;
               return _regeneratorRuntime.awrap(this.pageLoader.loadPage(route));
 
-            case 4:
+            case 5:
               componentResult = _context.sent;
 
               if (!cancelled) {
-                _context.next = 9;
+                _context.next = 10;
                 break;
               }
 
@@ -1078,14 +1089,14 @@ var Router = /*#__PURE__*/function () {
               error.cancelled = true;
               throw error;
 
-            case 9:
+            case 10:
               if (cancel === this.clc) {
                 this.clc = null;
               }
 
               return _context.abrupt("return", componentResult);
 
-            case 11:
+            case 12:
             case "end":
               return _context.stop();
           }
@@ -2303,7 +2314,7 @@ var singletonRouter = {
   }
 }; // Create public properties and methods of the router in the singletonRouter
 
-var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'isFallback'];
+var urlPropertyFields = ['pathname', 'route', 'query', 'asPath', 'components', 'isFallback', 'basePath'];
 var routerEvents = ['routeChangeStart', 'beforeHistoryChange', 'routeChangeComplete', 'routeChangeError', 'hashChangeStart', 'hashChangeComplete'];
 var coreMethodFields = ['push', 'replace', 'reload', 'back', 'prefetch', 'beforePopState']; // Events is a static property on the router, the router doesn't have to be initialized to use it
Diff for link.module.js
@@ -67,6 +67,8 @@ var _utils = __webpack_require__("g/15");
 
 var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -158,8 +160,8 @@ class Link extends _react.Component {
 
     this.formatUrls = memoizedFormatUrl((href, asHref) => {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for link.js
@@ -155,6 +155,8 @@ var _utils = __webpack_require__("g/15");
 
 var _router = _interopRequireDefault(__webpack_require__("nOHt"));
 
+var _router2 = __webpack_require__("elyg");
+
 function isLocal(href) {
   var url = (0, _url.parse)(href, false, true);
   var origin = (0, _url.parse)((0, _utils.getLocationOrigin)(), false, true);
@@ -254,8 +256,8 @@ var Link = /*#__PURE__*/function (_react$Component) {
 
     _this.formatUrls = memoizedFormatUrl(function (href, asHref) {
       return {
-        href: formatUrl(href),
-        as: asHref ? formatUrl(asHref) : asHref
+        href: (0, _router2.addBasePath)(formatUrl(href)),
+        as: asHref ? (0, _router2.addBasePath)(formatUrl(asHref)) : asHref
       };
     });
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7af4401b5f5c700c1b0c.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false,"gip":true}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-51838dc5b2b8e0705281.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3fe4a01f56146429e3ef.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.7af4401b5f5c700c1b0c.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-2b907e3a24cc9b21066c.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_ssgManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_ssgManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.19d754828701b71231d2.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false,"gip":true}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-51838dc5b2b8e0705281.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.110a005245c95e156aab.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.19d754828701b71231d2.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-2b907e3a24cc9b21066c.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-a3986a8c3257a924ad2b.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_ssgManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_ssgManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
buildDuration 11.2s 11.5s ⚠️ +260ms
nodeModulesSize 61 MB 61 MB ⚠️ +1.96 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..a4ac.js gzip 10.2 kB N/A N/A
framework.HASH.js gzip 39.1 kB 39.1 kB
de003c3a9d30..f272.js gzip N/A 10.3 kB N/A
Overall change 56.3 kB 56.4 kB ⚠️ +66 B
Client Bundles (main, webpack, commons) Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB N/A N/A
framework.HA..dule.js gzip 39.1 kB 39.1 kB
de003c3a9d30..dule.js gzip N/A 6.84 kB N/A
Overall change 51.5 kB 51.5 kB ⚠️ +60 B
Legacy Client Bundles (polyfills)
zeit/next.js canary ijjk/next.js update/adding-basePath Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.06 kB ⚠️ +24 B
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.88 kB ⚠️ +24 B
Client Pages Modern Overall increase ⚠️
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.51 kB ⚠️ +23 B
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.3 kB ⚠️ +23 B
Client Build Manifests
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall decrease ✓
zeit/next.js canary ijjk/next.js update/adding-basePath Change
_error.js gzip 233 kB 233 kB -274 B
404.html gzip 1.32 kB 1.33 kB ⚠️ +3 B
hooks.html gzip 956 B 958 B ⚠️ +2 B
index.js gzip 233 kB 233 kB ⚠️ +200 B
link.js gzip 243 kB 243 kB ⚠️ +132 B
routerDirect.js gzip 241 kB 241 kB ⚠️ +43 B
withRouter.js gzip 241 kB 241 kB -238 B
Overall change 1.19 MB 1.19 MB -132 B

@timneutkens timneutkens merged commit d3e308a into vercel:canary Apr 14, 2020
@timneutkens timneutkens deleted the update/adding-basePath branch April 14, 2020 07:50
kodiakhq bot pushed a commit to vercel/vercel that referenced this pull request Jun 15, 2020
As mentioned by @dav-is we can prefix the outputs with the `basePath` instead of using a rewrite so that we make sure to 404 when the basePath isn't prefixed on the output. This behavior is also matched in Next.js with [this PR](vercel/next.js#9988). 

x-ref: #3478
ofhouse pushed a commit to milliHQ/terraform-aws-next-js that referenced this pull request Mar 13, 2021
As mentioned by @dav-is we can prefix the outputs with the `basePath` instead of using a rewrite so that we make sure to 404 when the basePath isn't prefixed on the output. This behavior is also matched in Next.js with [this PR](vercel/next.js#9988). 

x-ref: vercel/vercel#3478
@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants