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 #
This commit is contained in:
Reino Muhl 2024-09-12 09:19:40 -04:00
Родитель 5cbed82649
Коммит 66023d562f
Не найден ключ, соответствующий данной подписи
3 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -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: [

Просмотреть файл

@ -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,
});

Просмотреть файл

@ -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