-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/build): ensure correct handling of
index.output
for SSR
Previously, the index file was not being renamed correctly when using server-side rendering (SSR). Closes: #29012 (cherry picked from commit 97897b7)
- Loading branch information
1 parent
be21acc
commit 21f21ed
Showing
3 changed files
with
125 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/angular/build/src/builders/application/tests/behavior/index-csr_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
import { buildApplication } from '../../index'; | ||
import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "index.csr.html"', () => { | ||
beforeEach(async () => { | ||
await harness.modifyFile('src/tsconfig.app.json', (content) => { | ||
const tsConfig = JSON.parse(content); | ||
tsConfig.files ??= []; | ||
tsConfig.files.push('main.server.ts'); | ||
|
||
return JSON.stringify(tsConfig); | ||
}); | ||
}); | ||
|
||
it(`should generate 'index.csr.html' instead of 'index.html' when ssr is enabled.`, async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
server: 'src/main.server.ts', | ||
ssr: true, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBeTrue(); | ||
harness.expectDirectory('dist/server').toExist(); | ||
harness.expectFile('dist/browser/index.csr.html').toExist(); | ||
harness.expectFile('dist/browser/index.html').toNotExist(); | ||
}); | ||
|
||
it(`should generate 'index.csr.html' instead of 'index.html' when 'output' is 'index.html' and ssr is enabled.`, async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
index: { | ||
input: 'src/index.html', | ||
output: 'index.html', | ||
}, | ||
server: 'src/main.server.ts', | ||
ssr: true, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBeTrue(); | ||
|
||
harness.expectDirectory('dist/server').toExist(); | ||
harness.expectFile('dist/browser/index.csr.html').toExist(); | ||
harness.expectFile('dist/browser/index.html').toNotExist(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters