File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export const HANDLER_FUNCTION_NAME = '___netlify-handler'
2
2
export const ODB_FUNCTION_NAME = '___netlify-odb-handler'
3
3
export const IMAGE_FUNCTION_NAME = '_ipx'
4
4
export const NEXT_PLUGIN_NAME = '@netlify/next-runtime'
5
+ export const NEXT_PLUGIN = '@netlify/plugin-nextjs'
5
6
export const HANDLER_FUNCTION_TITLE = 'Next.js SSR handler'
6
7
export const ODB_FUNCTION_TITLE = 'Next.js ISR handler'
7
8
export const IMAGE_FUNCTION_TITLE = "'next/image handler'"
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
ODB_FUNCTION_NAME ,
13
13
IMAGE_FUNCTION_NAME ,
14
14
DEFAULT_FUNCTIONS_SRC ,
15
+ NEXT_PLUGIN ,
15
16
NEXT_PLUGIN_NAME ,
16
17
HANDLER_FUNCTION_TITLE ,
17
18
ODB_FUNCTION_TITLE ,
@@ -31,17 +32,20 @@ export interface ApiRouteConfig {
31
32
compiled : string
32
33
}
33
34
34
- const checkForPackage = async ( packageDir : string ) => {
35
+ const checkForPackage = async ( packageDir : string , nodeModule : boolean ) => {
35
36
const packagePlugin = existsSync ( packageDir ) ? await readJSON ( packageDir ) : null
36
- const nextPlugin = packagePlugin ? packagePlugin . dependencies [ '@netlify/plugin-nextjs' ] : null
37
- return nextPlugin
37
+ const nextPlugin =
38
+ packagePlugin ?. dependencies [ NEXT_PLUGIN ] && ! nodeModule ? packagePlugin . dependencies [ NEXT_PLUGIN ] : null
39
+ const checkModule = packagePlugin && nodeModule ? packagePlugin . version : null
40
+
41
+ return checkModule || nextPlugin
38
42
}
39
43
40
44
const writeFunctionConfiguration = async ( functionName : string , functionTitle : string , functionsDir : string ) => {
41
45
const pluginPackagePath = '.netlify/plugins/package.json'
42
- const depsPackagePath = './ package.json'
43
-
44
- const nextPluginVersion = ( await checkForPackage ( pluginPackagePath ) ) || ( await checkForPackage ( depsPackagePath ) )
46
+ const nodeModulesPath = join ( 'node_modules' , NEXT_PLUGIN , ' package.json')
47
+ const nextPluginVersion =
48
+ ( await checkForPackage ( nodeModulesPath , true ) ) || ( await checkForPackage ( pluginPackagePath , false ) )
45
49
46
50
const metadata = {
47
51
config : {
You can’t perform that action at this time.
0 commit comments