Skip to content

Next.js SDK incompatibility with bundle analyzer #6336

Closed
@yhuang1211

Description

@yhuang1211

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.22.0

Framework Version

13.0.5

Link to Sentry event

No response

Steps to Reproduce

After upgrading @sentry/nextjs from 7.21.1 to 7.22.0, the environment variables in next.config.js get dropped and can no longer be accessed from next app.

// next.config.js
const { withSentryConfig } = require("@sentry/nextjs");
const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: process.env.ANALYZE === "true" });

const moduleExports = { env: { myConfig: 'MY_CONFIG' }, ... }

const SentryWebpackPluginOptions = { silent: true };

module.exports = withBundleAnalyzer(withSentryConfig(moduleExports, SentryWebpackPluginOptions));

The config code above worked fine before 7.22.0.
At 7.22.0 it would work if withBundleAnalyzer is removed though.

Expected Result

In next app console.log(process.env.myConfig) should print MY_CONFIG on browser.

Actual Result

console.log(process.env.myConfig) prints undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions