From f4e5f1ad096738c9d21812b2eabb0b1127e65f8c Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Thu, 24 Feb 2022 12:13:04 +0200 Subject: [PATCH] Make it under an experimental flag --- packages/next/build/webpack-config.ts | 1 + .../build/webpack/plugins/middleware-source-maps-plugin.ts | 3 ++- packages/next/server/config-shared.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index c3378ec65636bd6..54904755d64c349 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -1274,6 +1274,7 @@ export default async function getBaseWebpackConfig( }, plugins: [ ...getMiddlewareSourceMapPlugins({ + isConfigured: !!config.experimental.middlewareSourceMaps, isProductionBrowserSourceMapsOn: config.productionBrowserSourceMaps, }), hasReactRefresh && new ReactRefreshWebpackPlugin(webpack), diff --git a/packages/next/build/webpack/plugins/middleware-source-maps-plugin.ts b/packages/next/build/webpack/plugins/middleware-source-maps-plugin.ts index 13d9ef93eb7ba1d..72f6248a9ce33ce 100644 --- a/packages/next/build/webpack/plugins/middleware-source-maps-plugin.ts +++ b/packages/next/build/webpack/plugins/middleware-source-maps-plugin.ts @@ -8,9 +8,10 @@ import type { webpack5 } from 'next/dist/compiled/webpack/webpack' * are emitted. */ export const getMiddlewareSourceMapPlugins = (params: { + isConfigured: boolean isProductionBrowserSourceMapsOn: boolean }) => { - if (params.isProductionBrowserSourceMapsOn) { + if (!params.isConfigured || params.isProductionBrowserSourceMapsOn) { return [] } diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index a580ee537efbbee..b927e37ffdc8140 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -106,6 +106,7 @@ export interface ExperimentalConfig { urlImports?: NonNullable['buildHttp'] outputFileTracingRoot?: string outputStandalone?: boolean + middlewareSourceMaps?: boolean } /**