Skip to content

Commit 6355b77

Browse files
author
Lukas Holzer
committed
chore: nudge to install the @netlify/functions package
1 parent a2d5436 commit 6355b77

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib/functions/check-tsconfig-for-v2-api.mjs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// @ts-check
22
import { existsSync } from 'fs'
33
import { writeFile } from 'fs/promises'
4+
import { createRequire } from 'module'
45
import { join } from 'path'
56

67
import { parseTsconfig } from 'get-tsconfig'
78
import terminalLink from 'terminal-link'
89

9-
import { NETLIFYDEVLOG, chalk, log } from '../../utils/command-helpers.mjs'
10+
import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log } from '../../utils/command-helpers.mjs'
1011

1112
/**
1213
* The `tsconfig.json` we are going to write to the functions directory.
@@ -44,6 +45,16 @@ export async function checkTsconfigForV2Api(config) {
4445
return
4546
}
4647

48+
try {
49+
const require = createRequire(config.functionsDir)
50+
require.resolve('@netlify/functions')
51+
} catch {
52+
log(
53+
`${NETLIFYDEVWARN} Please install the ${chalk.dim(
54+
'@netlify/functions',
55+
)} package to get a better typed experience!`,
56+
)
57+
}
4758
const tsconfig = join(config.functionsDir, 'tsconfig.json')
4859

4960
if (existsSync(tsconfig)) {

0 commit comments

Comments
 (0)