next.js
b12b46b6 - Add experimental custom webpack support (#98862)

Commit
31 days ago
Add experimental custom webpack support (#98862) ### What? Add the experimental `customWebpack` configuration option so webpack-mode applications can use a project-installed webpack version instead of the version bundled with Next.js. Webpack is now an optional `^5.98.0` peer dependency, and the new option is documented with end-to-end coverage for webpack 5.98.0 and 5.111.0. ### Why? Next.js currently redirects webpack imports to its bundled implementation. This prevents applications from opting into newer compatible webpack releases or validating upgrades independently. The new option provides an explicit escape hatch while preserving the bundled implementation as the default. ### How? After configuration is resolved, webpack-mode startup redirects the existing webpack require-hook aliases to the package resolved from the application. The selection is propagated to webpack build workers through the existing local-webpack runtime switch. If the optional peer cannot be resolved, Next.js restores its bundled aliases and reports an actionable installation error. The implementation only activates for webpack, leaving Turbopack and Rspack unchanged. It also handles the resolver stack API exposed by external webpack versions. The test matrix verifies the selected compiler version, rendering in development and production, the build-worker path, missing-peer diagnostics, and bundled fallback behavior when the option is disabled. ### Verification - `pnpm test-dev-webpack test/e2e/app-dir/custom-webpack/custom-webpack.test.ts` - `pnpm test-start-webpack test/e2e/app-dir/custom-webpack/custom-webpack.test.ts` - `pnpm --filter=next types` <!-- NEXT_JS_LLM --> <!-- fleet 19431696-5f4c-400d-a3be-700bfe86abda --> --------- Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Author
Parents
Loading