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

fix(turbopack): middleware path and aliases #56804

Merged
merged 7 commits into from
Oct 13, 2023
Merged

Conversation

ForsakenHarmony
Copy link
Contributor

@ForsakenHarmony ForsakenHarmony commented Oct 13, 2023

Description

  • Adds the page path to the middleware template (and also uses the template from the next.js loader)
  • ESM aliases for the edge context
  • Fix for the process polyfill to make it possible to import from dist/esm
  • Fix for the server-only/client-only aliases

Closes WEB-1779

@ijjk ijjk added Turbopack Related to Turbopack with Next.js. created-by: Turbopack team PRs by the Turbopack team. type: next labels Oct 13, 2023
@ForsakenHarmony
Copy link
Contributor Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@ForsakenHarmony ForsakenHarmony changed the title fix(turbopack): middleware aliases fix(turbopack): middleware path and aliases Oct 13, 2023
@ForsakenHarmony ForsakenHarmony marked this pull request as ready for review October 13, 2023 15:54
@ijjk
Copy link
Member

ijjk commented Oct 13, 2023

Tests Passed

jridgewell
jridgewell previously approved these changes Oct 13, 2023
@ijjk
Copy link
Member

ijjk commented Oct 13, 2023

Stats from current PR

Default Build
General
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
buildDuration 10.1s 10.2s N/A
buildDurationCached 5.9s 6s N/A
nodeModulesSize 172 MB 172 MB N/A
nextStartRea..uration (ms) 529ms 513ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
199-HASH.js gzip 27.5 kB 27.5 kB N/A
3f784ff6-HASH.js gzip 50.9 kB 50.9 kB
99.HASH.js gzip 182 B 182 B
framework-HASH.js gzip 45.3 kB 45.3 kB
main-app-HASH.js gzip 254 B 252 B N/A
main-HASH.js gzip 32.9 kB 32.9 kB N/A
webpack-HASH.js gzip 1.75 kB 1.75 kB N/A
Overall change 96.4 kB 96.4 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
_app-HASH.js gzip 206 B 205 B N/A
_error-HASH.js gzip 182 B 180 B N/A
amp-HASH.js gzip 506 B 505 B N/A
css-HASH.js gzip 322 B 323 B N/A
dynamic-HASH.js gzip 2.57 kB 2.57 kB N/A
edge-ssr-HASH.js gzip 260 B 259 B N/A
head-HASH.js gzip 350 B 350 B
hooks-HASH.js gzip 369 B 369 B
image-HASH.js gzip 4.35 kB 4.35 kB N/A
index-HASH.js gzip 256 B 256 B
link-HASH.js gzip 2.64 kB 2.63 kB N/A
routerDirect..HASH.js gzip 312 B 311 B N/A
script-HASH.js gzip 385 B 384 B N/A
withRouter-HASH.js gzip 307 B 308 B N/A
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 1.08 kB 1.08 kB
Client Build Manifests
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
_buildManifest.js gzip 485 B 482 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
index.html gzip 528 B 529 B N/A
link.html gzip 541 B 542 B N/A
withRouter.html gzip 524 B 524 B
Overall change 524 B 524 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
edge-ssr.js gzip 93.8 kB 93.8 kB
page.js gzip 152 kB 152 kB N/A
Overall change 93.8 kB 93.8 kB
Middleware size
vercel/next.js canary vercel/next.js hrmny/fix-middleware Change
middleware-b..fest.js gzip 624 B 624 B
middleware-r..fest.js gzip 150 B 151 B N/A
middleware.js gzip 22.9 kB 22.9 kB N/A
edge-runtime..pack.js gzip 1.92 kB 1.92 kB
Overall change 2.55 kB 2.55 kB
Diff details
Diff for middleware.js
@@ -2,7 +2,7 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [826],
   {
-    /***/ 137: /***/ (
+    /***/ 1003: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -21,7 +21,7 @@
       __webpack_require__.r(middleware_namespaceObject);
       __webpack_require__.d(middleware_namespaceObject, {
         default: () => middleware,
-      }); // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/globals.js
+      }); // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/globals.js
 
       async function registerInstrumentation() {
         if (
@@ -91,7 +91,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         // Eagerly fire instrumentation hook to make the startup faster.
         void ensureInstrumentationRegistered();
       }
-      enhanceGlobals(); //# sourceMappingURL=globals.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/error.js
+      enhanceGlobals(); //# sourceMappingURL=globals.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/error.js
 
       class PageSignatureError extends Error {
         constructor({ page }) {
@@ -118,7 +118,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
   Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
   `);
         }
-      } //# sourceMappingURL=error.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/utils.js
+      } //# sourceMappingURL=error.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/utils.js
 
       /**
        * Converts a Node.js IncomingHttpHeaders object to a Headers object. Any
@@ -253,7 +253,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             }
           );
         }
-      } //# sourceMappingURL=utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/fetch-event.js
+      } //# sourceMappingURL=utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/fetch-event.js
 
       const responseSymbol = Symbol("response");
       const passThroughSymbol = Symbol("passThrough");
@@ -299,7 +299,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             page: this.sourcePage,
           });
         }
-      } //# sourceMappingURL=fetch-event.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/i18n/detect-domain-locale.js
+      } //# sourceMappingURL=fetch-event.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/i18n/detect-domain-locale.js
 
       function detectDomainLocale(domainItems, hostname, detectedLocale) {
         if (!domainItems) return;
@@ -325,7 +325,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             return item;
           }
         }
-      } //# sourceMappingURL=detect-domain-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/remove-trailing-slash.js
+      } //# sourceMappingURL=detect-domain-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/remove-trailing-slash.js
 
       /**
        * Removes the trailing slash for a given route or page path. Preserves the
@@ -335,7 +335,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
        *   - `/` -> `/`
        */ function removeTrailingSlash(route) {
         return route.replace(/\/$/, "") || "/";
-      } //# sourceMappingURL=remove-trailing-slash.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/parse-path.js
+      } //# sourceMappingURL=remove-trailing-slash.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/parse-path.js
 
       /**
        * Given a path this function will find the pathname, query and hash and return
@@ -363,7 +363,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
           query: "",
           hash: "",
         };
-      } //# sourceMappingURL=parse-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/add-path-prefix.js
+      } //# sourceMappingURL=parse-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/add-path-prefix.js
 
       /**
        * Adds the provided prefix to the given path. It first ensures that the path
@@ -374,7 +374,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         }
         const { pathname, query, hash } = parsePath(path);
         return "" + prefix + pathname + query + hash;
-      } //# sourceMappingURL=add-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/add-path-suffix.js
+      } //# sourceMappingURL=add-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/add-path-suffix.js
 
       /**
        * Similarly to `addPathPrefix`, this function adds a suffix at the end on the
@@ -386,7 +386,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         }
         const { pathname, query, hash } = parsePath(path);
         return "" + pathname + suffix + query + hash;
-      } //# sourceMappingURL=add-path-suffix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/path-has-prefix.js
+      } //# sourceMappingURL=add-path-suffix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/path-has-prefix.js
 
       /**
        * Checks if a given path starts with a given prefix. It ensures it matches
@@ -400,7 +400,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         }
         const { pathname } = parsePath(path);
         return pathname === prefix || pathname.startsWith(prefix + "/");
-      } //# sourceMappingURL=path-has-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/add-locale.js
+      } //# sourceMappingURL=path-has-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/add-locale.js
 
       /**
        * For a given path and a locale, if the locale is given, it will prefix the
@@ -419,7 +419,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         }
         // Add the locale prefix to the path.
         return addPathPrefix(path, "/" + locale);
-      } //# sourceMappingURL=add-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/format-next-pathname-info.js
+      } //# sourceMappingURL=add-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/format-next-pathname-info.js
 
       function formatNextPathnameInfo(info) {
         let pathname = addLocale(
@@ -443,7 +443,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             ? addPathSuffix(pathname, "/")
             : pathname
           : removeTrailingSlash(pathname);
-      } //# sourceMappingURL=format-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/get-hostname.js
+      } //# sourceMappingURL=format-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/get-hostname.js
 
       /**
        * Takes an object with a hostname property (like a parsed URL) and some
@@ -463,7 +463,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
           hostname = parsed.hostname;
         } else return;
         return hostname.toLowerCase();
-      } //# sourceMappingURL=get-hostname.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/i18n/normalize-locale-path.js
+      } //# sourceMappingURL=get-hostname.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/i18n/normalize-locale-path.js
 
       /**
        * For a pathname that may include a locale from a list of locales, it
@@ -493,7 +493,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
           pathname,
           detectedLocale,
         };
-      } //# sourceMappingURL=normalize-locale-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/remove-path-prefix.js
+      } //# sourceMappingURL=normalize-locale-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/remove-path-prefix.js
 
       /**
        * Given a path and a prefix it will remove the prefix when it exists in the
@@ -527,7 +527,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         // If the path without the prefix doesn't start with a `/` we need to add it
         // back to the path to make sure it's a valid path.
         return "/" + withoutPrefix;
-      } //# sourceMappingURL=remove-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/get-next-pathname-info.js
+      } //# sourceMappingURL=remove-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/get-next-pathname-info.js
 
       function getNextPathnameInfo(pathname, options) {
         var _options_nextConfig;
@@ -585,7 +585,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
           }
         }
         return info;
-      } //# sourceMappingURL=get-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/next-url.js
+      } //# sourceMappingURL=get-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/next-url.js
 
       const REGEX_LOCALHOST_HOSTNAME =
         /(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|\[::1\]|localhost)/;
@@ -812,8 +812,8 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         }
       } //# sourceMappingURL=next-url.js.map
 
-      // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
-      var _edge_runtime_cookies = __webpack_require__(3842); // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/cookies.js // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/request.js
+      // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
+      var _edge_runtime_cookies = __webpack_require__(5511); // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/cookies.js // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/request.js
       //# sourceMappingURL=cookies.js.map
 
       const INTERNALS = Symbol("internal request");
@@ -890,7 +890,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         get url() {
           return this[INTERNALS].url;
         }
-      } //# sourceMappingURL=request.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/response.js
+      } //# sourceMappingURL=request.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/response.js
 
       const response_INTERNALS = Symbol("internal response");
       const REDIRECTS = new Set([301, 302, 303, 307, 308]);
@@ -988,7 +988,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             headers,
           });
         }
-      } //# sourceMappingURL=response.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/relativize-url.js
+      } //# sourceMappingURL=response.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/relativize-url.js
 
       /**
        * Given a URL as a string and a base URL it will make the URL relative
@@ -1001,7 +1001,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         return relative.protocol + "//" + relative.host === origin
           ? relative.toString().replace(origin, "")
           : relative.toString();
-      } //# sourceMappingURL=relativize-url.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/client/components/app-router-headers.js
+      } //# sourceMappingURL=relativize-url.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/client/components/app-router-headers.js
 
       const RSC = "RSC";
       const ACTION = "Next-Action";
@@ -1022,7 +1022,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         [NEXT_ROUTER_STATE_TREE],
         [NEXT_ROUTER_PREFETCH],
       ];
-      const NEXT_RSC_UNION_QUERY = "_rsc"; //# sourceMappingURL=app-router-headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/internal-utils.js
+      const NEXT_RSC_UNION_QUERY = "_rsc"; //# sourceMappingURL=app-router-headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/internal-utils.js
 
       const INTERNAL_QUERY_NAMES = [
         "__nextFallback",
@@ -1071,7 +1071,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         for (const key of INTERNAL_HEADERS) {
           delete headers[key];
         }
-      } //# sourceMappingURL=internal-utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
+      } //# sourceMappingURL=internal-utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
 
       /**
        * Normalizes an app route so it represents the actual request path. Essentially
@@ -1122,7 +1122,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
        * Since this function is used on full urls it checks `?` for searchParams handling.
        */ function normalizeRscPath(pathname, enabled) {
         return enabled ? pathname.replace(/\.rsc($|\?)/, "$1") : pathname;
-      } //# sourceMappingURL=app-paths.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/lib/constants.js
+      } //# sourceMappingURL=app-paths.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/lib/constants.js
 
       const NEXT_QUERY_PARAM_PREFIX = "nxtP";
       const PRERENDER_REVALIDATE_HEADER = "x-prerender-revalidate";
@@ -1287,7 +1287,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         metadata: "__next_metadata__",
         metadataRoute: "__next_metadata_route__",
         metadataImageMeta: "__next_metadata_image_meta__",
-      }; // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js
+      }; // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js
       //# sourceMappingURL=constants.js.map
 
       class ReflectAdapter {
@@ -1307,7 +1307,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         static deleteProperty(target, prop) {
           return Reflect.deleteProperty(target, prop);
         }
-      } //# sourceMappingURL=reflect.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js
+      } //# sourceMappingURL=reflect.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js
 
       /**
        * @internal
@@ -1488,7 +1488,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         [Symbol.iterator]() {
           return this.entries();
         }
-      } //# sourceMappingURL=headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js
+      } //# sourceMappingURL=headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js
 
       /**
        * @internal
@@ -1621,7 +1621,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             },
           });
         }
-      } //# sourceMappingURL=request-cookies.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/api-utils/index.js
+      } //# sourceMappingURL=request-cookies.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/api-utils/index.js
 
       /**
        *
@@ -1676,7 +1676,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         if (SYMBOL_CLEARED_COOKIES in res) {
           return res;
         }
-        const { serialize } = __webpack_require__(7171);
+        const { serialize } = __webpack_require__(847);
         const previous = res.getHeader("Set-Cookie");
         res.setHeader(`Set-Cookie`, [
           ...(typeof previous === "string"
@@ -1773,7 +1773,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             });
           },
         });
-      } //# sourceMappingURL=index.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/async-storage/draft-mode-provider.js
+      } //# sourceMappingURL=index.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/async-storage/draft-mode-provider.js
 
       class DraftModeProvider {
         constructor(previewProps, req, cookies, mutableCookies) {
@@ -1826,7 +1826,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
             expires: new Date(0),
           });
         }
-      } //# sourceMappingURL=draft-mode-provider.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/async-storage/request-async-storage-wrapper.js
+      } //# sourceMappingURL=draft-mode-provider.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/async-storage/request-async-storage-wrapper.js
 
       function getHeaders(headers) {
         const cleaned = HeadersAdapter.from(headers);
@@ -1911,10 +1911,10 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
         },
       }; //# sourceMappingURL=request-async-storage-wrapper.js.map
 
-      // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/client/components/async-local-storage.js
-      var async_local_storage = __webpack_require__(7940); // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/client/components/request-async-storage.external.js
+      // EXTERNAL MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/client/components/async-local-storage.js
+      var async_local_storage = __webpack_require__(4049); // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/client/components/request-async-storage.external.js
       const requestAsyncStorage = (0,
-      async_local_storage /* createAsyncLocalStorage */.P)(); //# sourceMappingURL=request-async-storage.external.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/adapter.js
+      async_local_storage /* createAsyncLocalStorage */.P)(); //# sourceMappingURL=request-async-storage.external.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/adapter.js
 
       class NextRequestHint extends NextRequest {
         constructor(params) {
@@ -2178,36 +2178,41 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
           waitUntil: Promise.all(event[waitUntilSymbol]),
           fetchMetrics: request.fetchMetrics,
         };
-      } //# sourceMappingURL=adapter.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/exports/next-response.js // CONCATENATED MODULE: ./middleware.js
+      } //# sourceMappingURL=adapter.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/esm/server/web/exports/next-response.js // CONCATENATED MODULE: ./middleware.js
 
       // This file is for modularized imports for next/server to get fully-treeshaking.
       //# sourceMappingURL=next-response.js.map
 
       async function middleware() {
         return NextResponse.next();
-      } // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=private-next-root-dir%2Fmiddleware.js&page=%2Fmiddleware&rootDir=%2Ftmp%2Fnext-statsBPRYaE%2Fstats-app&matchers=&preferredRegion=&middlewareConfig=e30%3D!
+      } // CONCATENATED MODULE: ./node_modules/.pnpm/[email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=private-next-root-dir%2Fmiddleware.js&page=%2Fmiddleware&rootDir=%2Ftmp%2Fnext-statsBPRYaE%2Fstats-app&matchers=&preferredRegion=&middlewareConfig=e30%3D!
 
-      const mod = { ...middleware_namespaceObject };
-      const handler = mod.middleware || mod.default;
+      // Import the userland code.
 
+      const mod = {
+        ...middleware_namespaceObject,
+      };
+      const handler = mod.middleware || mod.default;
+      const page = "/middleware";
       if (typeof handler !== "function") {
         throw new Error(
-          'The Middleware "pages/middleware" must export a `middleware` or a `default` function'
+          `The Middleware "${page}" must export a \`middleware\` or a \`default\` function`
         );
       }
-
       function nHandler(opts) {
         return adapter({
           ...opts,
-          page: "/middleware",
+          page,
           handler,
         });
       }
 
+      //# sourceMappingURL=middleware.js.map
+
       /***/
     },
 
-    /***/ 3842: /***/ (module) => {
+    /***/ 5511: /***/ (module) => {
       "use strict";
 
       var __defProp = Object.defineProperty;
@@ -2608,7 +2613,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
       /***/
     },
 
-    /***/ 7171: /***/ (module) => {
+    /***/ 847: /***/ (module) => {
       "use strict";
       var __dirname = "/";
 
@@ -2738,7 +2743,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
       /***/
     },
 
-    /***/ 7940: /***/ (
+    /***/ 4049: /***/ (
       __unused_webpack_module,
       __webpack_exports__,
       __webpack_require__
@@ -2784,7 +2789,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
     // webpackRuntimeModules
     /******/ var __webpack_exec__ = (moduleId) =>
       __webpack_require__((__webpack_require__.s = moduleId));
-    /******/ var __webpack_exports__ = __webpack_exec__(137);
+    /******/ var __webpack_exports__ = __webpack_exec__(1003);
     /******/ (_ENTRIES =
       typeof _ENTRIES === "undefined" ? {} : _ENTRIES).middleware_middleware =
       __webpack_exports__;
Commit: ff9bcc1

@kodiakhq kodiakhq bot merged commit f9d12d1 into canary Oct 13, 2023
59 checks passed
@kodiakhq kodiakhq bot deleted the hrmny/fix-middleware branch October 13, 2023 18:41
@github-actions github-actions bot added the locked label Nov 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Turbopack team PRs by the Turbopack team. locked Turbopack Related to Turbopack with Next.js. type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants