Skip to content

Commit a72a837

Browse files
authored
feat: Set experimentalRegion to 'context' in order to enable colocated blobs (#488)
1 parent c0ab50b commit a72a837

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/build/plugin-context.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,18 @@ test('nx monorepo with package path and different distDir', () => {
195195
expect(ctx.relPublishDir).toBe('dist/apps/my-app/.next')
196196
expect(ctx.publishDir).toBe(join(cwd, 'dist/apps/my-app/.next'))
197197
})
198+
199+
test('should use deploy configuration blobs directory when @netlify/build version supports regional blob awareness', () => {
200+
const { cwd } = mockFileSystem({
201+
'.next/required-server-files.json': JSON.stringify({
202+
config: { distDir: '.next' },
203+
relativeAppDir: '',
204+
} as RequiredServerFilesManifest),
205+
})
206+
207+
const ctx = new PluginContext({
208+
constants: { NETLIFY_BUILD_VERSION: '29.41.5' },
209+
} as NetlifyPluginOptions)
210+
211+
expect(ctx.blobDir).toBe(join(cwd, '.netlify/deploy/v1/blobs/deploy'))
212+
})

src/build/plugin-context.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
import type { PrerenderManifest, RoutesManifest } from 'next/dist/build/index.js'
1414
import type { MiddlewareManifest } from 'next/dist/build/webpack/plugins/middleware-plugin.js'
1515
import type { NextConfigComplete } from 'next/dist/server/config-shared.js'
16+
import { satisfies } from 'semver'
1617

1718
const MODULE_DIR = fileURLToPath(new URL('.', import.meta.url))
1819
const PLUGIN_DIR = join(MODULE_DIR, '../..')
@@ -151,8 +152,9 @@ export class PluginContext {
151152
}
152153

153154
get useRegionalBlobs(): boolean {
154-
// Disabling regional blobs until feature is ready for production (see FRA-436)
155-
return false
155+
// Region-aware blobs are only available as of CLI v17.23.5 (i.e. Build v29.41.5)
156+
const REQUIRED_BUILD_VERSION = '>=29.41.5'
157+
return satisfies(this.buildVersion, REQUIRED_BUILD_VERSION, { includePrerelease: true })
156158
}
157159

158160
/**

tests/utils/helpers.ts

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const startMockBlobStore = async (ctx: FixtureTestContext) => {
7474
ctx.blobStore = getDeployStore({
7575
apiURL: `http://${ctx.blobStoreHost}`,
7676
deployID: ctx.deployID,
77+
experimentalRegion: 'context',
7778
siteID: ctx.siteID,
7879
token: BLOB_TOKEN,
7980
})
@@ -88,6 +89,7 @@ export const getBlobEntries = async (ctx: FixtureTestContext) => {
8889
: getDeployStore({
8990
apiURL: `http://${ctx.blobStoreHost}`,
9091
deployID: ctx.deployID,
92+
experimentalRegion: 'context',
9193
siteID: ctx.siteID,
9294
token: BLOB_TOKEN,
9395
})

0 commit comments

Comments
 (0)