Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export async function generateAngularServerAppManifest(
for (const file of [...additionalHtmlOutputFiles.values(), ...outputFiles]) {
const extension = extname(file.path);
if (extension === '.html') {
const jsChunkFilePath = `assets-chunks/${file.path.replace(/[./]/g, '_')}.mjs`;
// Mirror the asset path, which is unique, so that two assets never share a chunk.
const jsChunkFilePath = `assets-chunks/${file.path}.mjs`;
const escapedContent = escapeUnsafeChars(file.text);

serverAssetsChunks.push(
Expand Down
26 changes: 26 additions & 0 deletions packages/angular/build/src/utils/server-rendering/manifest_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,32 @@ describe('generateAngularServerAppManifest', () => {
);
});

it('should generate a separate chunk for each asset', async () => {
const { manifestContent, serverAssetsChunks } = await generateManifest({
'blog/archive/index.html': '<main>Archive</main>',
'blog_archive/index.html': '<main>Landing</main>',
'blog.archive/index.html': '<main>Release</main>',
});

expect(serverAssetsChunks).toEqual([
jasmine.objectContaining({
path: 'assets-chunks/blog/archive/index.html.mjs',
text: 'export default `<main>Archive</main>`;',
}),
jasmine.objectContaining({
path: 'assets-chunks/blog_archive/index.html.mjs',
text: 'export default `<main>Landing</main>`;',
}),
jasmine.objectContaining({
path: 'assets-chunks/blog.archive/index.html.mjs',
text: 'export default `<main>Release</main>`;',
}),
]);
expect(manifestContent).toContain('import("./assets-chunks/blog/archive/index.html.mjs")');
expect(manifestContent).toContain('import("./assets-chunks/blog_archive/index.html.mjs")');
expect(manifestContent).toContain('import("./assets-chunks/blog.archive/index.html.mjs")');
});

it('should serialize a base href which contains JavaScript string delimiters', async () => {
const { manifestContent } = await generateManifest(
{ 'index.html': '<main></main>' },
Expand Down
Loading