diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index bb73efb05c804..8a3e6331955ee 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -1724,8 +1724,15 @@ export default async function getBaseWebpackConfig( }, } + if (!webpack5Config.output) { + webpack5Config.output = {} + } + if (isClient) { + webpack5Config.output.trustedTypes = 'nextjs#bundler' + } + if (isClient || isEdgeServer) { - webpack5Config.output!.enabledLibraryTypes = ['assign'] + webpack5Config.output.enabledLibraryTypes = ['assign'] } if (dev) {