From 9243f6ff4e239d6008f59623dd4c9e1c32c771f3 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Mon, 21 Jul 2025 16:12:24 -0500 Subject: [PATCH] Fix Vercel ES module import issues - Change JSON import to use require() to avoid module loading issues - Add api/tsconfig.json with CommonJS module configuration - Update Vercel Node.js runtime to @vercel/node@3.2.0 - Add buildCommand to vercel.json for proper compilation - Fix 'Cannot use import statement outside a module' error --- api/migrate.ts | 4 +++- api/tsconfig.json | 22 ++++++++++++++++++++++ vercel.json | 5 +++-- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 api/tsconfig.json diff --git a/api/migrate.ts b/api/migrate.ts index 6daaea4..dc6d655 100644 --- a/api/migrate.ts +++ b/api/migrate.ts @@ -1,6 +1,8 @@ import { NextRequest, NextResponse } from 'next/server'; import { Pool } from 'pg'; -import cardsData from '../src/data/cards.json'; + +// Use require for JSON import to avoid module issues +const cardsData = require('../src/data/cards.json'); // Create PostgreSQL connection pool const pool = new Pool({ diff --git a/api/tsconfig.json b/api/tsconfig.json new file mode 100644 index 0000000..18603cf --- /dev/null +++ b/api/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "moduleResolution": "node", + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "declaration": false, + "outDir": "./dist" + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules", + "dist" + ] +} \ No newline at end of file diff --git a/vercel.json b/vercel.json index a024fa7..be81e47 100644 --- a/vercel.json +++ b/vercel.json @@ -52,7 +52,8 @@ ], "functions": { "api/**/*.ts": { - "runtime": "@vercel/node@3.0.7" + "runtime": "@vercel/node@3.2.0" } - } + }, + "buildCommand": "npm run build" }