Skip to content

Commit 285d979

Browse files
committed
match version of angular/ssr instead of core
1 parent ca53395 commit 285d979

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

demo/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
},
8787
"devDependencies": {
8888
"@netlify/build": "^35.13.6",
89-
"@netlify/edge-functions": "^3.0.6",
9089
"@netlify/eslint-config-node": "^7.0.1",
9190
"@opentelemetry/api": "~1.8.0",
9291
"@types/node": "^24.0.0",
@@ -97,6 +96,7 @@
9796
"prettier": "^3.8.3"
9897
},
9998
"dependencies": {
99+
"@netlify/edge-functions": "^3.0.6",
100100
"semver": "^7.8.0"
101101
},
102102
"jest": {

src/helpers/getPackageVersion.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ export async function getAngularVersion(root) {
1212
try {
1313
const require = createRequire(import.meta.url)
1414

15-
packagePath = require.resolve('@angular/core/package.json', { paths: [root] })
15+
// we're checking @angular/ssr version
16+
// there could be patch-level differences in this and @angular/core
17+
// but in serverModuleHelpers.js, we need patch-level matching of the ssr package
18+
// so we cannot rely on the version of core anymore
19+
packagePath = require.resolve('@angular/ssr/package.json', { paths: [root] })
1620
} catch {
1721
// module not found
1822
return

src/helpers/serverModuleHelpers.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const reqHandler = createRequestHandler(netlifyAppEngineHandler)
4949
`
5050

5151
// eslint-disable-next-line no-inline-comments
52-
const NetlifyServerTsAppEngine21Dot2 = /* typescript */ `import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
52+
const NetlifyServerTsAppEngine21Dot2Dot9 = /* typescript */ `import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
5353
import { getAllowedHosts, getContext, getTrustProxyHeaders } from '@netlify/angular-runtime/app-engine.js'
5454
5555
const angularAppEngine = new AngularAppEngine({
@@ -60,7 +60,7 @@ const angularAppEngine = new AngularAppEngine({
6060
${NetlifyServerTsAppEngineCommonContent}`
6161

6262
// eslint-disable-next-line no-inline-comments
63-
const NetlifyServerTsAppEngine21Dot1 = /* typescript */ `import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
63+
const NetlifyServerTsAppEngine21Dot1Dot5 = /* typescript */ `import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
6464
import { getAllowedHosts, getContext } from '@netlify/angular-runtime/app-engine.js'
6565
6666
const angularAppEngine = new AngularAppEngine({
@@ -134,14 +134,14 @@ export async function fixServerTs({ angularVersion, siteRoot, failPlugin, failBu
134134
const angularJson = getAngularJson({ failPlugin, siteRoot, workspaceType, packagePath })
135135

136136
// Angular v21.1 introduced `allowedHosts`: https://github.com/angular/angular-cli/blob/21.1.x/packages/angular/ssr/src/app-engine.ts
137-
// Angular v21.2 introduced `trustProxyHeaders` as well: https://github.com/angular/angular-cli/blob/21.2.x/packages/angular/ssr/src/app-engine.ts
137+
// Angular v21.2.9 introduced `trustProxyHeaders` as well: https://github.com/angular/angular-cli/blob/21.2.x/packages/angular/ssr/src/app-engine.ts
138138
// we cannot add the config if the version doesn't support it
139139
// because TypeScript complains about invalid properties
140140
let NetlifyServerTsAppEngine = NetlifyServerTsAppEngine21Dot0
141-
if (satisfies(angularVersion, '>=21.2.0', { includePrerelease: true })) {
142-
NetlifyServerTsAppEngine = NetlifyServerTsAppEngine21Dot2
143-
} else if (satisfies(angularVersion, '>=21.1.0', { includePrerelease: true })) {
144-
NetlifyServerTsAppEngine = NetlifyServerTsAppEngine21Dot1
141+
if (satisfies(angularVersion, '>=21.2.9', { includePrerelease: true })) {
142+
NetlifyServerTsAppEngine = NetlifyServerTsAppEngine21Dot2Dot9
143+
} else if (satisfies(angularVersion, '>=21.1.5', { includePrerelease: true })) {
144+
NetlifyServerTsAppEngine = NetlifyServerTsAppEngine21Dot1Dot5
145145
}
146146

147147
const project = getProject(angularJson, failBuild, workspaceType === 'nx')

0 commit comments

Comments
 (0)