Skip to content

Commit f4e7509

Browse files
committed
fix: reset
1 parent ba66880 commit f4e7509

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

packages/runtime/src/helpers/functions.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { getResolverForPages, getResolverForSourceFiles } from '../templates/get
2828
import { ApiConfig, extractConfigFromFile, isEdgeConfig } from './analysis'
2929
import { getRequiredServerFiles } from './config'
3030
import { getDependenciesOfFile, getServerFile, getSourceFileForPage } from './files'
31-
import { writeFunctionConfiguration, nextVersionNum } from './functionsMetaData'
31+
import { writeFunctionConfiguration } from './functionsMetaData'
3232
import { pack } from './pack'
3333
import { ApiRouteType } from './types'
3434
import { getFunctionNameForPage } from './utils'
@@ -132,13 +132,11 @@ export const generateFunctions = async (
132132
}
133133

134134
const writeHandler = async (functionName: string, functionTitle: string, isODB: boolean) => {
135-
const useHooks = await nextVersionNum()
136135
const handlerSource = getHandler({
137136
isODB,
138137
publishDir,
139138
appDir: relative(functionDir, appDir),
140139
nextServerModuleRelativeLocation,
141-
useHooks,
142140
})
143141
await ensureDir(join(functionsDir, functionName))
144142

packages/runtime/src/templates/getHandler.ts

+11-16
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,11 @@ type MakeHandlerParams = {
4040
NextServer: NextServerType
4141
staticManifest: Array<[string, string]>
4242
mode: 'ssr' | 'odb'
43-
useHooks: boolean
4443
}
4544

4645
// We return a function and then call `toString()` on it to serialise it as the launcher function
4746
// eslint-disable-next-line max-lines-per-function
48-
const makeHandler = ({
49-
conf,
50-
app,
51-
pageRoot,
52-
NextServer,
53-
staticManifest = [],
54-
mode = 'ssr',
55-
useHooks,
56-
}: MakeHandlerParams) => {
47+
const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mode = 'ssr' }: MakeHandlerParams) => {
5748
// Change working directory into the site root, unless using Nx, which moves the
5849
// dist directory and handles this itself
5950
const dir = path.resolve(__dirname, app)
@@ -70,10 +61,15 @@ const makeHandler = ({
7061
const { appDir }: ExperimentalConfigWithLegacy = conf.experimental
7162
// Next 13.4 conditionally uses different React versions and we need to make sure we use the same one
7263
// With the release of 13.5 experimental.appDir is no longer used.
73-
// we will need to check if appDir is set and Next version before running requireHook
74-
if (appDir && useHooks) return overrideRequireHooks(conf.experimental)
64+
// we will need to check if appDir is set and Next version before running requireHooks
65+
// const runRequireHooks = async (hook) =>
66+
// await nextVersionNum()
67+
// .then((version) => (appDir && version ? hook : null))
68+
// .catch(() => ({}))
69+
70+
if (appDir) overrideRequireHooks(conf.experimental)
7571
const NetlifyNextServer: NetlifyNextServerType = getNetlifyNextServer(NextServer)
76-
if (appDir && useHooks) return applyRequireHooks()
72+
if (appDir) applyRequireHooks()
7773

7874
const ONE_YEAR_IN_SECONDS = 31536000
7975

@@ -218,7 +214,6 @@ export const getHandler = ({
218214
publishDir = '../../../.next',
219215
appDir = '../../..',
220216
nextServerModuleRelativeLocation,
221-
useHooks,
222217
}): string =>
223218
// This is a string, but if you have the right editor plugin it should format as js (e.g. bierner.comment-tagged-templates in VS Code)
224219
javascript/* javascript */ `
@@ -246,7 +241,7 @@ export const getHandler = ({
246241
const pageRoot = path.resolve(path.join(__dirname, "${publishDir}", "server"));
247242
exports.handler = ${
248243
isODB
249-
? `builder((${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'odb', useHooks: ${useHooks} }));`
250-
: `(${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'ssr', useHooks: ${useHooks} });`
244+
? `builder((${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'odb'}));`
245+
: `(${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'ssr'});`
251246
}
252247
`

0 commit comments

Comments
 (0)