diff --git a/packages/angular/build/src/builders/application/chunk-optimizer.ts b/packages/angular/build/src/builders/application/chunk-optimizer.ts index ea4c2f8076f9..db3e1d2f180d 100644 --- a/packages/angular/build/src/builders/application/chunk-optimizer.ts +++ b/packages/angular/build/src/builders/application/chunk-optimizer.ts @@ -113,11 +113,15 @@ function bundleOutputToEsbuildMetafile( continue; } + // Read once per module: in Rolldown, `renderedLength` is an uncached getter that + // copies the entire module code across the NAPI bridge on each access. + const { renderedLength } = renderedModule; + for (const [originalInputPath, originalInputInfo] of Object.entries( originalOutputEntry.inputs, )) { const proportion = originalInputInfo.bytesInOutput / totalOriginalBytesInModule; - const newBytesInOutput = Math.floor(renderedModule.renderedLength * proportion); + const newBytesInOutput = Math.floor(renderedLength * proportion); const existing = newOutputInputs[originalInputPath]; if (existing) {