-
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-devkit/build-angular): display warning when `preserveWhi…
…tespaces` is set in the tsconfig provided to the server builder This commits add a check to display a warning when `preserveWhitespaces` is configured in `tsconfig.server.json`, as potentially this could cause issue with hydration. (cherry picked from commit 688bb2d)
- Loading branch information
1 parent
6e9586d
commit 107851a
Showing
2 changed files
with
77 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
47 changes: 47 additions & 0 deletions
47
...evkit/build_angular/src/builders/server/tests/behavior/preserve_whitespaces_check_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,47 @@ | ||
/** | ||
* @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 { logging } from '@angular-devkit/core'; | ||
import { execute } from '../../index'; | ||
import { BASE_OPTIONS, SERVER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(execute, SERVER_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "preserveWhitespaces warning"', () => { | ||
it('should not show warning when "preserveWhitespaces" is not set.', async () => { | ||
harness.useTarget('server', { | ||
...BASE_OPTIONS, | ||
}); | ||
|
||
const { logs } = await harness.executeOnce(); | ||
expect(logs).not.toContain( | ||
jasmine.objectContaining<logging.LogEntry>({ | ||
message: jasmine.stringMatching('"preserveWhitespaces" was set in'), | ||
}), | ||
); | ||
}); | ||
it('should show warning when "preserveWhitespaces" is set.', async () => { | ||
harness.useTarget('server', { | ||
...BASE_OPTIONS, | ||
}); | ||
|
||
await harness.modifyFile('src/tsconfig.server.json', (content) => { | ||
const tsconfig = JSON.parse(content); | ||
(tsconfig.angularCompilerOptions ??= {}).preserveWhitespaces = false; | ||
|
||
return JSON.stringify(tsconfig); | ||
}); | ||
|
||
const { logs } = await harness.executeOnce(); | ||
expect(logs).toContain( | ||
jasmine.objectContaining<logging.LogEntry>({ | ||
message: jasmine.stringMatching('"preserveWhitespaces" was set in'), | ||
}), | ||
); | ||
}); | ||
}); | ||
}); |