mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit adds a background macrotask when an XHR request is performed. The macrotask is started during `loadstart` and ended during `loadend` event. The macrotask is needed so that the application is not stabilized during HTTP calls. This is important for server rendering, as the application is rendering when the application is stabilized. The application is stabilized when there are no longer pending Macro and Micro tasks intercepted by Zone.js, Since an XHR request is none of these, we create a background macrotask so that Zone.js is made aware that there is something pending. Prior to this change, we patched the `HttpHandler` in `@angular/platform-server` but this is not enough, as there can be multiple `HttpHandler` in an application, example when importing `HttpClient` in a lazy loaded component/module. Which causes a new unpatched instance of `HttpHandler` to be created in the child injector which is not intercepted by Zone.js and thus the application is stabalized and rendered before the XHR request is finalized. NB: Zone.js is fundamental for SSR and currently, it's not possible to do SSR without it. Closes: #49425 PR Close #49546
24 lines
728 B
JavaScript
24 lines
728 B
JavaScript
/**
|
|
* @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 * as path from 'path';
|
|
import {moduleRules, baseDir} from './base-config.mjs';
|
|
|
|
export default {
|
|
entry: {
|
|
helloworld: './built/src/helloworld/client.js',
|
|
transferstate: './built/src/transferstate/client.js',
|
|
httptransferstatelazy: './built/src/http-transferstate-lazy/client.js',
|
|
},
|
|
// Allow for better debugging of this integration test.
|
|
optimization: {minimize: false},
|
|
output: {path: path.join(baseDir, 'webpack-out'), filename: '[name]-bundle.js'},
|
|
module: {
|
|
rules: moduleRules,
|
|
}
|
|
};
|