-
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 full rebuild after initial error build in…
… watch mode If an initial build of an application results in an error during watch mode (including `ng serve`), the following non-error rebuild will now always be a full build result. This ensures that all new files are available for later incremental build result updates. (cherry picked from commit b24089e)
- Loading branch information
1 parent
27f8331
commit 8f6ee7e
Showing
4 changed files
with
82 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
66 changes: 66 additions & 0 deletions
66
packages/angular/build/src/builders/dev-server/tests/behavior/build-errors_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,66 @@ | ||
/** | ||
* @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 { executeDevServer } from '../../index'; | ||
import { describeServeBuilder } from '../jasmine-helpers'; | ||
import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup'; | ||
import { logging } from '@angular-devkit/core'; | ||
|
||
describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupTarget) => { | ||
describe('Behavior: "Rebuild Error Detection"', () => { | ||
beforeEach(() => { | ||
setupTarget(harness); | ||
}); | ||
|
||
it('Emits full build result with incremental enabled and initial build has errors', async () => { | ||
harness.useTarget('serve', { | ||
...BASE_OPTIONS, | ||
watch: true, | ||
}); | ||
|
||
// Missing ending `>` on the div will cause an error | ||
await harness.appendToFile('src/app/app.component.html', '<div>Hello, world!</div'); | ||
|
||
const buildCount = await harness | ||
.execute({ outputLogsOnFailure: false }) | ||
.pipe( | ||
timeout(BUILD_TIMEOUT), | ||
concatMap(async ({ result, logs }, index) => { | ||
switch (index) { | ||
case 0: | ||
expect(result?.success).toBeFalse(); | ||
debugger; | ||
expect(logs).toContain( | ||
jasmine.objectContaining<logging.LogEntry>({ | ||
message: jasmine.stringMatching('Unexpected character "EOF"'), | ||
}), | ||
); | ||
|
||
await harness.appendToFile('src/app/app.component.html', '>'); | ||
|
||
break; | ||
case 1: | ||
expect(result?.success).toBeTrue(); | ||
expect(logs).not.toContain( | ||
jasmine.objectContaining<logging.LogEntry>({ | ||
message: jasmine.stringMatching('Unexpected character "EOF"'), | ||
}), | ||
); | ||
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
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