Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee5c5f8

Browse files
committed
fix(@angular/build): avoid extra tick in SSR dev-server builds
In SSR applications, an unnecessary event loop tick during server startup could lead to an incorrect platform being initialized. This change introduces an `ngJitMode` define, which is set to `false` during AOT builds. This allows for the JIT-specific code paths to not be followed, preventing the async operations that caused the extra tick. This ensures that the server platform is correctly and synchronously initialized.
1 parent b0f4330 commit ee5c5f8

File tree

5 files changed

+5
-2
lines changed

5 files changed

+5
-2
lines changed

packages/angular/build/src/builders/dev-server/vite-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ export async function* serveWithVite(
447447
browserOptions.loader as EsbuildLoaderOption | undefined,
448448
{
449449
...browserOptions.define,
450+
'ngJitMode': browserOptions.aot ? 'false' : 'true',
450451
'ngHmrMode': browserOptions.templateUpdates ? 'true' : 'false',
451452
},
452453
extensions?.middleware,

packages/angular/ssr/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ts_project(
3030
deps = [
3131
"//:node_modules/@angular/common",
3232
"//:node_modules/@angular/core",
33+
"//:node_modules/@angular/platform-browser",
3334
"//:node_modules/@angular/platform-server",
3435
"//:node_modules/@angular/router",
3536
"//:node_modules/tslib",

packages/angular_devkit/build_angular/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ ts_project(
142142
"//:node_modules/@angular/compiler-cli",
143143
"//:node_modules/@angular/core",
144144
"//:node_modules/@angular/localize",
145+
"//:node_modules/@angular/platform-browser",
145146
"//:node_modules/@angular/platform-server",
146147
"//:node_modules/@angular/service-worker",
147148
"//:node_modules/@babel/core",

packages/schematics/angular/server/files/application-builder/standalone-src/main.server.ts.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { AppComponent } from './app/app.component';
33
import { config } from './app/app.config.server';
44

55
const bootstrap = (context: BootstrapContext) =>
6-
bootstrapApplication(AppComponent, config, BootstrapContext);
6+
bootstrapApplication(AppComponent, config, context);
77

88
export default bootstrap;

packages/schematics/angular/server/files/server-builder/standalone-src/main.server.ts.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { AppComponent } from './app/app.component';
33
import { config } from './app/app.config.server';
44

55
const bootstrap = (context: BootstrapContext) =>
6-
bootstrapApplication(AppComponent, config, BootstrapContext);
6+
bootstrapApplication(AppComponent, config, context);
77

88
export default bootstrap;

0 commit comments

Comments
 (0)