Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c7171f

Browse files
authored
fix: correct checking for runtime version installed in the project and provide example API endpoint in code snippets (#230)
* fix: adjust getAngularRuntimeVersion to not find auto-installed version in .netlify/plugins * docs: fix wrong code snippet in README * fix: add commented out example API to code snippets shown on incompatible server.ts error * fix: use :internal: trick * fix: add missing ending qoute
1 parent 18fd723 commit 3c7171f

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export async function netlifyCommonEngineHandler(request: Request, context: any)
123123
// Example API endpoints can be defined here.
124124
// Uncomment and define endpoints as necessary.
125125
// const pathname = new URL(request.url).pathname;
126-
// if (pathname = '/api/hello') {
126+
// if (pathname === '/api/hello') {
127127
// return Response.json({ message: 'Hello from the API' });
128128
// }
129129

@@ -145,7 +145,7 @@ export async function netlifyAppEngineHandler(request: Request): Promise<Respons
145145
// Example API endpoints can be defined here.
146146
// Uncomment and define endpoints as necessary.
147147
// const pathname = new URL(request.url).pathname;
148-
// if (pathname = '/api/hello') {
148+
// if (pathname === '/api/hello') {
149149
// return Response.json({ message: 'Hello from the API' });
150150
// }
151151

‎src/helpers/getPackageVersion.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const { createRequire } = require('node:module')
2+
const { join } = require('node:path/posix')
3+
14
const { readJSON } = require('fs-extra')
25

36
/**
@@ -29,8 +32,8 @@ module.exports.getAngularVersion = getAngularVersion
2932
const getAngularRuntimeVersion = async function (root) {
3033
let packagePath
3134
try {
32-
// eslint-disable-next-line n/no-missing-require
33-
packagePath = require.resolve('@netlify/angular-runtime/package.json',{paths: [root]})
35+
constsiteRequire=createRequire(join(root,':internal:'))
36+
packagePath = siteRequire.resolve('@netlify/angular-runtime/package.json')
3437
} catch {
3538
// module not found
3639
return

‎src/helpers/serverModuleHelpers.js‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import { render } from '@netlify/angular-runtime/common-engine'
1616
const commonEngine = new CommonEngine()
1717
1818
export async function netlifyCommonEngineHandler(request: Request, context: any): Promise<Response> {
19+
// Example API endpoints can be defined here.
20+
// Uncomment and define endpoints as necessary.
21+
// const pathname = new URL(request.url).pathname;
22+
// if (pathname === '/api/hello') {
23+
// return Response.json({ message: 'Hello from the API' });
24+
// }
25+
1926
return await render(commonEngine)
2027
}
2128
`
@@ -29,6 +36,13 @@ const angularAppEngine = new AngularAppEngine()
2936
export async function netlifyAppEngineHandler(request: Request): Promise<Response> {
3037
const context = getContext()
3138
39+
// Example API endpoints can be defined here.
40+
// Uncomment and define endpoints as necessary.
41+
// const pathname = new URL(request.url).pathname;
42+
// if (pathname === '/api/hello') {
43+
// return Response.json({ message: 'Hello from the API' });
44+
// }
45+
3246
const result = await angularAppEngine.handle(request, context)
3347
return result || new Response('Not found', { status: 404 })
3448
}
@@ -113,7 +127,7 @@ const fixServerTs = async function ({ angularVersion, siteRoot, failPlugin, fail
113127
)
114128
} else if (!satisfies(angularRuntimeVersionInstalledByUser, '>=2.2.0', { includePrerelease: true })) {
115129
failBuild(
116-
`Angular@19 SSR on Netlify requires '@netlify/angular-runtime' version 2.2.0 or later to be installed. Found version "${angularRuntimeVersionInstalledByUser}. Please update it to version 2.2.0 or later and try again.`,
130+
`Angular@19 SSR on Netlify requires '@netlify/angular-runtime' version 2.2.0 or later to be installed. Found version "${angularRuntimeVersionInstalledByUser}". Please update it to version 2.2.0 or later and try again.`,
117131
)
118132
}
119133

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /