Skip to content

Commit

Permalink
v12.1.3-canary.4
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Mar 30, 2022
1 parent 7b3ec57 commit bb918fd
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.1.3-canary.3"
"version": "12.1.3-canary.4"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "12.1.3-canary.3",
"@next/eslint-plugin-next": "12.1.3-canary.4",
"@rushstack/eslint-patch": "1.0.8",
"@typescript-eslint/parser": "5.10.1",
"eslint-import-resolver-node": "0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"private": true,
"scripts": {
"build-native": "napi build --platform --cargo-name next_swc_napi native",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -69,7 +69,7 @@
]
},
"dependencies": {
"@next/env": "12.1.3-canary.3",
"@next/env": "12.1.3-canary.4",
"caniuse-lite": "^1.0.30001283",
"postcss": "8.4.5",
"styled-jsx": "5.0.1"
Expand Down Expand Up @@ -117,11 +117,11 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.4.4",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "12.1.3-canary.3",
"@next/polyfill-nomodule": "12.1.3-canary.3",
"@next/react-dev-overlay": "12.1.3-canary.3",
"@next/react-refresh-utils": "12.1.3-canary.3",
"@next/swc": "12.1.3-canary.3",
"@next/polyfill-module": "12.1.3-canary.4",
"@next/polyfill-nomodule": "12.1.3-canary.4",
"@next/react-dev-overlay": "12.1.3-canary.4",
"@next/react-refresh-utils": "12.1.3-canary.4",
"@next/swc": "12.1.3-canary.4",
"@peculiar/webcrypto": "1.3.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "12.1.3-canary.3",
"version": "12.1.3-canary.4",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down

1 comment on commit bb918fd

@ijjk
Copy link
Member

@ijjk ijjk commented on bb918fd Mar 30, 2022

Choose a reason for hiding this comment

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

Stats from current release

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
buildDuration 18.2s 19s ⚠️ +720ms
buildDurationCached 6.9s 7.6s ⚠️ +620ms
nodeModulesSize 467 MB 467 MB ⚠️ +10.9 kB
Page Load Tests Overall increase ✓
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
/ failed reqs 0 0
/ total time (seconds) 3.955 4.03 ⚠️ +0.08
/ avg req/sec 632.16 620.42 ⚠️ -11.74
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 2.003 1.98 -0.02
/error-in-render avg req/sec 1248.06 1262.64 +14.58
Client Bundles (main, webpack) Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
925.HASH.js gzip 179 B 179 B
framework-HASH.js gzip 42 kB 42 kB
main-HASH.js gzip 27.9 kB 28.4 kB ⚠️ +497 B
webpack-HASH.js gzip 1.44 kB 1.44 kB
Overall change 71.6 kB 72.1 kB ⚠️ +497 B
Legacy Client Bundles (polyfills)
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
_app-HASH.js gzip 1.36 kB 1.36 kB
_error-HASH.js gzip 192 B 192 B
amp-HASH.js gzip 309 B 309 B
css-HASH.js gzip 327 B 327 B
dynamic-HASH.js gzip 2.57 kB 3.05 kB ⚠️ +476 B
head-HASH.js gzip 351 B 351 B
hooks-HASH.js gzip 920 B 920 B
image-HASH.js gzip 5.48 kB 5.48 kB
index-HASH.js gzip 263 B 263 B
link-HASH.js gzip 2.26 kB 2.26 kB
routerDirect..HASH.js gzip 320 B 320 B
script-HASH.js gzip 387 B 387 B
withRouter-HASH.js gzip 319 B 319 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 15.2 kB 15.7 kB ⚠️ +476 B
Client Build Manifests
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
_buildManifest.js gzip 460 B 460 B
Overall change 460 B 460 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
index.html gzip 532 B 531 B -1 B
link.html gzip 545 B 545 B
withRouter.html gzip 525 B 525 B
Overall change 1.6 kB 1.6 kB -1 B

Diffs

Diff for _buildManifest.js
@@ -8,7 +8,7 @@ self.__BUILD_MANIFEST = {
     "static\u002Fchunks\u002Fpages\u002Fcss-16a755ee71604f2b.js"
   ],
   "/dynamic": [
-    "static\u002Fchunks\u002Fpages\u002Fdynamic-84f8d81080673359.js"
+    "static\u002Fchunks\u002Fpages\u002Fdynamic-db84c8a4bbee83c6.js"
   ],
   "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-96a5d6ed07cf5a83.js"],
   "/hooks": ["static\u002Fchunks\u002Fpages\u002Fhooks-9dfe734f583d4926.js"],
Diff for dynamic-HASH.js
@@ -253,7 +253,7 @@
       });
       exports["default"] = void 0;
       var _react = _interopRequireDefault(__webpack_require__(7294));
-      var _useSubscription = __webpack_require__(7161);
+      var _useSubscription = __webpack_require__(2021);
       var _loadableContext = __webpack_require__(3644);
       function _interopRequireDefault(obj) {
         return obj && obj.__esModule
@@ -627,85 +627,195 @@
       /***/
     },
 
-    /***/ 5152: /***/ function(
+    /***/ 2021: /***/ function(
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) {
-      module.exports = __webpack_require__(7645);
-
-      /***/
-    },
-
-    /***/ 8217: /***/ function(
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) {
-      "use strict";
-      /** @license React vundefined
-       * use-subscription.production.min.js
-       *
-       * Copyright (c) Facebook, Inc. and its affiliates.
-       *
-       * This source code is licensed under the MIT license found in the
-       * LICENSE file in the root directory of this source tree.
-       */
-      var e = __webpack_require__(6086),
-        g = __webpack_require__(7294);
-      exports.useSubscription = function(a) {
-        var c = a.getCurrentValue,
-          d = a.subscribe,
-          b = g.useState(function() {
-            return { getCurrentValue: c, subscribe: d, value: c() };
-          });
-        a = b[0];
-        var f = b[1];
-        b = a.value;
-        if (a.getCurrentValue !== c || a.subscribe !== d)
-          (b = c()), f({ getCurrentValue: c, subscribe: d, value: b });
-        g.useDebugValue(b);
-        g.useEffect(
-          function() {
-            function b() {
-              if (!a) {
-                var b = c();
-                f(function(a) {
-                  return a.getCurrentValue !== c ||
-                    a.subscribe !== d ||
-                    a.value === b
-                    ? a
-                    : e({}, a, { value: b });
+      var __dirname = "/";
+      (() => {
+        "use strict";
+        var e = {
+          800: e => {
+            /*
+object-assign
+(c) Sindre Sorhus
+@license MIT
+*/
+            var r = Object.getOwnPropertySymbols;
+            var t = Object.prototype.hasOwnProperty;
+            var u = Object.prototype.propertyIsEnumerable;
+            function toObject(e) {
+              if (e === null || e === undefined) {
+                throw new TypeError(
+                  "Object.assign cannot be called with null or undefined"
+                );
+              }
+              return Object(e);
+            }
+            function shouldUseNative() {
+              try {
+                if (!Object.assign) {
+                  return false;
+                }
+                var e = new String("abc");
+                e[5] = "de";
+                if (Object.getOwnPropertyNames(e)[0] === "5") {
+                  return false;
+                }
+                var r = {};
+                for (var t = 0; t < 10; t++) {
+                  r["_" + String.fromCharCode(t)] = t;
+                }
+                var u = Object.getOwnPropertyNames(r).map(function(e) {
+                  return r[e];
                 });
+                if (u.join("") !== "0123456789") {
+                  return false;
+                }
+                var n = {};
+                "abcdefghijklmnopqrst".split("").forEach(function(e) {
+                  n[e] = e;
+                });
+                if (
+                  Object.keys(Object.assign({}, n)).join("") !==
+                  "abcdefghijklmnopqrst"
+                ) {
+                  return false;
+                }
+                return true;
+              } catch (e) {
+                return false;
               }
             }
-            var a = !1,
-              h = d(b);
-            b();
-            return function() {
-              a = !0;
-              h();
+            e.exports = shouldUseNative()
+              ? Object.assign
+              : function(e, n) {
+                  var a;
+                  var i = toObject(e);
+                  var s;
+                  for (var c = 1; c < arguments.length; c++) {
+                    a = Object(arguments[c]);
+                    for (var o in a) {
+                      if (t.call(a, o)) {
+                        i[o] = a[o];
+                      }
+                    }
+                    if (r) {
+                      s = r(a);
+                      for (var f = 0; f < s.length; f++) {
+                        if (u.call(a, s[f])) {
+                          i[s[f]] = a[s[f]];
+                        }
+                      }
+                    }
+                  }
+                  return i;
+                };
+          },
+          569: (e, r, t) => {
+            /** @license React vundefined
+             * use-subscription.development.js
+             *
+             * Copyright (c) Facebook, Inc. and its affiliates.
+             *
+             * This source code is licensed under the MIT license found in the
+             * LICENSE file in the root directory of this source tree.
+             */
+            if (false) {
+            }
+          },
+          403: (e, r, t) => {
+            /** @license React vundefined
+             * use-subscription.production.min.js
+             *
+             * Copyright (c) Facebook, Inc. and its affiliates.
+             *
+             * This source code is licensed under the MIT license found in the
+             * LICENSE file in the root directory of this source tree.
+             */
+            var u = t(800),
+              n = t(522);
+            r.useSubscription = function(e) {
+              var r = e.getCurrentValue,
+                t = e.subscribe,
+                a = n.useState(function() {
+                  return { getCurrentValue: r, subscribe: t, value: r() };
+                });
+              e = a[0];
+              var i = a[1];
+              a = e.value;
+              if (e.getCurrentValue !== r || e.subscribe !== t)
+                (a = r()), i({ getCurrentValue: r, subscribe: t, value: a });
+              n.useDebugValue(a);
+              n.useEffect(
+                function() {
+                  function b() {
+                    if (!e) {
+                      var n = r();
+                      i(function(e) {
+                        return e.getCurrentValue !== r ||
+                          e.subscribe !== t ||
+                          e.value === n
+                          ? e
+                          : u({}, e, { value: n });
+                      });
+                    }
+                  }
+                  var e = !1,
+                    n = t(b);
+                  b();
+                  return function() {
+                    e = !0;
+                    n();
+                  };
+                },
+                [r, t]
+              );
+              return a;
             };
           },
-          [c, d]
-        );
-        return b;
-      };
+          138: (e, r, t) => {
+            if (true) {
+              e.exports = t(403);
+            } else {
+            }
+          },
+          522: e => {
+            e.exports = __webpack_require__(7294);
+          }
+        };
+        var r = {};
+        function __nccwpck_require__(t) {
+          var u = r[t];
+          if (u !== undefined) {
+            return u.exports;
+          }
+          var n = (r[t] = { exports: {} });
+          var a = true;
+          try {
+            e[t](n, n.exports, __nccwpck_require__);
+            a = false;
+          } finally {
+            if (a) delete r[t];
+          }
+          return n.exports;
+        }
+        if (typeof __nccwpck_require__ !== "undefined")
+          __nccwpck_require__.ab = __dirname + "/";
+        var t = __nccwpck_require__(138);
+        module.exports = t;
+      })();
 
       /***/
     },
 
-    /***/ 7161: /***/ function(
+    /***/ 5152: /***/ function(
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) {
-      "use strict";
-
-      if (true) {
-        module.exports = __webpack_require__(8217);
-      } else {
-      }
+      module.exports = __webpack_require__(7645);
 
       /***/
     }
Diff for main-HASH.js
@@ -473,7 +473,7 @@
       var _routeAnnouncer = __webpack_require__(8483);
       var _router1 = __webpack_require__(880);
       var _isError = __webpack_require__(676);
-      var _vitals = __webpack_require__(7185);
+      var _vitals = __webpack_require__(4564);
       var _refresh = __webpack_require__(2129);
       var _imageConfigContext = __webpack_require__(8730);
       function asyncGeneratorStep(
@@ -624,7 +624,7 @@
         }
         return target;
       }
-      var version = "12.1.2";
+      var version = "12.1.3-canary.4";
       exports.version = version;
       var router;
       exports.router = router;
@@ -3197,7 +3197,7 @@
       /***/
     },
 
-    /***/ 7185: /***/ function(
+    /***/ 4564: /***/ function(
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -4351,8 +4351,8 @@
       var _resolveRewrites = _interopRequireDefault1(__webpack_require__(2431));
       var _routeMatcher = __webpack_require__(3156);
       var _routeRegex = __webpack_require__(4903);
-      var _getMiddlewareRegex = __webpack_require__(3072);
       var _formatUrl = __webpack_require__(7795);
+      var _routingItems = __webpack_require__(7185);
       function _interopRequireDefault1(obj) {
         return obj && obj.__esModule
           ? obj
@@ -6378,8 +6378,16 @@
                 _runtimeJs.default.mark(function _callee() {
                   var asPathname,
                     cleanedAs,
-                    fns,
+                    middlewareList,
+                    middleware,
+                    routingItems,
                     requiresPreflight,
+                    _iteratorNormalCompletion,
+                    _didIteratorError,
+                    _iteratorError,
+                    _iterator,
+                    _step,
+                    item,
                     preflight,
                     parsed,
                     fsPathname,
@@ -6404,58 +6412,116 @@
                             _ctx.next = 4;
                             return _this.pageLoader.getMiddlewareList();
                           case 4:
-                            fns = _ctx.sent;
-                            requiresPreflight = fns.some(function(param) {
+                            middlewareList = _ctx.sent;
+                            middleware = middlewareList.map(function(param) {
                               var _param = _slicedToArray(param, 2),
-                                middleware = _param[0],
-                                isSSR = _param[1];
-                              return (0, _routeMatcher).getRouteMatcher(
-                                (0, _getMiddlewareRegex).getMiddlewareRegex(
-                                  middleware,
-                                  !isSSR
-                                )
-                              )(cleanedAs);
+                                page = _param[0],
+                                ssr = _param[1];
+                              return {
+                                page: page,
+                                ssr: ssr
+                              };
                             });
+                            routingItems = (0, _routingItems).getRoutingItems(
+                              options.pages,
+                              middleware
+                            );
+                            requiresPreflight = false;
+                            (_iteratorNormalCompletion = true),
+                              (_didIteratorError = false),
+                              (_iteratorError = undefined);
+                            _ctx.prev = 9;
+                            _iterator = routingItems[Symbol.iterator]();
+                          case 11:
+                            if (
+                              (_iteratorNormalCompletion = (_step = _iterator.next())
+                                .done)
+                            ) {
+                              _ctx.next = 19;
+                              break;
+                            }
+                            item = _step.value;
+                            if (!item.match(cleanedAs)) {
+                              _ctx.next = 16;
+                              break;
+                            }
+                            if (item.isMiddleware) {
+                              requiresPreflight = true;
+                            }
+                            return _ctx.abrupt("break", 19);
+                          case 16:
+                            _iteratorNormalCompletion = true;
+                            _ctx.next = 11;
+                            break;
+                          case 19:
+                            _ctx.next = 25;
+                            break;
+                          case 21:
+                            _ctx.prev = 21;
+                            _ctx.t0 = _ctx["catch"](9);
+                            _didIteratorError = true;
+                            _iteratorError = _ctx.t0;
+                          case 25:
+                            _ctx.prev = 25;
+                            _ctx.prev = 26;
+                            if (
+                              !_iteratorNormalCompletion &&
+                              _iterator.return != null
+                            ) {
+                              _iterator.return();
+                            }
+                          case 28:
+                            _ctx.prev = 28;
+                            if (!_didIteratorError) {
+                              _ctx.next = 31;
+                              break;
+                            }
+                            throw _iteratorError;
+                          case 31:
+                            return _ctx.finish(28);
+                          case 32:
+                            return _ctx.finish(25);
+                          case 33:
                             if (requiresPreflight) {
-                              _ctx.next = 8;
+                              _ctx.next = 35;
                               break;
                             }
                             return _ctx.abrupt("return", {
                               type: "next"
                             });
-                          case 8:
-                            _ctx.prev = 9;
-                            _ctx.next = 12;
+                          case 35:
+                            _ctx.prev = 36;
+                            _ctx.next = 39;
                             return _this._getPreflightData({
                               preflightHref: options.as,
                               shouldCache: options.cache,
                               isPreview: options.isPreview
                             });
-                          case 12:
+                          case 39:
                             preflight = _ctx.sent;
-                            _ctx.next = 18;
+                            _ctx.next = 45;
                             break;
-                          case 15:
-                            _ctx.prev = 15;
-                            _ctx.t0 = _ctx["catch"](9);
+                          case 42:
+                            _ctx.prev = 42;
+                            _ctx.t1 = _ctx["catch"](36);
                             return _ctx.abrupt("return", {
                               type: "redirect",
                               destination: options.as
                             });
-                          case 18:
+                          case 45:
                             if (!preflight.rewrite) {
-                              _ctx.next = 27;
+                              _ctx.next = 54;
                               break;
                             }
                             if (preflight.rewrite.startsWith("/")) {
-                              _ctx.next = 21;
+                              _ctx.next = 48;
                               break;
                             }
                             return _ctx.abrupt("return", {
                               type: "redirect",
                               destination: options.as
                             });
-                          case 21:
+                          case 48:
                             parsed = (0, _parseRelativeUrl).parseRelativeUrl(
                               (0, _normalizeLocalePath).normalizeLocalePath(
                                 hasBasePath(preflight.rewrite)
@@ -6490,13 +6556,13 @@
                               matchedPage: matchedPage,
                               resolvedHref: resolvedHref
                             });
-                          case 27:
+                          case 54:
                             if (!preflight.redirect) {
-                              _ctx.next = 33;
+                              _ctx.next = 60;
                               break;
                             }
                             if (!preflight.redirect.startsWith("/")) {
-                              _ctx.next = 32;
+                              _ctx.next = 59;
                               break;
                             }
                             cleanRedirect = (0,
@@ -6520,31 +6586,35 @@
                               newUrl: newUrl,
                               newAs: newAs
                             });
-                          case 32:
+                          case 59:
                             return _ctx.abrupt("return", {
                               type: "redirect",
                               destination: preflight.redirect
                             });
-                          case 33:
+                          case 60:
                             if (!(preflight.refresh && !preflight.ssr)) {
-                              _ctx.next = 35;
+                              _ctx.next = 62;
                               break;
                             }
                             return _ctx.abrupt("return", {
                               type: "refresh"
                             });
-                          case 35:
+                          case 62:
                             return _ctx.abrupt("return", {
                               type: "next"
                             });
-                          case 36:
+                          case 63:
                           case "end":
                             return _ctx.stop();
                         }
                     },
                     _callee,
                     null,
-                    [[9, 15]]
+                    [
+                      [9, 21, 25, 33],
+                      [26, , 28, 32],
+                      [36, 42]
+                    ]
                   );
                 })
               )();
@@ -6816,11 +6886,17 @@
       });
       exports.getMiddlewareRegex = getMiddlewareRegex;
       var _routeRegex = __webpack_require__(4903);
+      // Identify ^/[param]/ in route string
+      var FIRST_SEGMENT_DYNAMIC = /^\/\[[^/]+?\](?=\/|$)/;
+      var NOT_API_ROUTE = "(?!/api(?:/|$))";
       function getMiddlewareRegex(normalizedRoute) {
         var catchAll =
           arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
         var result = (0, _routeRegex).getParametrizedRoute(normalizedRoute);
-        var catchAllRegex = catchAll ? "(?!_next).*" : "";
+        var notApiRegex = FIRST_SEGMENT_DYNAMIC.test(normalizedRoute)
+          ? NOT_API_ROUTE
+          : "";
+        var catchAllRegex = catchAll ? "(?!_next($|/)).*" : "";
         var catchAllGroupedRegex = catchAll ? "(?:(/.*)?)" : "";
         if ("routeKeys" in result) {
           if (result.parameterizedRoute === "/") {
@@ -6834,10 +6910,12 @@
           return {
             groups: result.groups,
             namedRegex: "^"
+              .concat(notApiRegex)
               .concat(result.namedParameterizedRoute)
               .concat(catchAllGroupedRegex, "$"),
             re: new RegExp(
               "^"
+                .concat(notApiRegex)
                 .concat(result.parameterizedRoute)
                 .concat(catchAllGroupedRegex, "$")
             ),
@@ -6854,6 +6932,7 @@
           groups: {},
           re: new RegExp(
             "^"
+              .concat(notApiRegex)
               .concat(result.parameterizedRoute)
               .concat(catchAllGroupedRegex, "$")
           )
@@ -6891,6 +6970,18 @@
           return _routeRegex.getRouteRegex;
         }
       });
+      Object.defineProperty(exports, "getRoutingItems", {
+        enumerable: true,
+        get: function get() {
+          return _routingItems.getRoutingItems;
+        }
+      });
+      Object.defineProperty(exports, "RoutingItem", {
+        enumerable: true,
+        get: function get() {
+          return _routingItems.RoutingItem;
+        }
+      });
       Object.defineProperty(exports, "getSortedRoutes", {
         enumerable: true,
         get: function get() {
@@ -6906,6 +6997,7 @@
       var _getMiddlewareRegex = __webpack_require__(3072);
       var _routeMatcher = __webpack_require__(3156);
       var _routeRegex = __webpack_require__(4903);
+      var _routingItems = __webpack_require__(7185);
       var _sortedRoutes = __webpack_require__(566);
       var _isDynamic = __webpack_require__(6238); //# sourceMappingURL=index.js.map
 
@@ -7237,6 +7329,101 @@
       /***/
     },
 
+    /***/ 7185: /***/ function(
+      __unused_webpack_module,
+      exports,
+      __webpack_require__
+    ) {
+      "use strict";
+
+      function _arrayLikeToArray(arr, len) {
+        if (len == null || len > arr.length) len = arr.length;
+        for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+        return arr2;
+      }
+      function _arrayWithoutHoles(arr) {
+        if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+      }
+      function _iterableToArray(iter) {
+        if (
+          (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null) ||
+          iter["@@iterator"] != null
+        )
+          return Array.from(iter);
+      }
+      function _nonIterableSpread() {
+        throw new TypeError(
+          "Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
+        );
+      }
+      function _toConsumableArray(arr) {
+        return (
+          _arrayWithoutHoles(arr) ||
+          _iterableToArray(arr) ||
+          _unsupportedIterableToArray(arr) ||
+          _nonIterableSpread()
+        );
+      }
+      function _unsupportedIterableToArray(o, minLen) {
+        if (!o) return;
+        if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+        var n = Object.prototype.toString.call(o).slice(8, -1);
+        if (n === "Object" && o.constructor) n = o.constructor.name;
+        if (n === "Map" || n === "Set") return Array.from(n);
+        if (
+          n === "Arguments" ||
+          /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)
+        )
+          return _arrayLikeToArray(o, minLen);
+      }
+      Object.defineProperty(exports, "__esModule", {
+        value: true
+      });
+      exports.getRoutingItems = getRoutingItems;
+      var _getMiddlewareRegex = __webpack_require__(3072);
+      var _routeMatcher = __webpack_require__(3156);
+      var _routeRegex = __webpack_require__(4903);
+      var _sortedRoutes = __webpack_require__(566);
+      var MIDDLEWARE_SUFFIX = "/_middleware";
+      function getRoutingItems(pages, middleware) {
+        // append the suffix so that `getSortedRoutes()` can handle middleware properly
+        var middlewarePages = middleware.map(function(m) {
+          return "".concat(m.page).concat(MIDDLEWARE_SUFFIX);
+        });
+        var middlewareMap = new Map(
+          middleware.map(function(m) {
+            return [m.page, m];
+          })
+        );
+        var sortedRoutes = (0, _sortedRoutes).getSortedRoutes(
+          _toConsumableArray(pages).concat(_toConsumableArray(middlewarePages))
+        );
+        return sortedRoutes.map(function(page) {
+          if (page.endsWith(MIDDLEWARE_SUFFIX)) {
+            var p = page.slice(0, -MIDDLEWARE_SUFFIX.length) || "/";
+            var ssr = middlewareMap.get(p).ssr;
+            return {
+              match: (0, _routeMatcher).getRouteMatcher(
+                (0, _getMiddlewareRegex).getMiddlewareRegex(p, !ssr)
+              ),
+              page: p,
+              ssr: ssr,
+              isMiddleware: true
+            };
+          } else {
+            return {
+              match: (0, _routeMatcher).getRouteMatcher(
+                (0, _routeRegex).getRouteRegex(page)
+              ),
+              page: page
+            };
+          }
+        });
+      } //# sourceMappingURL=routing-items.js.map
+
+      /***/
+    },
+
     /***/ 566: /***/ function(__unused_webpack_module, exports) {
       "use strict";
 
@@ -7311,6 +7498,7 @@
           this.slugName = null;
           this.restSlugName = null;
           this.optionalRestSlugName = null;
+          this.isMiddleware = false;
         }
         _createClass(UrlNode, [
           {
@@ -7345,6 +7533,9 @@
               if (this.optionalRestSlugName !== null) {
                 childrenPaths.splice(childrenPaths.indexOf("[[...]]"), 1);
               }
+              if (this.isMiddleware) {
+                childrenPaths.splice(childrenPaths.indexOf("_middleware"), 1);
+              }
               var routes = childrenPaths
                 .map(function(c) {
                   return _this.children
@@ -7381,10 +7572,21 @@
                 }
                 routes.unshift(r);
               }
-              if (this.restSlugName !== null) {
+              if (this.isMiddleware) {
                 var _routes1;
-                (_routes1 = routes).push.apply(
+                (_routes1 = routes).unshift.apply(
                   _routes1,
+                  _toConsumableArray(
+                    this.children
+                      .get("_middleware")
+                      ._smoosh("".concat(prefix, "_middleware/"))
+                  )
+                );
+              }
+              if (this.restSlugName !== null) {
+                var _routes2;
+                (_routes2 = routes).push.apply(
+                  _routes2,
                   _toConsumableArray(
                     this.children
                       .get("[...]")
@@ -7397,9 +7599,9 @@
                 );
               }
               if (this.optionalRestSlugName !== null) {
-                var _routes2;
-                (_routes2 = routes).push.apply(
-                  _routes2,
+                var _routes3;
+                (_routes3 = routes).push.apply(
+                  _routes3,
                   _toConsumableArray(
                     this.children
                       .get("[[...]]")
@@ -7540,6 +7742,11 @@
                   // nextSegment is overwritten to [] so that it can later be sorted specifically
                   nextSegment = "[]";
                 }
+              } else if (
+                nextSegment === "_middleware" &&
+                urlPaths.length === 1
+              ) {
+                this.isMiddleware = true;
               }
               // If this UrlNode doesn't have the nextSegment yet we create a new child UrlNode
               if (!this.children.has(nextSegment)) {
Diff for index.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-31e3f2e995c2cb43.js"
+      src="/_next/static/chunks/main-ab56f791707d19d6.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-31e3f2e995c2cb43.js"
+      src="/_next/static/chunks/main-ab56f791707d19d6.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-31e3f2e995c2cb43.js"
+      src="/_next/static/chunks/main-ab56f791707d19d6.js"
       defer=""
     ></script>
     <script

Default Build with SWC (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
buildDuration 22.3s 23.3s ⚠️ +1s
buildDurationCached 7.5s 8.1s ⚠️ +630ms
nodeModulesSize 467 MB 467 MB ⚠️ +10.9 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
/ failed reqs 0 0
/ total time (seconds) 3.991 4.302 ⚠️ +0.31
/ avg req/sec 626.35 581.13 ⚠️ -45.22
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 2.004 2.063 ⚠️ +0.06
/error-in-render avg req/sec 1247.6 1211.79 ⚠️ -35.81
Client Bundles (main, webpack) Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
925.HASH.js gzip 178 B 178 B
framework-HASH.js gzip 42.3 kB 42.3 kB
main-HASH.js gzip 28.2 kB 28.8 kB ⚠️ +537 B
webpack-HASH.js gzip 1.45 kB 1.45 kB
Overall change 72.1 kB 72.7 kB ⚠️ +537 B
Legacy Client Bundles (polyfills)
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
_app-HASH.js gzip 1.35 kB 1.35 kB
_error-HASH.js gzip 179 B 179 B
amp-HASH.js gzip 313 B 313 B
css-HASH.js gzip 324 B 324 B
dynamic-HASH.js gzip 2.56 kB 3.04 kB ⚠️ +477 B
head-HASH.js gzip 351 B 351 B
hooks-HASH.js gzip 921 B 921 B
image-HASH.js gzip 5.59 kB 5.59 kB
index-HASH.js gzip 261 B 261 B
link-HASH.js gzip 2.33 kB 2.33 kB
routerDirect..HASH.js gzip 322 B 322 B
script-HASH.js gzip 388 B 388 B
withRouter-HASH.js gzip 317 B 317 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 15.3 kB 15.8 kB ⚠️ +477 B
Client Build Manifests Overall increase ⚠️
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
_buildManifest.js gzip 458 B 459 B ⚠️ +1 B
Overall change 458 B 459 B ⚠️ +1 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary v12.1.2 vercel/next.js refs/heads/canary Change
index.html gzip 532 B 530 B -2 B
link.html gzip 547 B 544 B -3 B
withRouter.html gzip 528 B 526 B -2 B
Overall change 1.61 kB 1.6 kB -7 B

Diffs

Diff for _buildManifest.js
@@ -8,7 +8,7 @@ self.__BUILD_MANIFEST = {
     "static\u002Fchunks\u002Fpages\u002Fcss-16a755ee71604f2b.js"
   ],
   "/dynamic": [
-    "static\u002Fchunks\u002Fpages\u002Fdynamic-84f8d81080673359.js"
+    "static\u002Fchunks\u002Fpages\u002Fdynamic-db84c8a4bbee83c6.js"
   ],
   "/head": ["static\u002Fchunks\u002Fpages\u002Fhead-96a5d6ed07cf5a83.js"],
   "/hooks": ["static\u002Fchunks\u002Fpages\u002Fhooks-9dfe734f583d4926.js"],
Diff for dynamic-HASH.js
@@ -253,7 +253,7 @@
       });
       exports["default"] = void 0;
       var _react = _interopRequireDefault(__webpack_require__(7294));
-      var _useSubscription = __webpack_require__(7161);
+      var _useSubscription = __webpack_require__(2021);
       var _loadableContext = __webpack_require__(3644);
       function _interopRequireDefault(obj) {
         return obj && obj.__esModule
@@ -627,85 +627,195 @@
       /***/
     },
 
-    /***/ 5152: /***/ function(
+    /***/ 2021: /***/ function(
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) {
-      module.exports = __webpack_require__(7645);
-
-      /***/
-    },
-
-    /***/ 8217: /***/ function(
-      __unused_webpack_module,
-      exports,
-      __webpack_require__
-    ) {
-      "use strict";
-      /** @license React vundefined
-       * use-subscription.production.min.js
-       *
-       * Copyright (c) Facebook, Inc. and its affiliates.
-       *
-       * This source code is licensed under the MIT license found in the
-       * LICENSE file in the root directory of this source tree.
-       */
-      var e = __webpack_require__(6086),
-        g = __webpack_require__(7294);
-      exports.useSubscription = function(a) {
-        var c = a.getCurrentValue,
-          d = a.subscribe,
-          b = g.useState(function() {
-            return { getCurrentValue: c, subscribe: d, value: c() };
-          });
-        a = b[0];
-        var f = b[1];
-        b = a.value;
-        if (a.getCurrentValue !== c || a.subscribe !== d)
-          (b = c()), f({ getCurrentValue: c, subscribe: d, value: b });
-        g.useDebugValue(b);
-        g.useEffect(
-          function() {
-            function b() {
-              if (!a) {
-                var b = c();
-                f(function(a) {
-                  return a.getCurrentValue !== c ||
-                    a.subscribe !== d ||
-                    a.value === b
-                    ? a
-                    : e({}, a, { value: b });
+      var __dirname = "/";
+      (() => {
+        "use strict";
+        var e = {
+          800: e => {
+            /*
+object-assign
+(c) Sindre Sorhus
+@license MIT
+*/
+            var r = Object.getOwnPropertySymbols;
+            var t = Object.prototype.hasOwnProperty;
+            var u = Object.prototype.propertyIsEnumerable;
+            function toObject(e) {
+              if (e === null || e === undefined) {
+                throw new TypeError(
+                  "Object.assign cannot be called with null or undefined"
+                );
+              }
+              return Object(e);
+            }
+            function shouldUseNative() {
+              try {
+                if (!Object.assign) {
+                  return false;
+                }
+                var e = new String("abc");
+                e[5] = "de";
+                if (Object.getOwnPropertyNames(e)[0] === "5") {
+                  return false;
+                }
+                var r = {};
+                for (var t = 0; t < 10; t++) {
+                  r["_" + String.fromCharCode(t)] = t;
+                }
+                var u = Object.getOwnPropertyNames(r).map(function(e) {
+                  return r[e];
                 });
+                if (u.join("") !== "0123456789") {
+                  return false;
+                }
+                var n = {};
+                "abcdefghijklmnopqrst".split("").forEach(function(e) {
+                  n[e] = e;
+                });
+                if (
+                  Object.keys(Object.assign({}, n)).join("") !==
+                  "abcdefghijklmnopqrst"
+                ) {
+                  return false;
+                }
+                return true;
+              } catch (e) {
+                return false;
               }
             }
-            var a = !1,
-              h = d(b);
-            b();
-            return function() {
-              a = !0;
-              h();
+            e.exports = shouldUseNative()
+              ? Object.assign
+              : function(e, n) {
+                  var a;
+                  var i = toObject(e);
+                  var s;
+                  for (var c = 1; c < arguments.length; c++) {
+                    a = Object(arguments[c]);
+                    for (var o in a) {
+                      if (t.call(a, o)) {
+                        i[o] = a[o];
+                      }
+                    }
+                    if (r) {
+                      s = r(a);
+                      for (var f = 0; f < s.length; f++) {
+                        if (u.call(a, s[f])) {
+                          i[s[f]] = a[s[f]];
+                        }
+                      }
+                    }
+                  }
+                  return i;
+                };
+          },
+          569: (e, r, t) => {
+            /** @license React vundefined
+             * use-subscription.development.js
+             *
+             * Copyright (c) Facebook, Inc. and its affiliates.
+             *
+             * This source code is licensed under the MIT license found in the
+             * LICENSE file in the root directory of this source tree.
+             */
+            if (false) {
+            }
+          },
+          403: (e, r, t) => {
+            /** @license React vundefined
+             * use-subscription.production.min.js
+             *
+             * Copyright (c) Facebook, Inc. and its affiliates.
+             *
+             * This source code is licensed under the MIT license found in the
+             * LICENSE file in the root directory of this source tree.
+             */
+            var u = t(800),
+              n = t(522);
+            r.useSubscription = function(e) {
+              var r = e.getCurrentValue,
+                t = e.subscribe,
+                a = n.useState(function() {
+                  return { getCurrentValue: r, subscribe: t, value: r() };
+                });
+              e = a[0];
+              var i = a[1];
+              a = e.value;
+              if (e.getCurrentValue !== r || e.subscribe !== t)
+                (a = r()), i({ getCurrentValue: r, subscribe: t, value: a });
+              n.useDebugValue(a);
+              n.useEffect(
+                function() {
+                  function b() {
+                    if (!e) {
+                      var n = r();
+                      i(function(e) {
+                        return e.getCurrentValue !== r ||
+                          e.subscribe !== t ||
+                          e.value === n
+                          ? e
+                          : u({}, e, { value: n });
+                      });
+                    }
+                  }
+                  var e = !1,
+                    n = t(b);
+                  b();
+                  return function() {
+                    e = !0;
+                    n();
+                  };
+                },
+                [r, t]
+              );
+              return a;
             };
           },
-          [c, d]
-        );
-        return b;
-      };
+          138: (e, r, t) => {
+            if (true) {
+              e.exports = t(403);
+            } else {
+            }
+          },
+          522: e => {
+            e.exports = __webpack_require__(7294);
+          }
+        };
+        var r = {};
+        function __nccwpck_require__(t) {
+          var u = r[t];
+          if (u !== undefined) {
+            return u.exports;
+          }
+          var n = (r[t] = { exports: {} });
+          var a = true;
+          try {
+            e[t](n, n.exports, __nccwpck_require__);
+            a = false;
+          } finally {
+            if (a) delete r[t];
+          }
+          return n.exports;
+        }
+        if (typeof __nccwpck_require__ !== "undefined")
+          __nccwpck_require__.ab = __dirname + "/";
+        var t = __nccwpck_require__(138);
+        module.exports = t;
+      })();
 
       /***/
     },
 
-    /***/ 7161: /***/ function(
+    /***/ 5152: /***/ function(
       module,
       __unused_webpack_exports,
       __webpack_require__
     ) {
-      "use strict";
-
-      if (true) {
-        module.exports = __webpack_require__(8217);
-      } else {
-      }
+      module.exports = __webpack_require__(7645);
 
       /***/
     }
Diff for main-HASH.js
@@ -473,7 +473,7 @@
       var _routeAnnouncer = __webpack_require__(8483);
       var _router1 = __webpack_require__(880);
       var _isError = __webpack_require__(676);
-      var _vitals = __webpack_require__(7185);
+      var _vitals = __webpack_require__(4564);
       var _refresh = __webpack_require__(2129);
       var _imageConfigContext = __webpack_require__(8730);
       function asyncGeneratorStep(
@@ -624,7 +624,7 @@
         }
         return target;
       }
-      var version = "12.1.2";
+      var version = "12.1.3-canary.4";
       exports.version = version;
       var router;
       exports.router = router;
@@ -3197,7 +3197,7 @@
       /***/
     },
 
-    /***/ 7185: /***/ function(
+    /***/ 4564: /***/ function(
       __unused_webpack_module,
       exports,
       __webpack_require__
@@ -4351,8 +4351,8 @@
       var _resolveRewrites = _interopRequireDefault1(__webpack_require__(2431));
       var _routeMatcher = __webpack_require__(3156);
       var _routeRegex = __webpack_require__(4903);
-      var _getMiddlewareRegex = __webpack_require__(3072);
       var _formatUrl = __webpack_require__(7795);
+      var _routingItems = __webpack_require__(7185);
       function _interopRequireDefault1(obj) {
         return obj && obj.__esModule
           ? obj
@@ -6378,8 +6378,16 @@
                 _runtimeJs.default.mark(function _callee() {
                   var asPathname,
                     cleanedAs,
-                    fns,
+                    middlewareList,
+                    middleware,
+                    routingItems,
                     requiresPreflight,
+                    _iteratorNormalCompletion,
+                    _didIteratorError,
+                    _iteratorError,
+                    _iterator,
+                    _step,
+                    item,
                     preflight,
                     parsed,
                     fsPathname,
@@ -6404,58 +6412,116 @@
                             _ctx.next = 4;
                             return _this.pageLoader.getMiddlewareList();
                           case 4:
-                            fns = _ctx.sent;
-                            requiresPreflight = fns.some(function(param) {
+                            middlewareList = _ctx.sent;
+                            middleware = middlewareList.map(function(param) {
                               var _param = _slicedToArray(param, 2),
-                                middleware = _param[0],
-                                isSSR = _param[1];
-                              return (0, _routeMatcher).getRouteMatcher(
-                                (0, _getMiddlewareRegex).getMiddlewareRegex(
-                                  middleware,
-                                  !isSSR
-                                )
-                              )(cleanedAs);
+                                page = _param[0],
+                                ssr = _param[1];
+                              return {
+                                page: page,
+                                ssr: ssr
+                              };
                             });
+                            routingItems = (0, _routingItems).getRoutingItems(
+                              options.pages,
+                              middleware
+                            );
+                            requiresPreflight = false;
+                            (_iteratorNormalCompletion = true),
+                              (_didIteratorError = false),
+                              (_iteratorError = undefined);
+                            _ctx.prev = 9;
+                            _iterator = routingItems[Symbol.iterator]();
+                          case 11:
+                            if (
+                              (_iteratorNormalCompletion = (_step = _iterator.next())
+                                .done)
+                            ) {
+                              _ctx.next = 19;
+                              break;
+                            }
+                            item = _step.value;
+                            if (!item.match(cleanedAs)) {
+                              _ctx.next = 16;
+                              break;
+                            }
+                            if (item.isMiddleware) {
+                              requiresPreflight = true;
+                            }
+                            return _ctx.abrupt("break", 19);
+                          case 16:
+                            _iteratorNormalCompletion = true;
+                            _ctx.next = 11;
+                            break;
+                          case 19:
+                            _ctx.next = 25;
+                            break;
+                          case 21:
+                            _ctx.prev = 21;
+                            _ctx.t0 = _ctx["catch"](9);
+                            _didIteratorError = true;
+                            _iteratorError = _ctx.t0;
+                          case 25:
+                            _ctx.prev = 25;
+                            _ctx.prev = 26;
+                            if (
+                              !_iteratorNormalCompletion &&
+                              _iterator.return != null
+                            ) {
+                              _iterator.return();
+                            }
+                          case 28:
+                            _ctx.prev = 28;
+                            if (!_didIteratorError) {
+                              _ctx.next = 31;
+                              break;
+                            }
+                            throw _iteratorError;
+                          case 31:
+                            return _ctx.finish(28);
+                          case 32:
+                            return _ctx.finish(25);
+                          case 33:
                             if (requiresPreflight) {
-                              _ctx.next = 8;
+                              _ctx.next = 35;
                               break;
                             }
                             return _ctx.abrupt("return", {
                               type: "next"
                             });
-                          case 8:
-                            _ctx.prev = 9;
-                            _ctx.next = 12;
+                          case 35:
+                            _ctx.prev = 36;
+                            _ctx.next = 39;
                             return _this._getPreflightData({
                               preflightHref: options.as,
                               shouldCache: options.cache,
                               isPreview: options.isPreview
                             });
-                          case 12:
+                          case 39:
                             preflight = _ctx.sent;
-                            _ctx.next = 18;
+                            _ctx.next = 45;
                             break;
-                          case 15:
-                            _ctx.prev = 15;
-                            _ctx.t0 = _ctx["catch"](9);
+                          case 42:
+                            _ctx.prev = 42;
+                            _ctx.t1 = _ctx["catch"](36);
                             return _ctx.abrupt("return", {
                               type: "redirect",
                               destination: options.as
                             });
-                          case 18:
+                          case 45:
                             if (!preflight.rewrite) {
-                              _ctx.next = 27;
+                              _ctx.next = 54;
                               break;
                             }
                             if (preflight.rewrite.startsWith("/")) {
-                              _ctx.next = 21;
+                              _ctx.next = 48;
                               break;
                             }
                             return _ctx.abrupt("return", {
                               type: "redirect",
                               destination: options.as
                             });
-                          case 21:
+                          case 48:
                             parsed = (0, _parseRelativeUrl).parseRelativeUrl(
                               (0, _normalizeLocalePath).normalizeLocalePath(
                                 hasBasePath(preflight.rewrite)
@@ -6490,13 +6556,13 @@
                               matchedPage: matchedPage,
                               resolvedHref: resolvedHref
                             });
-                          case 27:
+                          case 54:
                             if (!preflight.redirect) {
-                              _ctx.next = 33;
+                              _ctx.next = 60;
                               break;
                             }
                             if (!preflight.redirect.startsWith("/")) {
-                              _ctx.next = 32;
+                              _ctx.next = 59;
                               break;
                             }
                             cleanRedirect = (0,
@@ -6520,31 +6586,35 @@
                               newUrl: newUrl,
                               newAs: newAs
                             });
-                          case 32:
+                          case 59:
                             return _ctx.abrupt("return", {
                               type: "redirect",
                               destination: preflight.redirect
                             });
-                          case 33:
+                          case 60:
                             if (!(preflight.refresh && !preflight.ssr)) {
-                              _ctx.next = 35;
+                              _ctx.next = 62;
                               break;
                             }
                             return _ctx.abrupt("return", {
                               type: "refresh"
                             });
-                          case 35:
+                          case 62:
                             return _ctx.abrupt("return", {
                               type: "next"
                             });
-                          case 36:
+                          case 63:
                           case "end":
                             return _ctx.stop();
                         }
                     },
                     _callee,
                     null,
-                    [[9, 15]]
+                    [
+                      [9, 21, 25, 33],
+                      [26, , 28, 32],
+                      [36, 42]
+                    ]
                   );
                 })
               )();
@@ -6816,11 +6886,17 @@
       });
       exports.getMiddlewareRegex = getMiddlewareRegex;
       var _routeRegex = __webpack_require__(4903);
+      // Identify ^/[param]/ in route string
+      var FIRST_SEGMENT_DYNAMIC = /^\/\[[^/]+?\](?=\/|$)/;
+      var NOT_API_ROUTE = "(?!/api(?:/|$))";
       function getMiddlewareRegex(normalizedRoute) {
         var catchAll =
           arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
         var result = (0, _routeRegex).getParametrizedRoute(normalizedRoute);
-        var catchAllRegex = catchAll ? "(?!_next).*" : "";
+        var notApiRegex = FIRST_SEGMENT_DYNAMIC.test(normalizedRoute)
+          ? NOT_API_ROUTE
+          : "";
+        var catchAllRegex = catchAll ? "(?!_next($|/)).*" : "";
         var catchAllGroupedRegex = catchAll ? "(?:(/.*)?)" : "";
         if ("routeKeys" in result) {
           if (result.parameterizedRoute === "/") {
@@ -6834,10 +6910,12 @@
           return {
             groups: result.groups,
             namedRegex: "^"
+              .concat(notApiRegex)
               .concat(result.namedParameterizedRoute)
               .concat(catchAllGroupedRegex, "$"),
             re: new RegExp(
               "^"
+                .concat(notApiRegex)
                 .concat(result.parameterizedRoute)
                 .concat(catchAllGroupedRegex, "$")
             ),
@@ -6854,6 +6932,7 @@
           groups: {},
           re: new RegExp(
             "^"
+              .concat(notApiRegex)
               .concat(result.parameterizedRoute)
               .concat(catchAllGroupedRegex, "$")
           )
@@ -6891,6 +6970,18 @@
           return _routeRegex.getRouteRegex;
         }
       });
+      Object.defineProperty(exports, "getRoutingItems", {
+        enumerable: true,
+        get: function get() {
+          return _routingItems.getRoutingItems;
+        }
+      });
+      Object.defineProperty(exports, "RoutingItem", {
+        enumerable: true,
+        get: function get() {
+          return _routingItems.RoutingItem;
+        }
+      });
       Object.defineProperty(exports, "getSortedRoutes", {
         enumerable: true,
         get: function get() {
@@ -6906,6 +6997,7 @@
       var _getMiddlewareRegex = __webpack_require__(3072);
       var _routeMatcher = __webpack_require__(3156);
       var _routeRegex = __webpack_require__(4903);
+      var _routingItems = __webpack_require__(7185);
       var _sortedRoutes = __webpack_require__(566);
       var _isDynamic = __webpack_require__(6238); //# sourceMappingURL=index.js.map
 
@@ -7237,6 +7329,101 @@
       /***/
     },
 
+    /***/ 7185: /***/ function(
+      __unused_webpack_module,
+      exports,
+      __webpack_require__
+    ) {
+      "use strict";
+
+      function _arrayLikeToArray(arr, len) {
+        if (len == null || len > arr.length) len = arr.length;
+        for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+        return arr2;
+      }
+      function _arrayWithoutHoles(arr) {
+        if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+      }
+      function _iterableToArray(iter) {
+        if (
+          (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null) ||
+          iter["@@iterator"] != null
+        )
+          return Array.from(iter);
+      }
+      function _nonIterableSpread() {
+        throw new TypeError(
+          "Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
+        );
+      }
+      function _toConsumableArray(arr) {
+        return (
+          _arrayWithoutHoles(arr) ||
+          _iterableToArray(arr) ||
+          _unsupportedIterableToArray(arr) ||
+          _nonIterableSpread()
+        );
+      }
+      function _unsupportedIterableToArray(o, minLen) {
+        if (!o) return;
+        if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+        var n = Object.prototype.toString.call(o).slice(8, -1);
+        if (n === "Object" && o.constructor) n = o.constructor.name;
+        if (n === "Map" || n === "Set") return Array.from(n);
+        if (
+          n === "Arguments" ||
+          /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)
+        )
+          return _arrayLikeToArray(o, minLen);
+      }
+      Object.defineProperty(exports, "__esModule", {
+        value: true
+      });
+      exports.getRoutingItems = getRoutingItems;
+      var _getMiddlewareRegex = __webpack_require__(3072);
+      var _routeMatcher = __webpack_require__(3156);
+      var _routeRegex = __webpack_require__(4903);
+      var _sortedRoutes = __webpack_require__(566);
+      var MIDDLEWARE_SUFFIX = "/_middleware";
+      function getRoutingItems(pages, middleware) {
+        // append the suffix so that `getSortedRoutes()` can handle middleware properly
+        var middlewarePages = middleware.map(function(m) {
+          return "".concat(m.page).concat(MIDDLEWARE_SUFFIX);
+        });
+        var middlewareMap = new Map(
+          middleware.map(function(m) {
+            return [m.page, m];
+          })
+        );
+        var sortedRoutes = (0, _sortedRoutes).getSortedRoutes(
+          _toConsumableArray(pages).concat(_toConsumableArray(middlewarePages))
+        );
+        return sortedRoutes.map(function(page) {
+          if (page.endsWith(MIDDLEWARE_SUFFIX)) {
+            var p = page.slice(0, -MIDDLEWARE_SUFFIX.length) || "/";
+            var ssr = middlewareMap.get(p).ssr;
+            return {
+              match: (0, _routeMatcher).getRouteMatcher(
+                (0, _getMiddlewareRegex).getMiddlewareRegex(p, !ssr)
+              ),
+              page: p,
+              ssr: ssr,
+              isMiddleware: true
+            };
+          } else {
+            return {
+              match: (0, _routeMatcher).getRouteMatcher(
+                (0, _routeRegex).getRouteRegex(page)
+              ),
+              page: page
+            };
+          }
+        });
+      } //# sourceMappingURL=routing-items.js.map
+
+      /***/
+    },
+
     /***/ 566: /***/ function(__unused_webpack_module, exports) {
       "use strict";
 
@@ -7311,6 +7498,7 @@
           this.slugName = null;
           this.restSlugName = null;
           this.optionalRestSlugName = null;
+          this.isMiddleware = false;
         }
         _createClass(UrlNode, [
           {
@@ -7345,6 +7533,9 @@
               if (this.optionalRestSlugName !== null) {
                 childrenPaths.splice(childrenPaths.indexOf("[[...]]"), 1);
               }
+              if (this.isMiddleware) {
+                childrenPaths.splice(childrenPaths.indexOf("_middleware"), 1);
+              }
               var routes = childrenPaths
                 .map(function(c) {
                   return _this.children
@@ -7381,10 +7572,21 @@
                 }
                 routes.unshift(r);
               }
-              if (this.restSlugName !== null) {
+              if (this.isMiddleware) {
                 var _routes1;
-                (_routes1 = routes).push.apply(
+                (_routes1 = routes).unshift.apply(
                   _routes1,
+                  _toConsumableArray(
+                    this.children
+                      .get("_middleware")
+                      ._smoosh("".concat(prefix, "_middleware/"))
+                  )
+                );
+              }
+              if (this.restSlugName !== null) {
+                var _routes2;
+                (_routes2 = routes).push.apply(
+                  _routes2,
                   _toConsumableArray(
                     this.children
                       .get("[...]")
@@ -7397,9 +7599,9 @@
                 );
               }
               if (this.optionalRestSlugName !== null) {
-                var _routes2;
-                (_routes2 = routes).push.apply(
-                  _routes2,
+                var _routes3;
+                (_routes3 = routes).push.apply(
+                  _routes3,
                   _toConsumableArray(
                     this.children
                       .get("[[...]]")
@@ -7540,6 +7742,11 @@
                   // nextSegment is overwritten to [] so that it can later be sorted specifically
                   nextSegment = "[]";
                 }
+              } else if (
+                nextSegment === "_middleware" &&
+                urlPaths.length === 1
+              ) {
+                this.isMiddleware = true;
               }
               // If this UrlNode doesn't have the nextSegment yet we create a new child UrlNode
               if (!this.children.has(nextSegment)) {
Diff for index.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-31e3f2e995c2cb43.js"
+      src="/_next/static/chunks/main-ab56f791707d19d6.js"
       defer=""
     ></script>
     <script
Diff for link.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-31e3f2e995c2cb43.js"
+      src="/_next/static/chunks/main-ab56f791707d19d6.js"
       defer=""
     ></script>
     <script
Diff for withRouter.html
@@ -19,7 +19,7 @@
       defer=""
     ></script>
     <script
-      src="/_next/static/chunks/main-31e3f2e995c2cb43.js"
+      src="/_next/static/chunks/main-ab56f791707d19d6.js"
       defer=""
     ></script>
     <script

Please sign in to comment.