Skip to content

Commit 064c1dd

Browse files
committed
chore(config): enhance build performance with caching and memory optimizations
1 parent e8d2d04 commit 064c1dd

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

.github/workflows/CI.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ jobs:
2323
node-version: 20
2424
cache: "pnpm"
2525

26+
# Setup .next/cache directory cache
27+
- name: Setup Next.js cache
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
.next/cache
32+
${{ github.workspace }}/.next/cache
33+
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
34+
restore-keys: |
35+
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
36+
${{ runner.os }}-nextjs-
37+
2638
- name: Install dependencies
2739
run: pnpm install
2840

@@ -34,6 +46,9 @@ jobs:
3446

3547
- name: Build
3648
run: pnpm build
49+
env:
50+
NEXT_TELEMETRY_DISABLED: 1
51+
NODE_OPTIONS: "--max_old_space_size=4096"
3752

3853
- name: Install Playwright Browsers
3954
run: npx playwright install --with-deps

app/api/get-schema/[name]/route.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextResponse, NextRequest } from "next/server";
1+
import { NextResponse } from "next/server";
22
import fs from "fs/promises";
33
import path from "path";
44

@@ -20,12 +20,8 @@ function safeJoin(base: string, target: string): string | null {
2020
return null; // Path traversal detected or invalid path
2121
}
2222

23-
export async function GET(
24-
// Remove the request parameter as it's unused
25-
// request: NextRequest,
26-
{ params }: { params: { name: string } } // Use standard destructuring for the context/params
27-
) {
28-
const schemaName = params.name; // Access name via params
23+
export async function GET(request: Request, { params }: { params: { name: string } }) {
24+
const schemaName = params.name;
2925

3026
if (!schemaName) {
3127
return NextResponse.json({ error: "Schema name required" }, { status: 400 });
@@ -49,7 +45,7 @@ export async function GET(
4945
return NextResponse.json({ error: "Invalid schema name path" }, { status: 400 });
5046
}
5147

52-
console.log(`Attempting to read schema file: ${filePath}`); // Add logging
48+
console.log(`Attempting to read schema file: ${filePath}`);
5349

5450
const fileContent = await fs.readFile(filePath, "utf-8");
5551
// Assert the type after parsing JSON to satisfy eslint

next.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ const nextConfig = {
2929
images: {
3030
unoptimized: true,
3131
},
32+
33+
// Configure build cache
34+
experimental: {
35+
turbotrace: {
36+
enabled: true,
37+
},
38+
},
39+
40+
// Increase memory limit for builds
41+
onDemandEntries: {
42+
maxInactiveAge: 25 * 1000,
43+
pagesBufferLength: 4,
44+
},
3245
};
3346

3447
export default nextConfig;

0 commit comments

Comments
 (0)