From 13107a597808a0b7650ca6ac1d9052d7ab98e6e7 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 19 Dec 2024 23:30:29 -0600 Subject: [PATCH] fixes --- packages/next/src/build/compiler.ts | 12 ++++----- packages/next/src/build/webpack-config.ts | 12 ++++++--- .../config/blocks/css/loaders/client.ts | 2 +- .../webpack/plugins/build-manifest-plugin.ts | 26 ++++++++++--------- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/packages/next/src/build/compiler.ts b/packages/next/src/build/compiler.ts index 67dd02980e457..be8b30a5cf6b2 100644 --- a/packages/next/src/build/compiler.ts +++ b/packages/next/src/build/compiler.ts @@ -58,6 +58,12 @@ export function runCompiler( } compiler.fsStartTime = Date.now() compiler.run((err, stats) => { + const result = runWebpackSpan + .traceChild('webpack-generate-error-stats') + .traceFn(() => + generateStats({ errors: [], warnings: [], stats }, stats!) + ) + const webpackCloseSpan = runWebpackSpan.traceChild('webpack-close', { name: config.name || 'unknown', }) @@ -78,12 +84,6 @@ export function runCompiler( } return reject(err) } else if (!stats) throw new Error('No Stats from webpack') - - const result = webpackCloseSpan - .traceChild('webpack-generate-error-stats') - .traceFn(() => - generateStats({ errors: [], warnings: [], stats }, stats) - ) return resolve([result, compiler.inputFileSystem]) }) }) diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index 81ca658fa0e21..e4597fda6133c 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1041,10 +1041,14 @@ export default async function getBaseWebpackConfig( // duplication that need to be pulled out. chunks: (chunk: any) => !/^(polyfills|main|pages\/_app)$/.test(chunk.name), - cacheGroups: { - framework: frameworkCacheGroup, - lib: libCacheGroup, - }, + + // TODO: investigate these cache groups with rspack + cacheGroups: isRspack + ? {} + : { + framework: frameworkCacheGroup, + lib: libCacheGroup, + }, maxInitialRequests: 25, minSize: 20000, } diff --git a/packages/next/src/build/webpack/config/blocks/css/loaders/client.ts b/packages/next/src/build/webpack/config/blocks/css/loaders/client.ts index 3d7ea849b2917..89a68ed5db835 100644 --- a/packages/next/src/build/webpack/config/blocks/css/loaders/client.ts +++ b/packages/next/src/build/webpack/config/blocks/css/loaders/client.ts @@ -44,7 +44,7 @@ export function getClientStyleLoader({ const MiniCssExtractPlugin = isRspack ? // eslint-disable-next-line - require('@rspack/core').rspack.CssExtractRspackPlugin.loader + require('@rspack/core').rspack.CssExtractRspackPlugin : require('../../../../plugins/mini-css-extract-plugin').default return { diff --git a/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts b/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts index 1355c59905e1d..2cbbc45b4de84 100644 --- a/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts +++ b/packages/next/src/build/webpack/plugins/build-manifest-plugin.ts @@ -103,17 +103,18 @@ export function generateClientManifest( compiler?: any, compilation?: any ): string | undefined { - const compilationSpan = compilation - ? spans.get(compilation) - : compiler - ? spans.get(compiler) - : new Span({ name: 'client-manifest' }) - - const genClientManifestSpan = compilationSpan?.traceChild( + const compilationSpan = + (compilation + ? spans.get(compilation) + : compiler + ? spans.get(compiler) + : undefined) || new Span({ name: 'client-manifest' }) + + const genClientManifestSpan = compilationSpan.traceChild( 'NextJsBuildManifest-generateClientManifest' ) - return genClientManifestSpan?.traceFn(() => { + return genClientManifestSpan.traceFn(() => { const clientManifest: ClientBuildManifest = { __rewrites: normalizeRewritesForBuildManifest(rewrites) as any, __routerFilterStatic: clientRouterFilters?.staticFilter as any, @@ -200,10 +201,11 @@ export default class BuildManifestPlugin { createAssets(compiler: any, compilation: any, assets: any) { const compilationSpan = spans.get(compilation) || spans.get(compiler) - const createAssetsSpan = compilationSpan?.traceChild( - 'NextJsBuildManifest-createassets' - ) - return createAssetsSpan?.traceFn(() => { + const createAssetsSpan = ( + compilationSpan || new Span({ name: '' }) + ).traceChild('NextJsBuildManifest-createassets') + + return createAssetsSpan.traceFn(() => { const entrypoints: Map = compilation.entrypoints const assetMap: DeepMutable = { polyfillFiles: [],