From 66023d562fc5da2d0bc772780af94944286957ca Mon Sep 17 00:00:00 2001 From: Reino Muhl <10620585+StaberindeZA@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:19:40 -0400 Subject: [PATCH] fix(next): resolve package import version warnings Because: - Importing package.json in sentry config files resulted in build warning 'Should not import the named export' This commit: - Add package version as env var added to js bundle by nextjs Closes # --- apps/payments/next/next.config.js | 4 ++++ apps/payments/next/sentry.client.config.ts | 3 +-- apps/payments/next/sentry.server.config.ts | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/payments/next/next.config.js b/apps/payments/next/next.config.js index 21a45564f9b..bfdab67f129 100644 --- a/apps/payments/next/next.config.js +++ b/apps/payments/next/next.config.js @@ -7,6 +7,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const { composePlugins, withNx } = require('@nx/next'); const { withSentryConfig } = require('@sentry/nextjs'); +const { version } = require('./package.json'); /** * @type {import('@nx/next/plugins/with-nx').WithNxOptions} @@ -17,6 +18,9 @@ const nextConfig = { // See: https://github.com/gregberge/svgr svgr: false, }, + env: { + version, + }, experimental: { instrumentationHook: true, serverComponentsExternalPackages: [ diff --git a/apps/payments/next/sentry.client.config.ts b/apps/payments/next/sentry.client.config.ts index ebcb19de740..78d4b47d4ab 100644 --- a/apps/payments/next/sentry.client.config.ts +++ b/apps/payments/next/sentry.client.config.ts @@ -6,7 +6,6 @@ // The config you add here will be used whenever a users loads a page in their browser. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import { initSentryForNextjsClient } from '@fxa/shared/sentry/client'; -import { version } from './package.json'; const DEFAULT_SAMPLE_RATE = '1'; const DEFAULT_TRACES_SAMPLE_RATE = '1'; @@ -25,6 +24,6 @@ const sentryConfig = { }; initSentryForNextjsClient({ - release: version, + release: process.env.version, sentry: sentryConfig, }); diff --git a/apps/payments/next/sentry.server.config.ts b/apps/payments/next/sentry.server.config.ts index 874e481433a..09c5b9d475a 100644 --- a/apps/payments/next/sentry.server.config.ts +++ b/apps/payments/next/sentry.server.config.ts @@ -7,7 +7,6 @@ // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import { initSentryForNextjsServer } from '@fxa/shared/sentry'; import { config } from './config'; -import { version } from './package.json'; const sentryConfig = { dsn: config.nextPublicSentryDsn, @@ -19,7 +18,7 @@ const sentryConfig = { initSentryForNextjsServer( { - release: version, + release: process.env.version, sentry: sentryConfig, }, console