Unverified Commit 2d3d53f8 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

Add codemod command to middleware deprecation warning (#92532)

## What

Adds the `npx @next/codemod@latest middleware-to-proxy .` command to the
middleware deprecation warning in both `next build` and `next dev`.

## Why

The existing deprecation warning tells developers to use `proxy` instead
of `middleware`, but does not surface the available codemod for
automatic migration. Developers have to click through to the docs page
to discover it. Including the command directly in the warning lets them
copy-paste a one-liner to migrate immediately.

## How

Updated the `Log.warnOnce()` call in both:
- `packages/next/src/build/index.ts` (build path)
- `packages/next/src/server/lib/router-utils/setup-dev-bundler.ts` (dev
server path)

The warning now reads:

```
The "middleware" file convention is deprecated. Please use "proxy" instead.

  To migrate automatically, run:
  npx @next/codemod@latest middleware-to-proxy .

  Learn more: https://nextjs.org/docs/messages/middleware-to-proxy
```

This follows the same pattern used by other Next.js codemod suggestions
(e.g., `next/link` in `link.tsx`).

<!-- NEXT_JS_LLM_PR -->
parent 6344e18a
...@@ -1279,7 +1279,10 @@ export default async function build( ...@@ -1279,7 +1279,10 @@ export default async function build(
) )
} }
Log.warnOnce( Log.warnOnce(
`The "${MIDDLEWARE_FILENAME}" file convention is deprecated. Please use "${PROXY_FILENAME}" instead. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy` `The "${MIDDLEWARE_FILENAME}" file convention is deprecated. Please use "${PROXY_FILENAME}" instead.\n\n` +
` To migrate automatically, run:\n` +
` npx @next/codemod@canary middleware-to-proxy .\n\n` +
` Learn more: https://nextjs.org/docs/messages/middleware-to-proxy`
) )
} }
......
...@@ -488,7 +488,10 @@ async function startWatcher( ...@@ -488,7 +488,10 @@ async function startWatcher(
) )
} }
Log.warnOnce( Log.warnOnce(
`The "${MIDDLEWARE_FILENAME}" file convention is deprecated. Please use "${PROXY_FILENAME}" instead. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy` `The "${MIDDLEWARE_FILENAME}" file convention is deprecated. Please use "${PROXY_FILENAME}" instead.\n\n` +
` To migrate automatically, run:\n` +
` npx @next/codemod@canary middleware-to-proxy .\n\n` +
` Learn more: https://nextjs.org/docs/messages/middleware-to-proxy`
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment