From 9a6a19592bba6d79828915ec38496b0ed439bfbe Mon Sep 17 00:00:00 2001 From: Ed Stephinson Date: Fri, 15 Sep 2023 12:10:33 +0100 Subject: [PATCH] fix: merge feature flags with returned values from API to enrich flag availability in config --- packages/config/src/main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/config/src/main.ts b/packages/config/src/main.ts index 2eba5eac01..609f9391f4 100644 --- a/packages/config/src/main.ts +++ b/packages/config/src/main.ts @@ -63,7 +63,7 @@ export const resolveConfig = async function (opts) { mode, debug, logs, - featureFlags, + featureFlags: passedFeatureFlags, } = await normalizeOpts(optsA) const { siteInfo, accounts, addons, integrations } = await getSiteInfo({ @@ -72,10 +72,15 @@ export const resolveConfig = async function (opts) { mode, offline, siteFeatureFlagPrefix, - featureFlags, + featureFlags: passedFeatureFlags, testOpts, }) + // Feature flags can also be loaded from the call to `getSiteInfo()`, in the CLI + // these won't be accessible within the calls to `netlify-config` as they're fetched + // too late. We merge them here to ensure they're available to this package. + const featureFlags = { ...passedFeatureFlags, ...(siteInfo.feature_flags ?? {}) } + const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({ defaultConfig, base,