Skip to content

Commit f6d4661

Browse files
mrstorkpieh
andauthored
chore: add feature flag for regional blobs to allow for incremental rollout (#489)
Co-authored-by: Michal Piechowiak <[email protected]>
1 parent 47fe6d8 commit f6d4661

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/build/plugin-context.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ test('should use deploy configuration blobs directory when @netlify/build versio
206206

207207
const ctx = new PluginContext({
208208
constants: { NETLIFY_BUILD_VERSION: '29.41.5' },
209-
} as NetlifyPluginOptions)
209+
featureFlags: { 'next-runtime-regional-blobs': true },
210+
} as unknown as NetlifyPluginOptions)
210211

211212
expect(ctx.blobDir).toBe(join(cwd, '.netlify/deploy/v1/blobs/deploy'))
212213
})

src/build/plugin-context.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ export interface ExportDetail {
3939
}
4040

4141
export class PluginContext {
42-
utils: NetlifyPluginUtils
42+
featureFlags: NetlifyPluginOptions['featureFlags']
4343
netlifyConfig: NetlifyPluginOptions['netlifyConfig']
4444
pluginName: string
4545
pluginVersion: string
46+
utils: NetlifyPluginUtils
4647

4748
private constants: NetlifyPluginConstants
4849
private packageJSON: { name: string; version: string } & Record<string, unknown>
@@ -152,6 +153,10 @@ export class PluginContext {
152153
}
153154

154155
get useRegionalBlobs(): boolean {
156+
if (!(this.featureFlags || {})['next-runtime-regional-blobs']) {
157+
return false
158+
}
159+
155160
// Region-aware blobs are only available as of CLI v17.23.5 (i.e. Build v29.41.5)
156161
const REQUIRED_BUILD_VERSION = '>=29.41.5'
157162
return satisfies(this.buildVersion, REQUIRED_BUILD_VERSION, { includePrerelease: true })
@@ -198,12 +203,13 @@ export class PluginContext {
198203
}
199204

200205
constructor(options: NetlifyPluginOptions) {
206+
this.constants = options.constants
207+
this.featureFlags = options.featureFlags
208+
this.netlifyConfig = options.netlifyConfig
201209
this.packageJSON = JSON.parse(readFileSync(join(PLUGIN_DIR, 'package.json'), 'utf-8'))
202210
this.pluginName = this.packageJSON.name
203211
this.pluginVersion = this.packageJSON.version
204-
this.constants = options.constants
205212
this.utils = options.utils
206-
this.netlifyConfig = options.netlifyConfig
207213
}
208214

209215
/** Resolves a path correctly with mono repository awareness for .netlify directories mainly */

0 commit comments

Comments
 (0)