Skip to content

Commit 163111f

Browse files
committed
chore: refactor some names
1 parent fce7ec3 commit 163111f

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

src/helpers/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { RUNTIME_DIR } from './constants.js'
55
/**
66
* Enable Next.js standalone mode
77
*/
8-
export const setBuildtimeConfig = () => {
8+
export const setBuildConfig = () => {
99
process.env.NEXT_PRIVATE_STANDALONE = 'true'
1010
}
1111

12-
export const setRuntimeConfig = async () => {
12+
export const setRequestConfig = async () => {
1313
const runtimeConfig = JSON.parse(await readFile('./.next/required-server-files.json', 'utf-8'))
1414

1515
// set the path to the cache handler

src/helpers/files.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { copySync, moveSync } from 'fs-extra/esm'
66
import { NEXT_BUILD_DIR } from './constants.js'
77

88
/**
9-
* Stash the Next.js build output in a temporary directory
9+
* Move the Next.js build output to a temporary directory
1010
*/
11-
export const stashBuildOutput = ({ PUBLISH_DIR }: NetlifyPluginConstants) => {
11+
export const moveBuildOutput = ({ PUBLISH_DIR }: NetlifyPluginConstants) => {
1212
moveSync(PUBLISH_DIR, NEXT_BUILD_DIR, { overwrite: true })
1313
}
1414

src/helpers/functions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const pkg = readJsonSync(`${PLUGIN_DIR}/package.json`)
1313
* @param config Netlify config
1414
*/
1515
export const createServerHandler = async () => {
16-
// clear the server handler directory
16+
// clear the handler directory
1717
emptyDirSync(SERVER_HANDLER_DIR)
1818

19-
// trace the server handler dependencies
19+
// trace the handler dependencies
2020
const { fileList } = await nodeFileTrace(
2121
[`${PLUGIN_DIR}/dist/templates/server-handler.js`, `${PLUGIN_DIR}/dist/templates/cache-handler.cjs`],
2222
{ base: PLUGIN_DIR, ignore: ['package.json', 'node_modules/next/**'] },
@@ -27,11 +27,11 @@ export const createServerHandler = async () => {
2727
copySync(`${PLUGIN_DIR}/${path}`, `${SERVER_HANDLER_DIR}/${path}`)
2828
})
2929

30-
// copy the next.js standalone build output to the server handler directory
30+
// copy the next.js standalone build output to the handler directory
3131
copySync(`${NEXT_BUILD_DIR}/standalone/.next`, `${SERVER_HANDLER_DIR}/.next`)
3232
copySync(`${NEXT_BUILD_DIR}/standalone/node_modules`, `${SERVER_HANDLER_DIR}/node_modules`)
3333

34-
// create the server handler metadata file
34+
// create the handler metadata file
3535
writeJSONSync(`${SERVER_HANDLER_DIR}/${SERVER_HANDLER_NAME}.json`, {
3636
config: {
3737
name: 'Next.js Server Handler',
@@ -43,8 +43,10 @@ export const createServerHandler = async () => {
4343
version: 1,
4444
})
4545

46+
// config ESM
4647
writeFileSync(`${SERVER_HANDLER_DIR}/package.json`, JSON.stringify({ type: 'module' }))
4748

49+
// write the root handler file
4850
writeFileSync(
4951
`${SERVER_HANDLER_DIR}/${SERVER_HANDLER_NAME}.js`,
5052
`import handler from './dist/templates/server-handler.js';export default handler;export const config = { path: '/*' }`,

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import type { NetlifyPluginOptions } from '@netlify/build'
22

3-
import { setBuildtimeConfig } from './helpers/config.js'
4-
import { moveStaticAssets, stashBuildOutput } from './helpers/files.js'
3+
import { setBuildConfig } from './helpers/config.js'
4+
import { moveStaticAssets, moveBuildOutput } from './helpers/files.js'
55
import { createServerHandler } from './helpers/functions.js'
66

77
type NetlifyPluginOptionsWithFlags = NetlifyPluginOptions & { featureFlags?: Record<string, unknown> }
88

99
export const onPreBuild = () => {
10-
setBuildtimeConfig()
10+
setBuildConfig()
1111
}
1212

1313
export const onBuild = async ({ constants }: NetlifyPluginOptionsWithFlags) => {
14-
stashBuildOutput(constants)
14+
moveBuildOutput(constants)
1515
moveStaticAssets(constants)
1616
await createServerHandler()
1717
}

src/templates/server-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ let nextHandler: WorkerRequestHandler
88
export default async (request: Request) => {
99
if (!nextHandler) {
1010
// set the server config
11-
const { setRuntimeConfig } = await import('../helpers/config.js')
12-
await setRuntimeConfig()
11+
const { setRequestConfig } = await import('../helpers/config.js')
12+
await setRequestConfig()
1313

1414
// let Next.js initialize and create the request handler
1515
const { getRequestHandlers } = await import('next/dist/server/lib/start-server.js')

0 commit comments

Comments
 (0)