-
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): add asset tracking to application builder watch …
…files This commit updates the application builder to include assets in the watch process, triggering file re-copying when changes are detected. Closes #28415 (cherry picked from commit 2f92121)
- Loading branch information
1 parent
881095e
commit f752234
Showing
2 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
packages/angular/build/src/builders/application/tests/behavior/rebuild-assets_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,65 @@ | ||
/** | ||
* @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 { 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. | ||
*/ | ||
const BUILD_TIMEOUT = 10_000; | ||
|
||
describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "Rebuilds when input asset changes"', () => { | ||
beforeEach(async () => { | ||
// Application code is not needed for styles tests | ||
await harness.writeFile('src/main.ts', 'console.log("TEST");'); | ||
await harness.writeFile('public/asset.txt', 'foo'); | ||
}); | ||
|
||
it('emits updated asset', async () => { | ||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
assets: [ | ||
{ | ||
glob: '**/*', | ||
input: 'public', | ||
}, | ||
], | ||
watch: true, | ||
}); | ||
|
||
const buildCount = await harness | ||
.execute({ outputLogsOnFailure: false }) | ||
.pipe( | ||
timeout(BUILD_TIMEOUT), | ||
concatMap(async ({ result }, index) => { | ||
switch (index) { | ||
case 0: | ||
expect(result?.success).toBeTrue(); | ||
harness.expectFile('dist/browser/asset.txt').content.toContain('foo'); | ||
|
||
await harness.writeFile('public/asset.txt', 'bar'); | ||
break; | ||
case 1: | ||
expect(result?.success).toBeTrue(); | ||
harness.expectFile('dist/browser/asset.txt').content.toContain('bar'); | ||
break; | ||
} | ||
}), | ||
take(2), | ||
count(), | ||
) | ||
.toPromise(); | ||
|
||
expect(buildCount).toBe(2); | ||
}); | ||
}); | ||
}); |
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