next.js
057b84fe - Avoid bundling HMR refresh reducer in production (#94305)

Commit
168 days ago
Avoid bundling HMR refresh reducer in production (#94305) ### What? Prevent `hmrRefreshReducer` from being included in production App Router browser chunks and add regression coverage for the production bundle. ### Why? `hmrRefreshReducer` is only used by development HMR, but its eager import from the client reducer caused it to be shipped in optimized production bundles. ### How? Load the HMR reducer behind the compile-time development branch in `ACTION_HMR_REFRESH`, allowing production bundlers to eliminate its module edge. Extend the production `browser-chunks` test to reject `hmr-refresh-reducer` sources. ### Verification - `pnpm --filter=next build` - `pnpm next build test/e2e/app-dir/hello-world` and verified its production client chunks contain no `hmrRefreshReducer` or `hmr-refresh-reducer` - Red check: restored the eager import and confirmed `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-turbo test/production/app-dir/browser-chunks/browser-chunks.test.ts` fails on the new assertion - `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-turbo test/production/app-dir/browser-chunks/browser-chunks.test.ts` - `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-webpack test/production/app-dir/browser-chunks/browser-chunks.test.ts` <!-- NEXT_JS_LLM_PR -->
Author
Parents
Loading