Skip to content

Commit 76d4250

Browse files
committed
feat: updated funcmetadata to include edge
1 parent b489908 commit 76d4250

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/runtime/src/helpers/functionsMetaData.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const getNextRuntimeVersion = async (packageJsonPath: string, useNodeModulesPath
1515
return useNodeModulesPath ? packagePlugin.version : packagePlugin.dependencies[NEXT_PLUGIN]
1616
}
1717

18+
// Getting the path to the nextjs-plugin package.json file
19+
const nodeModulesPath = resolveModuleRoot(NEXT_PLUGIN) ? join(resolveModuleRoot(NEXT_PLUGIN), 'package.json') : null
20+
const pluginPackagePath = '.netlify/plugins/package.json'
21+
22+
1823
// The information needed to create a function configuration file
1924
export interface FunctionInfo {
2025
// The name of the function, e.g. `___netlify-handler`
@@ -34,9 +39,6 @@ export interface FunctionInfo {
3439
*/
3540
export const writeFunctionConfiguration = async (functionInfo: FunctionInfo) => {
3641
const { functionName, functionTitle, functionsDir } = functionInfo
37-
const pluginPackagePath = '.netlify/plugins/package.json'
38-
const moduleRoot = resolveModuleRoot(NEXT_PLUGIN)
39-
const nodeModulesPath = moduleRoot ? join(moduleRoot, 'package.json') : null
4042

4143
const nextPluginVersion =
4244
(await getNextRuntimeVersion(nodeModulesPath, true)) ||
@@ -54,3 +56,13 @@ export const writeFunctionConfiguration = async (functionInfo: FunctionInfo) =>
5456

5557
await writeFile(join(functionsDir, functionName, `${functionName}.json`), JSON.stringify(metadata))
5658
}
59+
60+
export const writeEdgeFunctionConfiguration = async () => {
61+
const nextPluginVersion =
62+
(await getNextRuntimeVersion(nodeModulesPath, true)) ||
63+
(await getNextRuntimeVersion(pluginPackagePath, false)) ||
64+
// The runtime version should always be available, but if it's not, return 'unknown'
65+
'unknown'
66+
67+
return `${NEXT_PLUGIN_NAME}@${nextPluginVersion}`
68+
}

0 commit comments

Comments
 (0)