Skip to content

Commit f9f726f

Browse files
committed
fix: update flag impl
1 parent 89fd2fb commit f9f726f

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

.github/workflows/e2e-appdir.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
push:
77
branches: [main]
88

9+
env:
10+
NEXT_SPLIT_API_ROUTES: true
11+
912
jobs:
1013
setup:
1114
runs-on: ubuntu-latest

.github/workflows/e2e-next.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
schedule:
99
- cron: '0 0 * * *'
1010

11+
env:
12+
NEXT_SPLIT_API_ROUTES: true
13+
1114
jobs:
1215
setup:
1316
runs-on: ubuntu-latest

.github/workflows/test-integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1010
cancel-in-progress: true
1111

12+
env:
13+
NEXT_SPLIT_API_ROUTES: true
14+
1215
jobs:
1316
build:
1417
name: Integration tests

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1212
cancel-in-progress: true
1313

14+
env:
15+
NEXT_SPLIT_API_ROUTES: true
16+
1417
jobs:
1518
build:
1619
name: Unit tests

packages/runtime/src/helpers/flags.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import destr from 'destr'
2+
13
/**
24
* If this flag is enabled, we generate individual Lambda functions for API Routes.
35
* They're packed together in 50mb chunks to avoid hitting the Lambda size limit.
@@ -9,13 +11,7 @@
911
* If disabled, we bundle all API Routes into a single function.
1012
* This is can lead to large bundle sizes.
1113
*
12-
* Enabled by default. Can be disabled by passing NEXT_SPLIT_API_ROUTES=false.
14+
* Disabled by default. Can be overriden using the NEXT_SPLIT_API_ROUTES env var.
1315
*/
14-
15-
export const splitApiRoutes = (featureFlags: Record<string, unknown>): boolean => {
16-
if (process.env.NEXT_SPLIT_API_ROUTES) {
17-
return process.env.NEXT_SPLIT_API_ROUTES === 'true'
18-
}
19-
// default to true during testing, swap to false before merging
20-
return typeof featureFlags.next_split_api_routes === 'boolean' ? featureFlags.next_split_api_routes : true
21-
}
16+
export const splitApiRoutes = (featureFlags: Record<string, unknown>): boolean =>
17+
destr(process.env.NEXT_SPLIT_API_ROUTES) ?? featureFlags.next_split_api_routes ?? false

0 commit comments

Comments
 (0)