From 5e37d10300ec42fedd5b22977aa2665782355bdd Mon Sep 17 00:00:00 2001 From: gibbyb Date: Sat, 21 Mar 2026 17:20:57 -0500 Subject: [PATCH] I think we might finally have the env crap figured out --- apps/next/next.config.js | 15 +++++++++------ apps/next/src/app/global-error.tsx | 4 ++-- apps/next/src/app/layout.tsx | 4 ++-- apps/next/src/{env.js => env.ts} | 0 apps/next/src/instrumentation-client.ts | 2 +- apps/next/src/sentry.server.config.ts | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) rename apps/next/src/{env.js => env.ts} (100%) diff --git a/apps/next/next.config.js b/apps/next/next.config.js index 5e83130..d67d2b2 100644 --- a/apps/next/next.config.js +++ b/apps/next/next.config.js @@ -1,7 +1,10 @@ -import { env } from './src/env.js'; +import { createJiti } from 'jiti'; import { withSentryConfig } from '@sentry/nextjs'; import { withPlausibleProxy } from 'next-plausible'; +const jiti = createJiti(import.meta.url); +await jiti.import('./src/env'); + /** @type {import("next").NextConfig} */ const config = withPlausibleProxy({ customDomain: process.env.NEXT_PUBLIC_PLAUSIBLE_URL, @@ -29,12 +32,12 @@ const config = withPlausibleProxy({ const sentryConfig = { // For all available options, see: // https://www.npmjs.com/package/@sentry/webpack-plugin#options - org: env.NEXT_PUBLIC_SENTRY_ORG, - project: env.NEXT_PUBLIC_SENTRY_PROJECT_NAME, - sentryUrl: env.NEXT_PUBLIC_SENTRY_URL, - authToken: env.SENTRY_AUTH_TOKEN, + org: process.env.NEXT_PUBLIC_SENTRY_ORG, + project: process.env.NEXT_PUBLIC_SENTRY_PROJECT_NAME, + sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL, + authToken: process.env.SENTRY_AUTH_TOKEN, // Only print logs for uploading source maps in CI - silent: !env.CI, + silent: !process.env.CI, // For all available options, see: // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ // Upload a larger set of source maps for prettier stack traces (increases build time) diff --git a/apps/next/src/app/global-error.tsx b/apps/next/src/app/global-error.tsx index a768c90..5154cec 100644 --- a/apps/next/src/app/global-error.tsx +++ b/apps/next/src/app/global-error.tsx @@ -15,7 +15,7 @@ import * as Sentry from '@sentry/nextjs'; import PlausibleProvider from 'next-plausible'; import { Button, ThemeProvider, Toaster } from '@gib/ui'; -import { env } from '@/env.js'; +import { env } from '@/env'; export const metadata: Metadata = generateMetadata(); @@ -46,7 +46,7 @@ const GlobalError = ({ error, reset = undefined }: GlobalErrorProps) => { }, [error]); return ( diff --git a/apps/next/src/app/layout.tsx b/apps/next/src/app/layout.tsx index f9d734d..f8ff122 100644 --- a/apps/next/src/app/layout.tsx +++ b/apps/next/src/app/layout.tsx @@ -1,6 +1,6 @@ import type { Metadata, Viewport } from 'next'; import { Geist, Geist_Mono } from 'next/font/google'; -import { env } from '@/env.js'; +import { env } from '@/env'; import '@/app/styles.css'; @@ -39,7 +39,7 @@ const RootLayout = ({ return ( diff --git a/apps/next/src/env.js b/apps/next/src/env.ts similarity index 100% rename from apps/next/src/env.js rename to apps/next/src/env.ts diff --git a/apps/next/src/instrumentation-client.ts b/apps/next/src/instrumentation-client.ts index 65d301f..269fb91 100644 --- a/apps/next/src/instrumentation-client.ts +++ b/apps/next/src/instrumentation-client.ts @@ -1,6 +1,6 @@ // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import * as Sentry from '@sentry/nextjs'; -import { env } from '@/env.js'; +import { env } from '@/env'; Sentry.init({ dsn: env.NEXT_PUBLIC_SENTRY_DSN, diff --git a/apps/next/src/sentry.server.config.ts b/apps/next/src/sentry.server.config.ts index b4d7780..19095bf 100644 --- a/apps/next/src/sentry.server.config.ts +++ b/apps/next/src/sentry.server.config.ts @@ -1,5 +1,5 @@ import * as Sentry from '@sentry/nextjs'; -import { env } from '@/env.js'; +import { env } from '@/env'; Sentry.init({ dsn: env.NEXT_PUBLIC_SENTRY_DSN,