-
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.
feat(@angular-devkit/build-angular): add preload hints based on trans…
…itive initial files When using the esbuild-based browser application builder, the pre-existing initial file analysis is now used to generate preload hints for any transitive initial files required by the application. These hints are generated for both the initial JavaScript chunks and any initial global stylesheets that may be present. These hints provide additional information to the browser so that it can start and better prioritize fetching of files needed to start the application.
- Loading branch information
1 parent
6abff16
commit 2a3fc68
Showing
2 changed files
with
57 additions
and
0 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
37 changes: 37 additions & 0 deletions
37
...kit/build_angular/src/builders/browser-esbuild/tests/behavior/index-preload-hints_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,37 @@ | ||
/** | ||
* @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 { buildEsbuildBrowser } from '../../index'; | ||
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(buildEsbuildBrowser, BROWSER_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "Preload hints"', () => { | ||
it('should add preload hints for transitive global style imports', async () => { | ||
await harness.writeFile( | ||
'src/styles.css', | ||
` | ||
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono&family=Roboto:wght@300;400;500;700&display=swap'); | ||
`, | ||
); | ||
|
||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
styles: ['src/styles.css'], | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBe(true); | ||
|
||
harness | ||
.expectFile('dist/index.html') | ||
.content.toContain( | ||
'<link rel="preload" href="https://fonts.googleapis.com/css2?family=Roboto+Mono&family=Roboto:wght@300;400;500;700&display=swap">', | ||
); | ||
}); | ||
}); | ||
}); |