Skip to content

Commit ce20029

Browse files
committed
fix: add semver to handler
1 parent 8728b30 commit ce20029

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/runtime/src/templates/getHandler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const path = require('path')
1717
const { URLSearchParams, URL } = require('url')
1818

1919
const { Bridge } = require('@vercel/node-bridge/bridge')
20+
const { satisfies } = require('semver')
2021

2122
const {
2223
augmentFsModule,
@@ -64,7 +65,7 @@ const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mod
6465
// With the release of 13.5 experimental.appDir is no longer used.
6566
// we will need to check if appDir is set and Next version before running requireHooks
6667
const runRequireHooks = async (hook) =>
67-
await nextVersionNum()
68+
await nextVersionNum(satisfies)
6869
.then((version) => (appDir && version ? hook : null))
6970
.catch(() => ({}))
7071

@@ -226,6 +227,7 @@ export const getHandler = ({
226227
227228
const { Server } = require("http");
228229
const { promises } = require("fs");
230+
const { satisfies } = require('semver')
229231
// We copy the file here rather than requiring from the node module
230232
const { Bridge } = require("./bridge");
231233
const { augmentFsModule, getMaxAge, getMultiValueHeaders, getPrefetchResponse, normalizePath, nextVersionNum } = require('./handlerUtils')

packages/runtime/src/templates/handlerUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { promisify } from 'util'
88
import { HandlerEvent, HandlerResponse } from '@netlify/functions'
99
import { http, https } from 'follow-redirects'
1010
import NextNodeServer from 'next/dist/server/next-server'
11-
import { satisfies } from 'semver'
1211

1312
import type { StaticRoute } from '../helpers/types'
1413

@@ -293,7 +292,7 @@ const nextPluginVersion = async () => {
293292
return packagePlugin?.version
294293
}
295294

296-
export const nextVersionNum = async () => satisfies(await nextPluginVersion(), '13.3.3 - 13.4.9')
295+
export const nextVersionNum = async (satisfies) => satisfies(await nextPluginVersion(), '13.3.3 - 13.4.9')
297296

298297
export const getMatchedRoute = (
299298
paths: string,

packages/runtime/src/templates/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { NextConfig } from 'next'
66
import type { PrerenderManifest } from 'next/dist/build'
77
import type { BaseNextResponse } from 'next/dist/server/base-http'
88
import type { NodeRequestHandler, Options } from 'next/dist/server/next-server'
9+
import { satisfies } from 'semver'
910

1011
import { ExperimentalConfigWithLegacy } from '../helpers/utils'
1112

@@ -67,7 +68,7 @@ const getNetlifyNextServer = (NextServer: NextServerType) => {
6768
// conditionally use the prebundled React module
6869
// PrebundledReact should only apply when appDir is set it falls between the specified Next versions
6970
const { experimental }: NextConfigWithAppDir = this.nextConfig
70-
const version = await nextVersionNum()
71+
const version = await nextVersionNum(satisfies)
7172
if (experimental?.appDir && version) this.netlifyPrebundleReact(url, this.nextConfig, parsedUrl)
7273

7374
// intercept on-demand revalidation requests and handle with the Netlify API

0 commit comments

Comments
 (0)