Skip to content

Commit 74461da

Browse files
committed
fix(@angular/build): ensure accurate content length for server assets
Adjusts the server assets to use the original content length Closes #28832 (cherry picked from commit 4d437ec)
1 parent d622e59 commit 74461da

File tree

1 file changed

+2
-5
lines changed
  • packages/angular/build/src/utils/server-rendering

1 file changed

+2
-5
lines changed

packages/angular/build/src/utils/server-rendering/manifest.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,16 @@ export function generateAngularServerAppManifest(
124124
const extension = extname(file.path);
125125
if (extension === '.html' || (inlineCriticalCss && extension === '.css')) {
126126
const jsChunkFilePath = `assets-chunks/${file.path.replace(/[./]/g, '_')}.mjs`;
127-
const escapedContent = escapeUnsafeChars(file.text);
128-
129127
serverAssetsChunks.push(
130128
createOutputFile(
131129
jsChunkFilePath,
132-
`export default \`${escapedContent}\`;`,
130+
`export default \`${escapeUnsafeChars(file.text)}\`;`,
133131
BuildOutputFileType.ServerApplication,
134132
),
135133
);
136134

137-
const contentLength = Buffer.byteLength(escapedContent);
138135
serverAssetsContent.push(
139-
`['${file.path}', {size: ${contentLength}, hash: '${file.hash}', text: () => import('./${jsChunkFilePath}').then(m => m.default)}]`,
136+
`['${file.path}', {size: ${file.size}, hash: '${file.hash}', text: () => import('./${jsChunkFilePath}').then(m => m.default)}]`,
140137
);
141138
}
142139
}

0 commit comments

Comments
 (0)