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

Added flag to identify shallow router events #19802

Merged
merged 4 commits into from
Dec 17, 2020
Merged

Added flag to identify shallow router events #19802

merged 4 commits into from
Dec 17, 2020

Conversation

bragle
Copy link
Contributor

@bragle bragle commented Dec 3, 2020

This PR is an implementation of RFC #13276 (more specifically @banerjeesouvik's suggestion) which solves #3322 by adding an extra parameter to the router events that'll allow you to see whether or not the route is shallow.

This is a recreation of PR #13243.

@ijjk
Copy link
Member

ijjk commented Dec 3, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 9.7s 9.9s ⚠️ +197ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +653 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary bragle/next.js canary Change
/ failed reqs 0 0
/ total time (seconds) 2.076 2.01 -0.07
/ avg req/sec 1204.14 1244.01 +39.87
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.228 1.34 ⚠️ +0.11
/error-in-render avg req/sec 2036.39 1865.24 ⚠️ -171.15
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..8b6e.js gzip 12.8 kB 12.8 kB ⚠️ +21 B
framework.HASH.js gzip 39 kB 39 kB
main-3c9ff84..1d7c.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59.1 kB ⚠️ +21 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-fca3d..2eb1.js gzip 3.44 kB 3.44 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
index.html gzip 614 B 614 B
link.html gzip 620 B 620 B
withRouter.html gzip 608 B 607 B -1 B
Overall change 1.84 kB 1.84 kB -1 B

Diffs

Diff for 677f882d2ed8..4eae9202a.js
@@ -1739,6 +1739,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     normalizeLocalePath,
                     parsedAs,
                     localePathResult,
+                    _options$shallow,
+                    shallow,
                     cleanedAs,
                     parsed,
                     _parsed,
@@ -1748,8 +1750,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     rewrites,
                     _yield,
                     route,
-                    _options$shallow,
-                    shallow,
                     resolvedAs,
                     potentialHref,
                     _parsedAs,
@@ -1846,8 +1846,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               performance.mark("routeChange");
                             }
 
+                            (_options$shallow = options.shallow),
+                              (shallow =
+                                _options$shallow === void 0
+                                  ? false
+                                  : _options$shallow);
+
                             if (this._inFlightRoute) {
-                              this.abortComponentLoad(this._inFlightRoute);
+                              this.abortComponentLoad(
+                                this._inFlightRoute,
+                                shallow
+                              );
                             }
 
                             as = addBasePath(
@@ -1870,20 +1879,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (
                               !(!options._h && this.onlyAHashChange(cleanedAs))
                             ) {
-                              _context.next = 29;
+                              _context.next = 30;
                               break;
                             }
 
                             this.asPath = cleanedAs;
-                            Router.events.emit("hashChangeStart", as); // TODO: do we need the resolved href when only a hash change?
+                            Router.events.emit("hashChangeStart", as, {
+                              shallow: shallow
+                            }); // TODO: do we need the resolved href when only a hash change?
 
                             this.changeState(method, url, as, options);
                             this.scrollToHash(cleanedAs);
                             this.notify(this.components[this.route]);
-                            Router.events.emit("hashChangeComplete", as);
+                            Router.events.emit("hashChangeComplete", as, {
+                              shallow: shallow
+                            });
                             return _context.abrupt("return", true);
 
-                          case 29:
+                          case 30:
                             parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
                               url
                             );
@@ -1893,30 +1906,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             // get their query parameters to allow ensuring they can be parsed properly
                             // when rewritten to
 
-                            _context.prev = 31;
-                            _context.next = 34;
+                            _context.prev = 32;
+                            _context.next = 35;
                             return this.pageLoader.getPageList();
 
-                          case 34:
+                          case 35:
                             pages = _context.sent;
-                            _context.next = 37;
+                            _context.next = 38;
                             return (0, _routeLoader.getClientBuildManifest)();
 
-                          case 37:
+                          case 38:
                             _yield = _context.sent;
                             rewrites = _yield.__rewrites;
-                            _context.next = 45;
+                            _context.next = 46;
                             break;
 
-                          case 41:
-                            _context.prev = 41;
-                            _context.t0 = _context["catch"](31);
+                          case 42:
+                            _context.prev = 42;
+                            _context.t0 = _context["catch"](32);
                             // If we fail to resolve the page list or client-build manifest, we must
                             // do a server-side transition:
                             window.location.href = as;
                             return _context.abrupt("return", false);
 
-                          case 45:
+                          case 46:
                             parsed = this._resolveHref(parsed, pages);
 
                             if (parsed.pathname !== pathname) {
@@ -1944,12 +1957,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             route = (0,
                             _normalizeTrailingSlash.removePathTrailingSlash)(
                               pathname
-                            );
-                            (_options$shallow = options.shallow),
-                              (shallow =
-                                _options$shallow === void 0
-                                  ? false
-                                  : _options$shallow); // we need to resolve the as value using rewrites for dynamic SSG
+                            ); // we need to resolve the as value using rewrites for dynamic SSG
                             // pages to allow building the data URL correctly
 
                             resolvedAs = as;
@@ -2049,7 +2057,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             }
 
                           case 69:
-                            Router.events.emit("routeChangeStart", as);
+                            Router.events.emit("routeChangeStart", as, {
+                              shallow: shallow
+                            });
                             _context.prev = 70;
                             _context.next = 73;
                             return this.getRouteInfo(
@@ -2118,7 +2128,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             );
 
                           case 85:
-                            Router.events.emit("beforeHistoryChange", as);
+                            Router.events.emit("beforeHistoryChange", as, {
+                              shallow: shallow
+                            });
                             this.changeState(method, url, as, options);
 
                             if (false) {
@@ -2145,7 +2157,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             Router.events.emit(
                               "routeChangeError",
                               error,
-                              cleanedAs
+                              cleanedAs,
+                              {
+                                shallow: shallow
+                              }
                             );
                             throw error;
 
@@ -2156,7 +2171,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (false) {
                             }
 
-                            Router.events.emit("routeChangeComplete", as);
+                            Router.events.emit("routeChangeComplete", as, {
+                              shallow: shallow
+                            });
                             return _context.abrupt("return", true);
 
                           case 99:
@@ -2182,7 +2199,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _callee,
                     this,
                     [
-                      [31, 41],
+                      [32, 42],
                       [70, 99]
                     ]
                   );
@@ -2233,6 +2250,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   pathname,
                   query,
                   as,
+                  shallow,
                   loadErrorFail
                 ) {
                   var Component,
@@ -2267,7 +2285,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               break;
                             }
 
-                            Router.events.emit("routeChangeError", err, as); // If we can't load the page it could be one of following reasons
+                            Router.events.emit("routeChangeError", err, as, {
+                              shallow: shallow
+                            }); // If we can't load the page it could be one of following reasons
                             //  1. Page doesn't exists
                             //  2. Page does exist in a different zone
                             //  3. Internal error while loading the page
@@ -2391,6 +2411,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 pathname,
                                 query,
                                 as,
+                                shallow,
                                 true
                               )
                             );
@@ -2412,7 +2433,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9) {
+              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {
                 return _handleRouteInfoError.apply(this, arguments);
               }
 
@@ -2583,7 +2604,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 _context3.t1,
                                 pathname,
                                 query,
-                                as
+                                as,
+                                shallow
                               )
                             );
 
@@ -2600,7 +2622,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function getRouteInfo(_x10, _x11, _x12, _x13) {
+              function getRouteInfo(_x11, _x12, _x13, _x14) {
                 return _getRouteInfo.apply(this, arguments);
               }
 
@@ -2834,7 +2856,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function prefetch(_x14) {
+              function prefetch(_x15) {
                 return _prefetch.apply(this, arguments);
               }
 
@@ -2899,7 +2921,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function fetchComponent(_x15) {
+              function fetchComponent(_x16) {
                 return _fetchComponent.apply(this, arguments);
               }
 
@@ -2975,12 +2997,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           },
           {
             key: "abortComponentLoad",
-            value: function abortComponentLoad(as) {
+            value: function abortComponentLoad(as, shallow) {
               if (this.clc) {
                 Router.events.emit(
                   "routeChangeError",
                   buildCancellationError(),
-                  as
+                  as,
+                  {
+                    shallow: shallow
+                  }
                 );
                 this.clc();
                 this.clc = null;
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       as="script"
     />
     <link
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 11.7s 11.8s ⚠️ +74ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +653 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..8b6e.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-3c9ff84..1d7c.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
677f882d2ed8..546e.js gzip N/A 12.8 kB N/A
Overall change 59 kB 59.1 kB ⚠️ +21 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-fca3d..2eb1.js gzip 3.44 kB 3.44 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
_error.js 997 kB 997 kB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 998 kB 998 kB
link.js 1.05 MB 1.05 MB ⚠️ +262 B
routerDirect.js 1.04 MB 1.05 MB ⚠️ +262 B
withRouter.js 1.04 MB 1.05 MB ⚠️ +262 B
Overall change 5.14 MB 5.14 MB ⚠️ +786 B
Commit: 78a2253

@ijjk
Copy link
Member

ijjk commented Dec 3, 2020

Failing test suites

Commit: 78a2253

test/integration/basepath/test/index.test.js

  • basePath development > should use urls with basepath in router events
  • basePath development > should use urls with basepath in router events for hash changes
  • basePath development > should use urls with basepath in router events for cancelled routes
  • basePath development > should use urls with basepath in router events for failed route change
  • basePath production > should use urls with basepath in router events
  • basePath production > should use urls with basepath in router events for hash changes
  • basePath production > should use urls with basepath in router events for cancelled routes
  • basePath production > should use urls with basepath in router events for failed route change
  • basePath serverless > should use urls with basepath in router events
  • basePath serverless > should use urls with basepath in router events for hash changes
  • basePath serverless > should use urls with basepath in router events for cancelled routes
  • basePath serverless > should use urls with basepath in router events for failed route change
  • multi-level basePath development > should use urls with basepath in router events
  • multi-level basePath development > should use urls with basepath in router events for hash changes
  • multi-level basePath development > should use urls with basepath in router events for cancelled routes
  • multi-level basePath development > should use urls with basepath in router events for failed route change
  • multi-level basePath production > should use urls with basepath in router events
  • multi-level basePath production > should use urls with basepath in router events for hash changes
  • multi-level basePath production > should use urls with basepath in router events for cancelled routes
  • multi-level basePath production > should use urls with basepath in router events for failed route change
Expand output

● basePath development › should use urls with basepath in router events

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 9

  Array [
    Array [
      "routeChangeStart",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  924 | 
  925 |       const eventLog = await browser.eval('window._getEventLog()')
> 926 |       expect(eventLog).toEqual([
      |                        ^
  927 |         ['routeChangeStart', `${basePath}/other-page`],
  928 |         ['beforeHistoryChange', `${basePath}/other-page`],
  929 |         ['routeChangeComplete', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:926:24)
      at runMicrotasks (<anonymous>)

● basePath development › should use urls with basepath in router events for hash changes

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 6

  Array [
    Array [
      "hashChangeStart",
      "/docs/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "hashChangeComplete",
      "/docs/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  941 | 
  942 |       const eventLog = await browser.eval('window._getEventLog()')
> 943 |       expect(eventLog).toEqual([
      |                        ^
  944 |         ['hashChangeStart', `${basePath}/hello#some-hash`],
  945 |         ['hashChangeComplete', `${basePath}/hello#some-hash`],
  946 |       ])

  at Object.<anonymous> (integration/basepath/test/index.test.js:943:24)
      at runMicrotasks (<anonymous>)

● basePath development › should use urls with basepath in router events for cancelled routes

expect(received).toEqual(expected) // deep equality

- Expected  -  0
+ Received  + 12

  Array [
    Array [
      "routeChangeStart",
      "/docs/slow-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Route Cancelled",
      true,
      "/docs/slow-route",
    ],
    Array [
      "routeChangeStart",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  962 | 
  963 |       const eventLog = await browser.eval('window._getEventLog()')
> 964 |       expect(eventLog).toEqual([
      |                        ^
  965 |         ['routeChangeStart', `${basePath}/slow-route`],
  966 |         ['routeChangeError', 'Route Cancelled', true, `${basePath}/slow-route`],
  967 |         ['routeChangeStart', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:964:24)
      at runMicrotasks (<anonymous>)

● basePath development › should use urls with basepath in router events for failed route change

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,9 +1,12 @@
  Array [
    Array [
      "routeChangeStart",
      "/docs/error-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Failed to load static props",
      null,

  983 | 
  984 |       const eventLog = await browser.eval('window._getEventLog()')
> 985 |       expect(eventLog).toEqual([
      |                        ^
  986 |         ['routeChangeStart', `${basePath}/error-route`],
  987 |         [
  988 |           'routeChangeError',

  at Object.<anonymous> (integration/basepath/test/index.test.js:985:24)
      at runMicrotasks (<anonymous>)

● basePath production › should use urls with basepath in router events

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 9

  Array [
    Array [
      "routeChangeStart",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  924 | 
  925 |       const eventLog = await browser.eval('window._getEventLog()')
> 926 |       expect(eventLog).toEqual([
      |                        ^
  927 |         ['routeChangeStart', `${basePath}/other-page`],
  928 |         ['beforeHistoryChange', `${basePath}/other-page`],
  929 |         ['routeChangeComplete', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:926:24)
      at runMicrotasks (<anonymous>)

● basePath production › should use urls with basepath in router events for hash changes

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 6

  Array [
    Array [
      "hashChangeStart",
      "/docs/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "hashChangeComplete",
      "/docs/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  941 | 
  942 |       const eventLog = await browser.eval('window._getEventLog()')
> 943 |       expect(eventLog).toEqual([
      |                        ^
  944 |         ['hashChangeStart', `${basePath}/hello#some-hash`],
  945 |         ['hashChangeComplete', `${basePath}/hello#some-hash`],
  946 |       ])

  at Object.<anonymous> (integration/basepath/test/index.test.js:943:24)
      at runMicrotasks (<anonymous>)

● basePath production › should use urls with basepath in router events for cancelled routes

expect(received).toEqual(expected) // deep equality

- Expected  -  0
+ Received  + 12

  Array [
    Array [
      "routeChangeStart",
      "/docs/slow-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Route Cancelled",
      true,
      "/docs/slow-route",
    ],
    Array [
      "routeChangeStart",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  962 | 
  963 |       const eventLog = await browser.eval('window._getEventLog()')
> 964 |       expect(eventLog).toEqual([
      |                        ^
  965 |         ['routeChangeStart', `${basePath}/slow-route`],
  966 |         ['routeChangeError', 'Route Cancelled', true, `${basePath}/slow-route`],
  967 |         ['routeChangeStart', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:964:24)
      at runMicrotasks (<anonymous>)

● basePath production › should use urls with basepath in router events for failed route change

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,9 +1,12 @@
  Array [
    Array [
      "routeChangeStart",
      "/docs/error-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Failed to load static props",
      null,

  983 | 
  984 |       const eventLog = await browser.eval('window._getEventLog()')
> 985 |       expect(eventLog).toEqual([
      |                        ^
  986 |         ['routeChangeStart', `${basePath}/error-route`],
  987 |         [
  988 |           'routeChangeError',

  at Object.<anonymous> (integration/basepath/test/index.test.js:985:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath development › should use urls with basepath in router events

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 9

  Array [
    Array [
      "routeChangeStart",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  924 | 
  925 |       const eventLog = await browser.eval('window._getEventLog()')
> 926 |       expect(eventLog).toEqual([
      |                        ^
  927 |         ['routeChangeStart', `${basePath}/other-page`],
  928 |         ['beforeHistoryChange', `${basePath}/other-page`],
  929 |         ['routeChangeComplete', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:926:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath development › should use urls with basepath in router events for hash changes

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 6

  Array [
    Array [
      "hashChangeStart",
      "/hello/world/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "hashChangeComplete",
      "/hello/world/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  941 | 
  942 |       const eventLog = await browser.eval('window._getEventLog()')
> 943 |       expect(eventLog).toEqual([
      |                        ^
  944 |         ['hashChangeStart', `${basePath}/hello#some-hash`],
  945 |         ['hashChangeComplete', `${basePath}/hello#some-hash`],
  946 |       ])

  at Object.<anonymous> (integration/basepath/test/index.test.js:943:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath development › should use urls with basepath in router events for cancelled routes

expect(received).toEqual(expected) // deep equality

- Expected  -  0
+ Received  + 12

  Array [
    Array [
      "routeChangeStart",
      "/hello/world/slow-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Route Cancelled",
      true,
      "/hello/world/slow-route",
    ],
    Array [
      "routeChangeStart",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  962 | 
  963 |       const eventLog = await browser.eval('window._getEventLog()')
> 964 |       expect(eventLog).toEqual([
      |                        ^
  965 |         ['routeChangeStart', `${basePath}/slow-route`],
  966 |         ['routeChangeError', 'Route Cancelled', true, `${basePath}/slow-route`],
  967 |         ['routeChangeStart', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:964:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath development › should use urls with basepath in router events for failed route change

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,9 +1,12 @@
  Array [
    Array [
      "routeChangeStart",
      "/hello/world/error-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Failed to load static props",
      null,

  983 | 
  984 |       const eventLog = await browser.eval('window._getEventLog()')
> 985 |       expect(eventLog).toEqual([
      |                        ^
  986 |         ['routeChangeStart', `${basePath}/error-route`],
  987 |         [
  988 |           'routeChangeError',

  at Object.<anonymous> (integration/basepath/test/index.test.js:985:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath production › should use urls with basepath in router events

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 9

  Array [
    Array [
      "routeChangeStart",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  924 | 
  925 |       const eventLog = await browser.eval('window._getEventLog()')
> 926 |       expect(eventLog).toEqual([
      |                        ^
  927 |         ['routeChangeStart', `${basePath}/other-page`],
  928 |         ['beforeHistoryChange', `${basePath}/other-page`],
  929 |         ['routeChangeComplete', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:926:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath production › should use urls with basepath in router events for hash changes

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 6

  Array [
    Array [
      "hashChangeStart",
      "/hello/world/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "hashChangeComplete",
      "/hello/world/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  941 | 
  942 |       const eventLog = await browser.eval('window._getEventLog()')
> 943 |       expect(eventLog).toEqual([
      |                        ^
  944 |         ['hashChangeStart', `${basePath}/hello#some-hash`],
  945 |         ['hashChangeComplete', `${basePath}/hello#some-hash`],
  946 |       ])

  at Object.<anonymous> (integration/basepath/test/index.test.js:943:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath production › should use urls with basepath in router events for cancelled routes

expect(received).toEqual(expected) // deep equality

- Expected  -  0
+ Received  + 12

  Array [
    Array [
      "routeChangeStart",
      "/hello/world/slow-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Route Cancelled",
      true,
      "/hello/world/slow-route",
    ],
    Array [
      "routeChangeStart",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/hello/world/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  962 | 
  963 |       const eventLog = await browser.eval('window._getEventLog()')
> 964 |       expect(eventLog).toEqual([
      |                        ^
  965 |         ['routeChangeStart', `${basePath}/slow-route`],
  966 |         ['routeChangeError', 'Route Cancelled', true, `${basePath}/slow-route`],
  967 |         ['routeChangeStart', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:964:24)
      at runMicrotasks (<anonymous>)

● multi-level basePath production › should use urls with basepath in router events for failed route change

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,9 +1,12 @@
  Array [
    Array [
      "routeChangeStart",
      "/hello/world/error-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Failed to load static props",
      null,

  983 | 
  984 |       const eventLog = await browser.eval('window._getEventLog()')
> 985 |       expect(eventLog).toEqual([
      |                        ^
  986 |         ['routeChangeStart', `${basePath}/error-route`],
  987 |         [
  988 |           'routeChangeError',

  at Object.<anonymous> (integration/basepath/test/index.test.js:985:24)
      at runMicrotasks (<anonymous>)

● basePath serverless › should use urls with basepath in router events

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 9

  Array [
    Array [
      "routeChangeStart",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  924 | 
  925 |       const eventLog = await browser.eval('window._getEventLog()')
> 926 |       expect(eventLog).toEqual([
      |                        ^
  927 |         ['routeChangeStart', `${basePath}/other-page`],
  928 |         ['beforeHistoryChange', `${basePath}/other-page`],
  929 |         ['routeChangeComplete', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:926:24)
      at runMicrotasks (<anonymous>)

● basePath serverless › should use urls with basepath in router events for hash changes

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 6

  Array [
    Array [
      "hashChangeStart",
      "/docs/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "hashChangeComplete",
      "/docs/hello#some-hash",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  941 | 
  942 |       const eventLog = await browser.eval('window._getEventLog()')
> 943 |       expect(eventLog).toEqual([
      |                        ^
  944 |         ['hashChangeStart', `${basePath}/hello#some-hash`],
  945 |         ['hashChangeComplete', `${basePath}/hello#some-hash`],
  946 |       ])

  at Object.<anonymous> (integration/basepath/test/index.test.js:943:24)
      at runMicrotasks (<anonymous>)

● basePath serverless › should use urls with basepath in router events for cancelled routes

expect(received).toEqual(expected) // deep equality

- Expected  -  0
+ Received  + 12

  Array [
    Array [
      "routeChangeStart",
      "/docs/slow-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Route Cancelled",
      true,
      "/docs/slow-route",
    ],
    Array [
      "routeChangeStart",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "beforeHistoryChange",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeComplete",
      "/docs/other-page",
+     Object {
+       "shallow": false,
+     },
    ],
  ]

  962 | 
  963 |       const eventLog = await browser.eval('window._getEventLog()')
> 964 |       expect(eventLog).toEqual([
      |                        ^
  965 |         ['routeChangeStart', `${basePath}/slow-route`],
  966 |         ['routeChangeError', 'Route Cancelled', true, `${basePath}/slow-route`],
  967 |         ['routeChangeStart', `${basePath}/other-page`],

  at Object.<anonymous> (integration/basepath/test/index.test.js:964:24)
      at runMicrotasks (<anonymous>)

● basePath serverless › should use urls with basepath in router events for failed route change

expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,9 +1,12 @@
  Array [
    Array [
      "routeChangeStart",
      "/docs/error-route",
+     Object {
+       "shallow": false,
+     },
    ],
    Array [
      "routeChangeError",
      "Failed to load static props",
      null,

  983 | 
  984 |       const eventLog = await browser.eval('window._getEventLog()')
> 985 |       expect(eventLog).toEqual([
      |                        ^
  986 |         ['routeChangeStart', `${basePath}/error-route`],
  987 |         [
  988 |           'routeChangeError',

  at Object.<anonymous> (integration/basepath/test/index.test.js:985:24)
      at runMicrotasks (<anonymous>)

@vercel vercel bot temporarily deployed to Preview December 4, 2020 01:53 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 4, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 9.7s 9.6s -88ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +653 B
Page Load Tests Overall increase ✓
vercel/next.js canary bragle/next.js canary Change
/ failed reqs 0 0
/ total time (seconds) 1.962 1.939 -0.02
/ avg req/sec 1273.89 1289.28 +15.39
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.264 1.213 -0.05
/error-in-render avg req/sec 1978.61 2061.36 +82.75
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..8b6e.js gzip 12.8 kB 12.8 kB ⚠️ +21 B
framework.HASH.js gzip 39 kB 39 kB
main-3c9ff84..1d7c.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59.1 kB ⚠️ +21 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-fca3d..2eb1.js gzip 3.44 kB 3.44 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
index.html gzip 614 B 614 B
link.html gzip 620 B 620 B
withRouter.html gzip 608 B 607 B -1 B
Overall change 1.84 kB 1.84 kB -1 B

Diffs

Diff for 677f882d2ed8..4eae9202a.js
@@ -1739,6 +1739,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     normalizeLocalePath,
                     parsedAs,
                     localePathResult,
+                    _options$shallow,
+                    shallow,
                     cleanedAs,
                     parsed,
                     _parsed,
@@ -1748,8 +1750,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     rewrites,
                     _yield,
                     route,
-                    _options$shallow,
-                    shallow,
                     resolvedAs,
                     potentialHref,
                     _parsedAs,
@@ -1846,8 +1846,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               performance.mark("routeChange");
                             }
 
+                            (_options$shallow = options.shallow),
+                              (shallow =
+                                _options$shallow === void 0
+                                  ? false
+                                  : _options$shallow);
+
                             if (this._inFlightRoute) {
-                              this.abortComponentLoad(this._inFlightRoute);
+                              this.abortComponentLoad(
+                                this._inFlightRoute,
+                                shallow
+                              );
                             }
 
                             as = addBasePath(
@@ -1870,20 +1879,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (
                               !(!options._h && this.onlyAHashChange(cleanedAs))
                             ) {
-                              _context.next = 29;
+                              _context.next = 30;
                               break;
                             }
 
                             this.asPath = cleanedAs;
-                            Router.events.emit("hashChangeStart", as); // TODO: do we need the resolved href when only a hash change?
+                            Router.events.emit("hashChangeStart", as, {
+                              shallow: shallow
+                            }); // TODO: do we need the resolved href when only a hash change?
 
                             this.changeState(method, url, as, options);
                             this.scrollToHash(cleanedAs);
                             this.notify(this.components[this.route]);
-                            Router.events.emit("hashChangeComplete", as);
+                            Router.events.emit("hashChangeComplete", as, {
+                              shallow: shallow
+                            });
                             return _context.abrupt("return", true);
 
-                          case 29:
+                          case 30:
                             parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
                               url
                             );
@@ -1893,30 +1906,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             // get their query parameters to allow ensuring they can be parsed properly
                             // when rewritten to
 
-                            _context.prev = 31;
-                            _context.next = 34;
+                            _context.prev = 32;
+                            _context.next = 35;
                             return this.pageLoader.getPageList();
 
-                          case 34:
+                          case 35:
                             pages = _context.sent;
-                            _context.next = 37;
+                            _context.next = 38;
                             return (0, _routeLoader.getClientBuildManifest)();
 
-                          case 37:
+                          case 38:
                             _yield = _context.sent;
                             rewrites = _yield.__rewrites;
-                            _context.next = 45;
+                            _context.next = 46;
                             break;
 
-                          case 41:
-                            _context.prev = 41;
-                            _context.t0 = _context["catch"](31);
+                          case 42:
+                            _context.prev = 42;
+                            _context.t0 = _context["catch"](32);
                             // If we fail to resolve the page list or client-build manifest, we must
                             // do a server-side transition:
                             window.location.href = as;
                             return _context.abrupt("return", false);
 
-                          case 45:
+                          case 46:
                             parsed = this._resolveHref(parsed, pages);
 
                             if (parsed.pathname !== pathname) {
@@ -1944,12 +1957,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             route = (0,
                             _normalizeTrailingSlash.removePathTrailingSlash)(
                               pathname
-                            );
-                            (_options$shallow = options.shallow),
-                              (shallow =
-                                _options$shallow === void 0
-                                  ? false
-                                  : _options$shallow); // we need to resolve the as value using rewrites for dynamic SSG
+                            ); // we need to resolve the as value using rewrites for dynamic SSG
                             // pages to allow building the data URL correctly
 
                             resolvedAs = as;
@@ -2049,7 +2057,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             }
 
                           case 69:
-                            Router.events.emit("routeChangeStart", as);
+                            Router.events.emit("routeChangeStart", as, {
+                              shallow: shallow
+                            });
                             _context.prev = 70;
                             _context.next = 73;
                             return this.getRouteInfo(
@@ -2118,7 +2128,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             );
 
                           case 85:
-                            Router.events.emit("beforeHistoryChange", as);
+                            Router.events.emit("beforeHistoryChange", as, {
+                              shallow: shallow
+                            });
                             this.changeState(method, url, as, options);
 
                             if (false) {
@@ -2145,7 +2157,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             Router.events.emit(
                               "routeChangeError",
                               error,
-                              cleanedAs
+                              cleanedAs,
+                              {
+                                shallow: shallow
+                              }
                             );
                             throw error;
 
@@ -2156,7 +2171,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (false) {
                             }
 
-                            Router.events.emit("routeChangeComplete", as);
+                            Router.events.emit("routeChangeComplete", as, {
+                              shallow: shallow
+                            });
                             return _context.abrupt("return", true);
 
                           case 99:
@@ -2182,7 +2199,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _callee,
                     this,
                     [
-                      [31, 41],
+                      [32, 42],
                       [70, 99]
                     ]
                   );
@@ -2233,6 +2250,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   pathname,
                   query,
                   as,
+                  shallow,
                   loadErrorFail
                 ) {
                   var Component,
@@ -2267,7 +2285,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               break;
                             }
 
-                            Router.events.emit("routeChangeError", err, as); // If we can't load the page it could be one of following reasons
+                            Router.events.emit("routeChangeError", err, as, {
+                              shallow: shallow
+                            }); // If we can't load the page it could be one of following reasons
                             //  1. Page doesn't exists
                             //  2. Page does exist in a different zone
                             //  3. Internal error while loading the page
@@ -2391,6 +2411,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 pathname,
                                 query,
                                 as,
+                                shallow,
                                 true
                               )
                             );
@@ -2412,7 +2433,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9) {
+              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {
                 return _handleRouteInfoError.apply(this, arguments);
               }
 
@@ -2583,7 +2604,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 _context3.t1,
                                 pathname,
                                 query,
-                                as
+                                as,
+                                shallow
                               )
                             );
 
@@ -2600,7 +2622,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function getRouteInfo(_x10, _x11, _x12, _x13) {
+              function getRouteInfo(_x11, _x12, _x13, _x14) {
                 return _getRouteInfo.apply(this, arguments);
               }
 
@@ -2834,7 +2856,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function prefetch(_x14) {
+              function prefetch(_x15) {
                 return _prefetch.apply(this, arguments);
               }
 
@@ -2899,7 +2921,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function fetchComponent(_x15) {
+              function fetchComponent(_x16) {
                 return _fetchComponent.apply(this, arguments);
               }
 
@@ -2975,12 +2997,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           },
           {
             key: "abortComponentLoad",
-            value: function abortComponentLoad(as) {
+            value: function abortComponentLoad(as, shallow) {
               if (this.clc) {
                 Router.events.emit(
                   "routeChangeError",
                   buildCancellationError(),
-                  as
+                  as,
+                  {
+                    shallow: shallow
+                  }
                 );
                 this.clc();
                 this.clc = null;
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       as="script"
     />
     <link
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.a8f91a45a8b4eae9202a.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f6b2035f70923751a09b.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 11.4s 11.6s ⚠️ +187ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +653 B
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..8b6e.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-3c9ff84..1d7c.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
677f882d2ed8..546e.js gzip N/A 12.8 kB N/A
Overall change 59 kB 59.1 kB ⚠️ +21 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-fca3d..2eb1.js gzip 3.44 kB 3.44 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
_error.js 997 kB 997 kB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 998 kB 998 kB
link.js 1.05 MB 1.05 MB ⚠️ +262 B
routerDirect.js 1.04 MB 1.05 MB ⚠️ +262 B
withRouter.js 1.04 MB 1.05 MB ⚠️ +262 B
Overall change 5.14 MB 5.14 MB ⚠️ +786 B
Commit: bf337c2

@timneutkens
Copy link
Member

There doesn't seem to be enough interest in this feature to justify the bundle size increase.

@bragle
Copy link
Contributor Author

bragle commented Dec 4, 2020

@timneutkens How many upvotes would justify this? I could try to make the size increase smaller if that'd help?

@vercel vercel bot temporarily deployed to Preview December 8, 2020 14:22 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 8, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 9.9s 9.9s ⚠️ +4ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +932 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary bragle/next.js canary Change
/ failed reqs 0 0
/ total time (seconds) 2.51 2.53 ⚠️ +0.02
/ avg req/sec 996.07 988.32 ⚠️ -7.75
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.439 1.449 ⚠️ +0.01
/error-in-render avg req/sec 1736.87 1725.83 ⚠️ -11.04
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..34b9.js gzip 12.8 kB 12.7 kB -33 B
framework.HASH.js gzip 39 kB 39 kB
main-f501b4a..c42e.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB -33 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..fd29.js gzip 303 B 303 B
withRouter-b..76ae.js gzip 302 B 302 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 322 B 322 B
Overall change 322 B 322 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
index.html gzip 614 B 613 B -1 B
link.html gzip 621 B 619 B -2 B
withRouter.html gzip 607 B 607 B
Overall change 1.84 kB 1.84 kB -3 B

Diffs

Diff for 677f882d2ed8..4f72a9a2e.js
@@ -1739,6 +1739,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     normalizeLocalePath,
                     parsedAs,
                     localePathResult,
+                    _options$shallow,
+                    shallow,
+                    routeProps,
                     cleanedAs,
                     parsed,
                     _parsed,
@@ -1748,8 +1751,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     rewrites,
                     _yield,
                     route,
-                    _options$shallow,
-                    shallow,
                     resolvedAs,
                     potentialHref,
                     _parsedAs,
@@ -1846,8 +1847,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               performance.mark("routeChange");
                             }
 
+                            (_options$shallow = options.shallow),
+                              (shallow =
+                                _options$shallow === void 0
+                                  ? false
+                                  : _options$shallow);
+                            routeProps = {
+                              shallow: shallow
+                            };
+
                             if (this._inFlightRoute) {
-                              this.abortComponentLoad(this._inFlightRoute);
+                              this.abortComponentLoad(
+                                this._inFlightRoute,
+                                routeProps
+                              );
                             }
 
                             as = addBasePath(
@@ -1870,20 +1883,28 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (
                               !(!options._h && this.onlyAHashChange(cleanedAs))
                             ) {
-                              _context.next = 29;
+                              _context.next = 31;
                               break;
                             }
 
                             this.asPath = cleanedAs;
-                            Router.events.emit("hashChangeStart", as); // TODO: do we need the resolved href when only a hash change?
+                            Router.events.emit(
+                              "hashChangeStart",
+                              as,
+                              routeProps
+                            ); // TODO: do we need the resolved href when only a hash change?
 
                             this.changeState(method, url, as, options);
                             this.scrollToHash(cleanedAs);
                             this.notify(this.components[this.route]);
-                            Router.events.emit("hashChangeComplete", as);
+                            Router.events.emit(
+                              "hashChangeComplete",
+                              as,
+                              routeProps
+                            );
                             return _context.abrupt("return", true);
 
-                          case 29:
+                          case 31:
                             parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
                               url
                             );
@@ -1893,30 +1914,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             // get their query parameters to allow ensuring they can be parsed properly
                             // when rewritten to
 
-                            _context.prev = 31;
-                            _context.next = 34;
+                            _context.prev = 33;
+                            _context.next = 36;
                             return this.pageLoader.getPageList();
 
-                          case 34:
+                          case 36:
                             pages = _context.sent;
-                            _context.next = 37;
+                            _context.next = 39;
                             return (0, _routeLoader.getClientBuildManifest)();
 
-                          case 37:
+                          case 39:
                             _yield = _context.sent;
                             rewrites = _yield.__rewrites;
-                            _context.next = 45;
+                            _context.next = 47;
                             break;
 
-                          case 41:
-                            _context.prev = 41;
-                            _context.t0 = _context["catch"](31);
+                          case 43:
+                            _context.prev = 43;
+                            _context.t0 = _context["catch"](33);
                             // If we fail to resolve the page list or client-build manifest, we must
                             // do a server-side transition:
                             window.location.href = as;
                             return _context.abrupt("return", false);
 
-                          case 45:
+                          case 47:
                             parsed = this._resolveHref(parsed, pages);
 
                             if (parsed.pathname !== pathname) {
@@ -1944,12 +1965,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             route = (0,
                             _normalizeTrailingSlash.removePathTrailingSlash)(
                               pathname
-                            );
-                            (_options$shallow = options.shallow),
-                              (shallow =
-                                _options$shallow === void 0
-                                  ? false
-                                  : _options$shallow); // we need to resolve the as value using rewrites for dynamic SSG
+                            ); // we need to resolve the as value using rewrites for dynamic SSG
                             // pages to allow building the data URL correctly
 
                             resolvedAs = as;
@@ -1963,7 +1979,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             );
 
                             if (!(0, _isDynamic.isDynamicRoute)(route)) {
-                              _context.next = 69;
+                              _context.next = 70;
                               break;
                             }
 
@@ -1986,7 +2002,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 (shouldInterpolate && !interpolatedAs.result)
                               )
                             ) {
-                              _context.next = 68;
+                              _context.next = 69;
                               break;
                             }
 
@@ -1997,7 +2013,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             });
 
                             if (!(missingParams.length > 0)) {
-                              _context.next = 66;
+                              _context.next = 67;
                               break;
                             }
 
@@ -2028,11 +2044,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 )
                             );
 
-                          case 66:
-                            _context.next = 69;
+                          case 67:
+                            _context.next = 70;
                             break;
 
-                          case 68:
+                          case 69:
                             if (shouldInterpolate) {
                               as = (0, _utils.formatWithValidation)(
                                 Object.assign({}, _parsedAs, {
@@ -2048,19 +2064,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               Object.assign(query, routeMatch);
                             }
 
-                          case 69:
-                            Router.events.emit("routeChangeStart", as);
-                            _context.prev = 70;
-                            _context.next = 73;
+                          case 70:
+                            Router.events.emit(
+                              "routeChangeStart",
+                              as,
+                              routeProps
+                            );
+                            _context.prev = 71;
+                            _context.next = 74;
                             return this.getRouteInfo(
                               route,
                               pathname,
                               query,
                               as,
-                              shallow
+                              routeProps
                             );
 
-                          case 73:
+                          case 74:
                             routeInfo = _context.sent;
                             (error = routeInfo.error),
                               (props = routeInfo.props),
@@ -2075,7 +2095,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 props.pageProps.__N_REDIRECT
                               )
                             ) {
-                              _context.next = 85;
+                              _context.next = 86;
                               break;
                             }
 
@@ -2084,7 +2104,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             // it's not
 
                             if (!destination.startsWith("/")) {
-                              _context.next = 83;
+                              _context.next = 84;
                               break;
                             }
 
@@ -2094,7 +2114,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             this._resolveHref(parsedHref, pages, false);
 
                             if (!pages.includes(parsedHref.pathname)) {
-                              _context.next = 83;
+                              _context.next = 84;
                               break;
                             }
 
@@ -2110,21 +2130,25 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               this.change(method, newUrl, newAs, options)
                             );
 
-                          case 83:
+                          case 84:
                             window.location.href = destination;
                             return _context.abrupt(
                               "return",
                               new Promise(function() {})
                             );
 
-                          case 85:
-                            Router.events.emit("beforeHistoryChange", as);
+                          case 86:
+                            Router.events.emit(
+                              "beforeHistoryChange",
+                              as,
+                              routeProps
+                            );
                             this.changeState(method, url, as, options);
 
                             if (false) {
                             }
 
-                            _context.next = 90;
+                            _context.next = 91;
                             return this.set(
                               route,
                               pathname,
@@ -2136,44 +2160,49 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               else throw e;
                             });
 
-                          case 90:
+                          case 91:
                             if (!error) {
-                              _context.next = 93;
+                              _context.next = 94;
                               break;
                             }
 
                             Router.events.emit(
                               "routeChangeError",
                               error,
-                              cleanedAs
+                              cleanedAs,
+                              routeProps
                             );
                             throw error;
 
-                          case 93:
+                          case 94:
                             if (false) {
                             }
 
                             if (false) {
                             }
 
-                            Router.events.emit("routeChangeComplete", as);
+                            Router.events.emit(
+                              "routeChangeComplete",
+                              as,
+                              routeProps
+                            );
                             return _context.abrupt("return", true);
 
-                          case 99:
-                            _context.prev = 99;
-                            _context.t1 = _context["catch"](70);
+                          case 100:
+                            _context.prev = 100;
+                            _context.t1 = _context["catch"](71);
 
                             if (!_context.t1.cancelled) {
-                              _context.next = 103;
+                              _context.next = 104;
                               break;
                             }
 
                             return _context.abrupt("return", false);
 
-                          case 103:
+                          case 104:
                             throw _context.t1;
 
-                          case 104:
+                          case 105:
                           case "end":
                             return _context.stop();
                         }
@@ -2182,8 +2211,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _callee,
                     this,
                     [
-                      [31, 41],
-                      [70, 99]
+                      [33, 43],
+                      [71, 100]
                     ]
                   );
                 })
@@ -2233,6 +2262,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   pathname,
                   query,
                   as,
+                  routeProps,
                   loadErrorFail
                 ) {
                   var Component,
@@ -2267,7 +2297,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               break;
                             }
 
-                            Router.events.emit("routeChangeError", err, as); // If we can't load the page it could be one of following reasons
+                            Router.events.emit(
+                              "routeChangeError",
+                              err,
+                              as,
+                              routeProps
+                            ); // If we can't load the page it could be one of following reasons
                             //  1. Page doesn't exists
                             //  2. Page does exist in a different zone
                             //  3. Internal error while loading the page
@@ -2391,6 +2426,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 pathname,
                                 query,
                                 as,
+                                routeProps,
                                 true
                               )
                             );
@@ -2412,7 +2448,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9) {
+              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {
                 return _handleRouteInfoError.apply(this, arguments);
               }
 
@@ -2427,12 +2463,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   route,
                   pathname,
                   query,
-                  as
+                  as,
+                  routeProps
                 ) {
                   var _this3 = this;
 
-                  var shallow,
-                    existingRouteInfo,
+                  var existingRouteInfo,
                     cachedRouteInfo,
                     routeInfo,
                     Component,
@@ -2441,29 +2477,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _require2,
                     isValidElementType,
                     dataHref,
-                    props,
-                    _args3 = arguments;
+                    props;
 
                   return _regeneratorRuntime.wrap(
                     function _callee3$(_context3) {
                       while (1) {
                         switch ((_context3.prev = _context3.next)) {
                           case 0:
-                            shallow =
-                              _args3.length > 4 && _args3[4] !== undefined
-                                ? _args3[4]
-                                : false;
-                            _context3.prev = 1;
+                            _context3.prev = 0;
                             existingRouteInfo = this.components[route];
 
                             if (
                               !(
-                                shallow &&
+                                routeProps.shallow &&
                                 existingRouteInfo &&
                                 this.route === route
                               )
                             ) {
-                              _context3.next = 5;
+                              _context3.next = 4;
                               break;
                             }
 
@@ -2472,7 +2503,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               existingRouteInfo
                             );
 
-                          case 5:
+                          case 4:
                             cachedRouteInfo =
                               existingRouteInfo &&
                               "initial" in existingRouteInfo
@@ -2480,16 +2511,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 : existingRouteInfo;
 
                             if (!cachedRouteInfo) {
-                              _context3.next = 10;
+                              _context3.next = 9;
                               break;
                             }
 
                             _context3.t0 = cachedRouteInfo;
-                            _context3.next = 13;
+                            _context3.next = 12;
                             break;
 
-                          case 10:
-                            _context3.next = 12;
+                          case 9:
+                            _context3.next = 11;
                             return this.fetchComponent(route).then(function(
                               res
                             ) {
@@ -2501,17 +2532,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               };
                             });
 
-                          case 12:
+                          case 11:
                             _context3.t0 = _context3.sent;
 
-                          case 13:
+                          case 12:
                             routeInfo = _context3.t0;
                             (Component = routeInfo.Component),
                               (__N_SSG = routeInfo.__N_SSG),
                               (__N_SSP = routeInfo.__N_SSP);
 
                             if (true) {
-                              _context3.next = 19;
+                              _context3.next = 18;
                               break;
                             }
 
@@ -2528,7 +2559,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 _require2.isValidElementType);
 
                             if (isValidElementType(Component)) {
-                              _context3.next = 19;
+                              _context3.next = 18;
                               break;
                             }
 
@@ -2539,7 +2570,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               )
                             );
 
-                          case 19:
+                          case 18:
                             if (__N_SSG || __N_SSP) {
                               dataHref = this.pageLoader.getDataHref(
                                 (0, _utils.formatWithValidation)({
@@ -2552,7 +2583,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               );
                             }
 
-                            _context3.next = 22;
+                            _context3.next = 21;
                             return this._getData(function() {
                               return __N_SSG
                                 ? _this3._getStaticData(dataHref)
@@ -2568,26 +2599,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                   );
                             });
 
-                          case 22:
+                          case 21:
                             props = _context3.sent;
                             routeInfo.props = props;
                             this.components[route] = routeInfo;
                             return _context3.abrupt("return", routeInfo);
 
-                          case 28:
-                            _context3.prev = 28;
-                            _context3.t1 = _context3["catch"](1);
+                          case 27:
+                            _context3.prev = 27;
+                            _context3.t1 = _context3["catch"](0);
                             return _context3.abrupt(
                               "return",
                               this.handleRouteInfoError(
                                 _context3.t1,
                                 pathname,
                                 query,
-                                as
+                                as,
+                                routeProps
                               )
                             );
 
-                          case 31:
+                          case 30:
                           case "end":
                             return _context3.stop();
                         }
@@ -2595,12 +2627,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     },
                     _callee3,
                     this,
-                    [[1, 28]]
+                    [[0, 27]]
                   );
                 })
               );
 
-              function getRouteInfo(_x10, _x11, _x12, _x13) {
+              function getRouteInfo(_x11, _x12, _x13, _x14, _x15) {
                 return _getRouteInfo.apply(this, arguments);
               }
 
@@ -2834,7 +2866,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function prefetch(_x14) {
+              function prefetch(_x16) {
                 return _prefetch.apply(this, arguments);
               }
 
@@ -2899,7 +2931,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function fetchComponent(_x15) {
+              function fetchComponent(_x17) {
                 return _fetchComponent.apply(this, arguments);
               }
 
@@ -2975,12 +3007,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           },
           {
             key: "abortComponentLoad",
-            value: function abortComponentLoad(as) {
+            value: function abortComponentLoad(as, routeProps) {
               if (this.clc) {
                 Router.events.emit(
                   "routeChangeError",
                   buildCancellationError(),
-                  as
+                  as,
+                  routeProps
                 );
                 this.clc();
                 this.clc = null;
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef24a8546d94f72a9a2e.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.cd6bb62960856006d14c.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef24a8546d94f72a9a2e.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.cd6bb62960856006d14c.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef24a8546d94f72a9a2e.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.cd6bb62960856006d14c.js"
       as="script"
     />
     <link
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef24a8546d94f72a9a2e.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.cd6bb62960856006d14c.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef24a8546d94f72a9a2e.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.cd6bb62960856006d14c.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.ef24a8546d94f72a9a2e.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.cd6bb62960856006d14c.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 11.9s 11.3s -666ms
nodeModulesSize 82.5 MB 82.5 MB ⚠️ +932 B
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..34b9.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-f501b4a..c42e.js gzip 6.56 kB 6.56 kB
webpack-e067..f178.js gzip 751 B 751 B
677f882d2ed8..cda3.js gzip N/A 12.7 kB N/A
Overall change 59 kB 59 kB -33 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-7231d4b..5856.js gzip 1.28 kB 1.28 kB
_error-01375..90b6.js gzip 3.69 kB 3.69 kB
hooks-d4591d..e7c2.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-db223d9..dbd7.js gzip 1.61 kB 1.61 kB
routerDirect..fd29.js gzip 303 B 303 B
withRouter-b..76ae.js gzip 302 B 302 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 322 B 322 B
Overall change 322 B 322 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB ⚠️ +212 B
routerDirect.js 1.05 MB 1.05 MB ⚠️ +212 B
withRouter.js 1.05 MB 1.05 MB ⚠️ +212 B
Overall change 5.16 MB 5.16 MB ⚠️ +636 B
Commit: 04d5126

@mi-na-bot
Copy link
Contributor

@timneutkens Is bundle size the main rationale for the client-side router's feature set?

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine now with the reduced bundle size 👍 Great work @bragle 💯

@vercel vercel bot temporarily deployed to Preview December 17, 2020 08:54 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 17, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 8.5s 8.6s ⚠️ +109ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +932 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary bragle/next.js canary Change
/ failed reqs 0 0
/ total time (seconds) 2.013 2.013
/ avg req/sec 1241.78 1241.74 ⚠️ -0.04
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.06 1.093 ⚠️ +0.03
/error-in-render avg req/sec 2358.69 2287.02 ⚠️ -71.67
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..0679.js gzip 12.8 kB 12.8 kB -7 B
framework.HASH.js gzip 39 kB 39 kB
main-086d1b7..8537.js gzip 6.56 kB 6.56 kB
webpack-95c2..e870.js gzip 751 B 751 B
Overall change 59.1 kB 59 kB -7 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-d3..23f6.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-0d19cb6..5497.js gzip 1.28 kB 1.28 kB
_error-2cf0e..a0a0.js gzip 3.69 kB 3.69 kB
hooks-42456f..0c06.js gzip 887 B 887 B
index-8081ce..e44f.js gzip 227 B 227 B
link-0ab9f83..fa00.js gzip 1.61 kB 1.61 kB
routerDirect..c3d8.js gzip 303 B 303 B
withRouter-0..a68e.js gzip 302 B 302 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
index.html gzip 615 B 613 B -2 B
link.html gzip 621 B 619 B -2 B
withRouter.html gzip 609 B 607 B -2 B
Overall change 1.84 kB 1.84 kB -6 B

Diffs

Diff for 677f882d2ed8..26d0f2923.js
@@ -1739,6 +1739,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _this$locales,
                     parsedAs,
                     localePathResult,
+                    _options$shallow,
+                    shallow,
+                    routeProps,
                     cleanedAs,
                     parsed,
                     _parsed,
@@ -1748,8 +1751,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     rewrites,
                     _yield,
                     route,
-                    _options$shallow,
-                    shallow,
                     resolvedAs,
                     potentialHref,
                     _parsedAs,
@@ -1844,8 +1845,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               performance.mark("routeChange");
                             }
 
+                            (_options$shallow = options.shallow),
+                              (shallow =
+                                _options$shallow === void 0
+                                  ? false
+                                  : _options$shallow);
+                            routeProps = {
+                              shallow: shallow
+                            };
+
                             if (this._inFlightRoute) {
-                              this.abortComponentLoad(this._inFlightRoute);
+                              this.abortComponentLoad(
+                                this._inFlightRoute,
+                                routeProps
+                              );
                             }
 
                             as = addBasePath(
@@ -1868,20 +1881,28 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (
                               !(!options._h && this.onlyAHashChange(cleanedAs))
                             ) {
-                              _context.next = 28;
+                              _context.next = 30;
                               break;
                             }
 
                             this.asPath = cleanedAs;
-                            Router.events.emit("hashChangeStart", as); // TODO: do we need the resolved href when only a hash change?
+                            Router.events.emit(
+                              "hashChangeStart",
+                              as,
+                              routeProps
+                            ); // TODO: do we need the resolved href when only a hash change?
 
                             this.changeState(method, url, as, options);
                             this.scrollToHash(cleanedAs);
                             this.notify(this.components[this.route]);
-                            Router.events.emit("hashChangeComplete", as);
+                            Router.events.emit(
+                              "hashChangeComplete",
+                              as,
+                              routeProps
+                            );
                             return _context.abrupt("return", true);
 
-                          case 28:
+                          case 30:
                             parsed = (0, _parseRelativeUrl.parseRelativeUrl)(
                               url
                             );
@@ -1891,30 +1912,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             // get their query parameters to allow ensuring they can be parsed properly
                             // when rewritten to
 
-                            _context.prev = 30;
-                            _context.next = 33;
+                            _context.prev = 32;
+                            _context.next = 35;
                             return this.pageLoader.getPageList();
 
-                          case 33:
+                          case 35:
                             pages = _context.sent;
-                            _context.next = 36;
+                            _context.next = 38;
                             return (0, _routeLoader.getClientBuildManifest)();
 
-                          case 36:
+                          case 38:
                             _yield = _context.sent;
                             rewrites = _yield.__rewrites;
-                            _context.next = 44;
+                            _context.next = 46;
                             break;
 
-                          case 40:
-                            _context.prev = 40;
-                            _context.t0 = _context["catch"](30);
+                          case 42:
+                            _context.prev = 42;
+                            _context.t0 = _context["catch"](32);
                             // If we fail to resolve the page list or client-build manifest, we must
                             // do a server-side transition:
                             window.location.href = as;
                             return _context.abrupt("return", false);
 
-                          case 44:
+                          case 46:
                             parsed = this._resolveHref(parsed, pages);
 
                             if (parsed.pathname !== pathname) {
@@ -1942,12 +1963,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             route = (0,
                             _normalizeTrailingSlash.removePathTrailingSlash)(
                               pathname
-                            );
-                            (_options$shallow = options.shallow),
-                              (shallow =
-                                _options$shallow === void 0
-                                  ? false
-                                  : _options$shallow); // we need to resolve the as value using rewrites for dynamic SSG
+                            ); // we need to resolve the as value using rewrites for dynamic SSG
                             // pages to allow building the data URL correctly
 
                             resolvedAs = as;
@@ -1961,7 +1977,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             );
 
                             if (!(0, _isDynamic.isDynamicRoute)(route)) {
-                              _context.next = 68;
+                              _context.next = 69;
                               break;
                             }
 
@@ -1984,7 +2000,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 (shouldInterpolate && !interpolatedAs.result)
                               )
                             ) {
-                              _context.next = 67;
+                              _context.next = 68;
                               break;
                             }
 
@@ -1995,7 +2011,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             });
 
                             if (!(missingParams.length > 0)) {
-                              _context.next = 65;
+                              _context.next = 66;
                               break;
                             }
 
@@ -2026,11 +2042,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 )
                             );
 
-                          case 65:
-                            _context.next = 68;
+                          case 66:
+                            _context.next = 69;
                             break;
 
-                          case 67:
+                          case 68:
                             if (shouldInterpolate) {
                               as = (0, _utils.formatWithValidation)(
                                 Object.assign({}, _parsedAs, {
@@ -2046,19 +2062,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               Object.assign(query, routeMatch);
                             }
 
-                          case 68:
-                            Router.events.emit("routeChangeStart", as);
-                            _context.prev = 69;
-                            _context.next = 72;
+                          case 69:
+                            Router.events.emit(
+                              "routeChangeStart",
+                              as,
+                              routeProps
+                            );
+                            _context.prev = 70;
+                            _context.next = 73;
                             return this.getRouteInfo(
                               route,
                               pathname,
                               query,
                               as,
-                              shallow
+                              routeProps
                             );
 
-                          case 72:
+                          case 73:
                             routeInfo = _context.sent;
                             (error = routeInfo.error),
                               (props = routeInfo.props),
@@ -2073,7 +2093,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 props.pageProps.__N_REDIRECT
                               )
                             ) {
-                              _context.next = 84;
+                              _context.next = 85;
                               break;
                             }
 
@@ -2082,7 +2102,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             // it's not
 
                             if (!destination.startsWith("/")) {
-                              _context.next = 82;
+                              _context.next = 83;
                               break;
                             }
 
@@ -2092,7 +2112,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             this._resolveHref(parsedHref, pages, false);
 
                             if (!pages.includes(parsedHref.pathname)) {
-                              _context.next = 82;
+                              _context.next = 83;
                               break;
                             }
 
@@ -2108,21 +2128,25 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               this.change(method, newUrl, newAs, options)
                             );
 
-                          case 82:
+                          case 83:
                             window.location.href = destination;
                             return _context.abrupt(
                               "return",
                               new Promise(function() {})
                             );
 
-                          case 84:
-                            Router.events.emit("beforeHistoryChange", as);
+                          case 85:
+                            Router.events.emit(
+                              "beforeHistoryChange",
+                              as,
+                              routeProps
+                            );
                             this.changeState(method, url, as, options);
 
                             if (false) {
                             }
 
-                            _context.next = 89;
+                            _context.next = 90;
                             return this.set(
                               route,
                               pathname,
@@ -2134,44 +2158,49 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               else throw e;
                             });
 
-                          case 89:
+                          case 90:
                             if (!error) {
-                              _context.next = 92;
+                              _context.next = 93;
                               break;
                             }
 
                             Router.events.emit(
                               "routeChangeError",
                               error,
-                              cleanedAs
+                              cleanedAs,
+                              routeProps
                             );
                             throw error;
 
-                          case 92:
+                          case 93:
                             if (false) {
                             }
 
                             if (false) {
                             }
 
-                            Router.events.emit("routeChangeComplete", as);
+                            Router.events.emit(
+                              "routeChangeComplete",
+                              as,
+                              routeProps
+                            );
                             return _context.abrupt("return", true);
 
-                          case 98:
-                            _context.prev = 98;
-                            _context.t1 = _context["catch"](69);
+                          case 99:
+                            _context.prev = 99;
+                            _context.t1 = _context["catch"](70);
 
                             if (!_context.t1.cancelled) {
-                              _context.next = 102;
+                              _context.next = 103;
                               break;
                             }
 
                             return _context.abrupt("return", false);
 
-                          case 102:
+                          case 103:
                             throw _context.t1;
 
-                          case 103:
+                          case 104:
                           case "end":
                             return _context.stop();
                         }
@@ -2180,8 +2209,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _callee,
                     this,
                     [
-                      [30, 40],
-                      [69, 98]
+                      [32, 42],
+                      [70, 99]
                     ]
                   );
                 })
@@ -2231,6 +2260,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   pathname,
                   query,
                   as,
+                  routeProps,
                   loadErrorFail
                 ) {
                   var Component,
@@ -2265,7 +2295,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               break;
                             }
 
-                            Router.events.emit("routeChangeError", err, as); // If we can't load the page it could be one of following reasons
+                            Router.events.emit(
+                              "routeChangeError",
+                              err,
+                              as,
+                              routeProps
+                            ); // If we can't load the page it could be one of following reasons
                             //  1. Page doesn't exists
                             //  2. Page does exist in a different zone
                             //  3. Internal error while loading the page
@@ -2389,6 +2424,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 pathname,
                                 query,
                                 as,
+                                routeProps,
                                 true
                               )
                             );
@@ -2410,7 +2446,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9) {
+              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {
                 return _handleRouteInfoError.apply(this, arguments);
               }
 
@@ -2425,12 +2461,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   route,
                   pathname,
                   query,
-                  as
+                  as,
+                  routeProps
                 ) {
                   var _this3 = this;
 
-                  var shallow,
-                    existingRouteInfo,
+                  var existingRouteInfo,
                     cachedRouteInfo,
                     routeInfo,
                     Component,
@@ -2439,29 +2475,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     _require,
                     isValidElementType,
                     dataHref,
-                    props,
-                    _args3 = arguments;
+                    props;
 
                   return _regeneratorRuntime.wrap(
                     function _callee3$(_context3) {
                       while (1) {
                         switch ((_context3.prev = _context3.next)) {
                           case 0:
-                            shallow =
-                              _args3.length > 4 && _args3[4] !== undefined
-                                ? _args3[4]
-                                : false;
-                            _context3.prev = 1;
+                            _context3.prev = 0;
                             existingRouteInfo = this.components[route];
 
                             if (
                               !(
-                                shallow &&
+                                routeProps.shallow &&
                                 existingRouteInfo &&
                                 this.route === route
                               )
                             ) {
-                              _context3.next = 5;
+                              _context3.next = 4;
                               break;
                             }
 
@@ -2470,7 +2501,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               existingRouteInfo
                             );
 
-                          case 5:
+                          case 4:
                             cachedRouteInfo =
                               existingRouteInfo &&
                               "initial" in existingRouteInfo
@@ -2478,16 +2509,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 : existingRouteInfo;
 
                             if (!cachedRouteInfo) {
-                              _context3.next = 10;
+                              _context3.next = 9;
                               break;
                             }
 
                             _context3.t0 = cachedRouteInfo;
-                            _context3.next = 13;
+                            _context3.next = 12;
                             break;
 
-                          case 10:
-                            _context3.next = 12;
+                          case 9:
+                            _context3.next = 11;
                             return this.fetchComponent(route).then(function(
                               res
                             ) {
@@ -2499,17 +2530,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               };
                             });
 
-                          case 12:
+                          case 11:
                             _context3.t0 = _context3.sent;
 
-                          case 13:
+                          case 12:
                             routeInfo = _context3.t0;
                             (Component = routeInfo.Component),
                               (__N_SSG = routeInfo.__N_SSG),
                               (__N_SSP = routeInfo.__N_SSP);
 
                             if (true) {
-                              _context3.next = 19;
+                              _context3.next = 18;
                               break;
                             }
 
@@ -2526,7 +2557,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                 _require.isValidElementType);
 
                             if (isValidElementType(Component)) {
-                              _context3.next = 19;
+                              _context3.next = 18;
                               break;
                             }
 
@@ -2537,7 +2568,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               )
                             );
 
-                          case 19:
+                          case 18:
                             if (__N_SSG || __N_SSP) {
                               dataHref = this.pageLoader.getDataHref(
                                 (0, _utils.formatWithValidation)({
@@ -2550,7 +2581,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               );
                             }
 
-                            _context3.next = 22;
+                            _context3.next = 21;
                             return this._getData(function() {
                               return __N_SSG
                                 ? _this3._getStaticData(dataHref)
@@ -2566,26 +2597,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                                   );
                             });
 
-                          case 22:
+                          case 21:
                             props = _context3.sent;
                             routeInfo.props = props;
                             this.components[route] = routeInfo;
                             return _context3.abrupt("return", routeInfo);
 
-                          case 28:
-                            _context3.prev = 28;
-                            _context3.t1 = _context3["catch"](1);
+                          case 27:
+                            _context3.prev = 27;
+                            _context3.t1 = _context3["catch"](0);
                             return _context3.abrupt(
                               "return",
                               this.handleRouteInfoError(
                                 _context3.t1,
                                 pathname,
                                 query,
-                                as
+                                as,
+                                routeProps
                               )
                             );
 
-                          case 31:
+                          case 30:
                           case "end":
                             return _context3.stop();
                         }
@@ -2593,12 +2625,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     },
                     _callee3,
                     this,
-                    [[1, 28]]
+                    [[0, 27]]
                   );
                 })
               );
 
-              function getRouteInfo(_x10, _x11, _x12, _x13) {
+              function getRouteInfo(_x11, _x12, _x13, _x14, _x15) {
                 return _getRouteInfo.apply(this, arguments);
               }
 
@@ -2835,7 +2867,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function prefetch(_x14) {
+              function prefetch(_x16) {
                 return _prefetch.apply(this, arguments);
               }
 
@@ -2900,7 +2932,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function fetchComponent(_x15) {
+              function fetchComponent(_x17) {
                 return _fetchComponent.apply(this, arguments);
               }
 
@@ -2976,12 +3008,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           },
           {
             key: "abortComponentLoad",
-            value: function abortComponentLoad(as) {
+            value: function abortComponentLoad(as, routeProps) {
               if (this.clc) {
                 Router.events.emit(
                   "routeChangeError",
                   buildCancellationError(),
-                  as
+                  as,
+                  routeProps
                 );
                 this.clc();
                 this.clc = null;
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9ed8924e51126d0f2923.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.b5bce6917aaa0be5398c.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9ed8924e51126d0f2923.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.b5bce6917aaa0be5398c.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9ed8924e51126d0f2923.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.b5bce6917aaa0be5398c.js"
       as="script"
     />
     <link
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9ed8924e51126d0f2923.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.b5bce6917aaa0be5398c.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9ed8924e51126d0f2923.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.b5bce6917aaa0be5398c.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.9ed8924e51126d0f2923.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.b5bce6917aaa0be5398c.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
buildDuration 9.9s 10s ⚠️ +70ms
nodeModulesSize 82.4 MB 82.4 MB ⚠️ +932 B
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary bragle/next.js canary Change
677f882d2ed8..0679.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-086d1b7..8537.js gzip 6.56 kB 6.56 kB
webpack-95c2..e870.js gzip 751 B 751 B
677f882d2ed8..5e70.js gzip N/A 12.8 kB N/A
Overall change 59.1 kB 59 kB -7 B
Legacy Client Bundles (polyfills)
vercel/next.js canary bragle/next.js canary Change
polyfills-d3..23f6.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary bragle/next.js canary Change
_app-0d19cb6..5497.js gzip 1.28 kB 1.28 kB
_error-2cf0e..a0a0.js gzip 3.69 kB 3.69 kB
hooks-42456f..0c06.js gzip 887 B 887 B
index-8081ce..e44f.js gzip 227 B 227 B
link-0ab9f83..fa00.js gzip 1.61 kB 1.61 kB
routerDirect..c3d8.js gzip 303 B 303 B
withRouter-0..a68e.js gzip 302 B 302 B
Overall change 8.31 kB 8.31 kB
Client Build Manifests
vercel/next.js canary bragle/next.js canary Change
_buildManifest.js gzip 323 B 323 B
Overall change 323 B 323 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary bragle/next.js canary Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB ⚠️ +212 B
routerDirect.js 1.05 MB 1.05 MB ⚠️ +212 B
withRouter.js 1.05 MB 1.05 MB ⚠️ +212 B
Overall change 5.16 MB 5.16 MB ⚠️ +636 B
Commit: 29cd05b

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 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.

None yet

4 participants