Skip to content

fix: use IMAGE_FUNCTION_NAME constant #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/runtime/src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { NextConfigComplete } from 'next/dist/server/config-shared'
import { join, dirname, relative } from 'pathe'
import slash from 'slash'

import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME } from '../constants'
import { HANDLER_FUNCTION_NAME, IMAGE_FUNCTION_NAME, ODB_FUNCTION_NAME } from '../constants'

import type { RoutesManifest } from './types'
import { escapeStringRegexp } from './utils'
Expand Down Expand Up @@ -107,18 +107,16 @@ export const configureHandlerFunctions = async ({
const files = config.files || []
const cssFilesToInclude = files.filter((f) => f.startsWith(`${publish}/static/css/`))

/* eslint-disable no-underscore-dangle */
if (!destr(process.env.DISABLE_IPX)) {
netlifyConfig.functions._ipx ||= {}
netlifyConfig.functions._ipx.node_bundler = 'nft'
netlifyConfig.functions[IMAGE_FUNCTION_NAME] ||= {}
netlifyConfig.functions[IMAGE_FUNCTION_NAME].node_bundler = 'nft'
}

// If the user has manually added the module to included_files, then don't exclude it
const excludedModules = DEFAULT_EXCLUDED_MODULES.filter(
(moduleName) => !hasManuallyAddedModule({ netlifyConfig, moduleName }),
)

/* eslint-enable no-underscore-dangle */
;[HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, '_api_*'].forEach((functionName) => {
netlifyConfig.functions[functionName] ||= { included_files: [], external_node_modules: [] }
netlifyConfig.functions[functionName].node_bundler = 'nft'
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/helpers/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { MiddlewareManifest } from 'next/dist/build/webpack/plugins/middlew
import type { RouteHas } from 'next/dist/lib/load-custom-routes'
import { outdent } from 'outdent'

import { IMAGE_FUNCTION_NAME } from '../constants'

import { getRequiredServerFiles, NextConfig } from './config'
import { makeLocaleOptional, stripLookahead, transformCaptureGroups } from './matchers'
import { RoutesManifest } from './types'
Expand Down Expand Up @@ -465,7 +467,7 @@ export const writeEdgeFunctions = async ({
await ensureDir(edgeFunctionDir)
await copyEdgeSourceFile({ edgeFunctionDir, file: 'ipx.ts', target: 'index.ts' })
await copyFile(
join('.netlify', 'functions-internal', '_ipx', 'imageconfig.json'),
join('.netlify', 'functions-internal', IMAGE_FUNCTION_NAME, 'imageconfig.json'),
join(edgeFunctionDir, 'imageconfig.json'),
)
manifest.functions.push({
Expand Down