Skip to content

Commit

Permalink
fix(@angular/build): ensure accurate content length for server assets
Browse files Browse the repository at this point in the history
Adjusts the server assets to use the original content length

Closes #28832

(cherry picked from commit 4d437ec)
  • Loading branch information
alan-agius4 committed Nov 20, 2024
1 parent d622e59 commit 74461da
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/angular/build/src/utils/server-rendering/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,16 @@ export function generateAngularServerAppManifest(
const extension = extname(file.path);
if (extension === '.html' || (inlineCriticalCss && extension === '.css')) {
const jsChunkFilePath = `assets-chunks/${file.path.replace(/[./]/g, '_')}.mjs`;
const escapedContent = escapeUnsafeChars(file.text);

serverAssetsChunks.push(
createOutputFile(
jsChunkFilePath,
`export default \`${escapedContent}\`;`,
`export default \`${escapeUnsafeChars(file.text)}\`;`,
BuildOutputFileType.ServerApplication,
),
);

const contentLength = Buffer.byteLength(escapedContent);
serverAssetsContent.push(
`['${file.path}', {size: ${contentLength}, hash: '${file.hash}', text: () => import('./${jsChunkFilePath}').then(m => m.default)}]`,
`['${file.path}', {size: ${file.size}, hash: '${file.hash}', text: () => import('./${jsChunkFilePath}').then(m => m.default)}]`,
);
}
}
Expand Down

0 comments on commit 74461da

Please sign in to comment.