Skip to content

Commit bb9569d

Browse files
committed
fix: correct jsonc import for build
1 parent f8dd319 commit bb9569d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/api/schemas/[name]/route.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NextResponse } from "next/server";
22
import fs from "fs/promises";
33
import path from "path";
4-
// Import 'parse' as a named export with an alias
5-
import { parse as jsoncParse } from "jsonc";
4+
// Correct the import for the 'jsonc' library
5+
import * as jsonc from "jsonc";
66

77
// Remove the explicit RouteContext interface
88
// interface RouteContext {
@@ -67,9 +67,11 @@ export async function GET(
6767
// Parse JSONC (JSON with comments) for validation
6868
try {
6969
// Check if jsoncParse is a function before calling (optional safety)
70-
if (typeof jsoncParse === 'function') {
70+
// Use the imported jsonc namespace
71+
if (typeof jsonc.parse === 'function') {
7172
// Use the imported jsoncParse function directly
72-
jsoncParse(fileContent);
73+
// Call parse via the jsonc namespace
74+
jsonc.parse(fileContent);
7375
} else {
7476
// Handle the case where jsonc or jsonc.parse is not loaded correctly
7577
console.error(`[API /api/schemas/${name}] jsonc.parse function not found.`);

0 commit comments

Comments
 (0)