-
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 input index HTML file triggers rebuilds w…
…hen changed When using the `application` builder, the input index HTML file will now correctly trigger rebuilds of the application. The rebuilds are not currently optimized for the input index file only case but changes will be reflected in the output. (cherry picked from commit 2708b18)
- Loading branch information
Showing
3 changed files
with
78 additions
and
1 deletion.
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
71 changes: 71 additions & 0 deletions
71
packages/angular/build/src/builders/application/tests/behavior/rebuild-index-html_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,71 @@ | ||
/** | ||
* @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.io/license | ||
*/ | ||
|
||
import { concatMap, count, take, timeout } from 'rxjs'; | ||
import { buildApplication } from '../../index'; | ||
import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup'; | ||
|
||
/** | ||
* Maximum time in milliseconds for single build/rebuild | ||
* This accounts for CI variability. | ||
*/ | ||
export const BUILD_TIMEOUT = 30_000; | ||
|
||
describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "Rebuilds when input index HTML changes"', () => { | ||
beforeEach(async () => { | ||
// Application code is not needed for styles tests | ||
await harness.writeFile('src/main.ts', 'console.log("TEST");'); | ||
}); | ||
|
||
it('rebuilds output index HTML', async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
watch: true, | ||
}); | ||
|
||
const buildCount = await harness | ||
.execute({ outputLogsOnFailure: false }) | ||
.pipe( | ||
timeout(30000), | ||
concatMap(async ({ result }, index) => { | ||
switch (index) { | ||
case 0: | ||
expect(result?.success).toBe(true); | ||
harness.expectFile('dist/browser/index.html').content.toContain('charset="utf-8"'); | ||
|
||
await harness.modifyFile('src/index.html', (content) => | ||
content.replace('charset="utf-8"', 'abc'), | ||
); | ||
break; | ||
case 1: | ||
expect(result?.success).toBe(true); | ||
harness | ||
.expectFile('dist/browser/index.html') | ||
.content.not.toContain('charset="utf-8"'); | ||
|
||
await harness.modifyFile('src/index.html', (content) => | ||
content.replace('abc', 'charset="utf-8"'), | ||
); | ||
break; | ||
case 2: | ||
expect(result?.success).toBe(true); | ||
harness.expectFile('dist/browser/index.html').content.toContain('charset="utf-8"'); | ||
|
||
break; | ||
} | ||
}), | ||
take(3), | ||
count(), | ||
) | ||
.toPromise(); | ||
|
||
expect(buildCount).toBe(3); | ||
}); | ||
}); | ||
}); |
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