diff --git a/src/lib/build.ts b/src/lib/build.ts index 7291ad3a699..15258061df9 100644 --- a/src/lib/build.ts +++ b/src/lib/build.ts @@ -5,7 +5,7 @@ import build from '@netlify/build' // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'toml... Remove this comment to see the full error message import tomlify from 'tomlify-j0.4' -import { isFeatureFlagEnabled } from '../utils/feature-flags.js' +import { getFeatureFlagsFromSiteInfo } from '../utils/feature-flags.js' import { getBootstrapURL } from './edge-functions/bootstrap.js' import { featureFlags as edgeFunctionsFeatureFlags } from './edge-functions/consts.js' @@ -93,17 +93,6 @@ export const getBuildOptions = ({ } } -/** - * @param {*} siteInfo - * @returns {Record} - */ -// @ts-expect-error TS(7006) FIXME: Parameter 'siteInfo' implicitly has an 'any' type. -const getFeatureFlagsFromSiteInfo = (siteInfo) => ({ - ...siteInfo.feature_flags, - // see https://github.com/netlify/pod-dev-foundations/issues/581#issuecomment-1731022753 - zisi_golang_use_al2: isFeatureFlagEnabled('cli_golang_use_al2', siteInfo), -}) - /** * run the build command * @param {BuildConfig} options diff --git a/src/utils/feature-flags.ts b/src/utils/feature-flags.ts index ebac454f42f..2730a7a2d40 100644 --- a/src/utils/feature-flags.ts +++ b/src/utils/feature-flags.ts @@ -13,3 +13,14 @@ // @ts-expect-error TS(7006) FIXME: Parameter 'flagName' implicitly has an 'any' type. export const isFeatureFlagEnabled = (flagName: string, siteInfo): boolean => Boolean(siteInfo.feature_flags && siteInfo.feature_flags[flagName] !== false) + +/** + * Retrieves all Feature flags from the siteInfo + */ +export const getFeatureFlagsFromSiteInfo = (siteInfo: { + feature_flags?: Record +}): Record => ({ + ...(siteInfo.feature_flags || {}), + // see https://github.com/netlify/pod-dev-foundations/issues/581#issuecomment-1731022753 + zisi_golang_use_al2: isFeatureFlagEnabled('cli_golang_use_al2', siteInfo), +}) diff --git a/src/utils/run-build.ts b/src/utils/run-build.ts index 6fb765ee961..ed9038c4a20 100644 --- a/src/utils/run-build.ts +++ b/src/utils/run-build.ts @@ -8,6 +8,7 @@ import { getPathInProject } from '../lib/settings.js' import { error } from './command-helpers.js' import { startFrameworkServer } from './framework-server.js' import { INTERNAL_FUNCTIONS_FOLDER } from './functions/index.js' +import { getFeatureFlagsFromSiteInfo } from './feature-flags.js' const netlifyBuildPromise = import('@netlify/build') @@ -71,6 +72,7 @@ export const runNetlifyBuild = async ({ command, env = {}, options, settings, ti mode: 'cli', telemetry: false, buffer: false, + featureFlags: getFeatureFlagsFromSiteInfo(cachedConfig.siteInfo), offline: options.offline, packagePath: command.workspacePackage, cwd: cachedConfig.buildDir,