Skip to content

fix: detect @angular/platform-server to determine if Angular project uses SSR - #10430

Merged
leoortizz merged 4 commits into
mainfrom
fix/angular-ssr-warning
Apr 29, 2026
Merged

leoortizz merged 4 commits into
mainfrom
fix/angular-ssr-warning

Conversation

@leoortizz

@leoortizz leoortizz commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Duplicate of #10364 to allow merging the PR as it was created from a fork.

Quoting @swseverance:

Description

Per #10362 a "SSR warning" message appears when performing firebase init hosting in Angular workspaces that do not use SSR. Now, the discover function for the Angular framework checks for the presence of @angular/platform-server in installed dependencies.

This fix will prevent the following warning from being displayed in Angular workspaces that have no dependencies on @angular/ssr:

Detected a Angular codebase with SSR features. We can't guarantee that this site will work on Firebase Hosting, which is
optimized for static sites. Another product, Firebase App Hosting, was designed for SSR web apps. Would you like to use App
Hosting instead? Learn more here: https://firebase.google.com/docs/app-hosting/product-comparison#hostings

I know personally the first time I saw the warning message (in my codebase with no SSR) it made me think I had incorrectly initialized my Angular workspace to in fact use SSR.

Scenarios Tested

Scenario 1: SSR

  1. Create new workspace with SSR
ng new ssr --style css --ssr true --ai-config none
cd ssr
  1. Init hosting (this command will differ based upon the user)
node /Users/sam/Documents/firebase-tools/lib/bin/firebase.js init hosting
  1. Observe the "SSR warning" appears

Scenario 2: No SSR

  1. Create new workspace without SSR
ng new nossr --style css --ssr false --ai-config none
cd nossr
  1. Init hosting (this command will differ based upon the user)
node /Users/sam/Documents/firebase-tools/lib/bin/firebase.js init hosting
  1. Observe there is no "SSR warning"

Sample Commands

N/A

swseverance and others added 4 commits April 16, 2026 13:28
…uses SSR

Previously, Angular's discover() always returned mayWantBackend: true,
causing the SSR warning to appear even for SPA-only Angular projects.
Now checks for the presence of @angular/platform-server in installed dependencies.

Resolves #10362

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Angular framework discovery logic to correctly identify if a project uses Server-Side Rendering (SSR). It replaces the hardcoded mayWantBackend: true with a check for the @angular/platform-server dependency, which helps suppress unnecessary SSR warnings for non-SSR projects. Comprehensive unit tests were added to verify discovery behavior for various project configurations, including missing configuration files and projects with or without SSR. A review comment suggests also checking for @angular/ssr to support modern Angular versions and notes potential performance implications of multiple dependency lookups.

Comment on lines +45 to +49
const mayWantBackend = !!findDependency("@angular/platform-server", {
cwd: dir,
depth: 0,
omitDev: false,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While @angular/platform-server is the traditional indicator for SSR in Angular, modern projects (v17+) often use @angular/ssr. Although @angular/ssr depends on @angular/platform-server, it is safer to check for both to ensure robust detection in all project configurations.

Additionally, note that calling findDependency multiple times (here and inside getAngularVersion) can be slow as it may spawn multiple npm list processes. If performance becomes an issue, consider a more unified way to check for multiple dependencies in a single pass.

Suggested change
const mayWantBackend = !!findDependency("@angular/platform-server", {
cwd: dir,
depth: 0,
omitDev: false,
});
const mayWantBackend = !!(findDependency("@angular/platform-server", {
cwd: dir,
depth: 0,
omitDev: false,
}) || findDependency("@angular/ssr", {
cwd: dir,
depth: 0,
omitDev: false,
}));

@leoortizz
leoortizz merged commit f2aa408 into main Apr 29, 2026
55 of 60 checks passed
@leoortizz
leoortizz deleted the fix/angular-ssr-warning branch April 29, 2026 15:55
bkendall pushed a commit that referenced this pull request Jul 9, 2026
…uses SSR (#10430)

* fix: detect @angular/platform-server to determine if Angular project uses SSR

Previously, Angular's discover() always returned mayWantBackend: true,
causing the SSR warning to appear even for SPA-only Angular projects.
Now checks for the presence of @angular/platform-server in installed dependencies.

Resolves #10362

* changelog

* add more tests

---------

Co-authored-by: Sam Severance <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants