Skip to content

Commit 4127fda

Browse files
author
apex-ai-net
committed
fix(build): resolve stripeCustomer import - remove .ts extension, use eval('import') to prevent client bundling
- Replace 'await import(./stripeCustomer.ts)' with eval('import') pattern - Apply same fix to serviceResolver.ts payments import - Prevents webpack/esbuild from including server-only Stripe code in client bundle - Resolves Netlify build failures (exit code 2) - Fixes TypeScript allowImportingTsExtensions constraint Refs: PR #10 fix from chore/netlify-build-fixes branch
1 parent a42d6bc commit 4127fda

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

lib/supabase/serviceResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as matchesService from './services/matches';
2020
// trying to resolve './services/payments' (and its Stripe dependencies) in the browser.
2121
type PaymentsServiceModule = typeof import('./services/payments');
2222
async function loadPaymentsService(): Promise<PaymentsServiceModule> {
23-
return await import('./services/payments');
23+
return await (0, eval)("import")('./services/payments') as PaymentsServiceModule;
2424
}
2525
import * as messagesService from './services/messages';
2626
import * as chatbotService from './services/chatbot';

lib/supabase/services/payments.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,10 @@ export async function createStudentCheckoutSession(
460460
// Get or create Stripe customer for this user
461461
let stripeCustomerId: string | undefined;
462462
try {
463-
// Dynamically import server-only helper to avoid bundling in client code.
464-
// Use explicit extension to satisfy certain bundlers/runtimes during production builds.
465-
const { getOrCreateCustomer } = await import('./stripeCustomer.ts');
463+
// Dynamically import server-only helper to avoid bundler static analysis in client builds.
464+
// Using eval('import') prevents webpack/esbuild from pre-resolving this in the client bundle.
465+
const stripeCustomerModule = await (0, eval)("import")('./stripeCustomer') as typeof import('./stripeCustomer');
466+
const { getOrCreateCustomer } = stripeCustomerModule;
466467
stripeCustomerId = await getOrCreateCustomer(
467468
supabase,
468469
userId,

0 commit comments

Comments
 (0)