- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.7k
 
Closed
Labels
Package: nextjsIssues related to the Sentry Nextjs SDKIssues related to the Sentry Nextjs SDK
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
 - I have reviewed the documentation https://docs.sentry.io/
 - I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
 
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/nextjs
SDK Version
7.33.0
Framework Version
Next 13.1.5
Link to Sentry event
No response
SDK Setup
  Sentry.init({
    dsn: 'foobar',
    environment,
    enabled: !!environment && ['staging', 'production'].includes(environment),
    tracesSampleRate: 0.2,
    tracesSampler: (ctx) => !ctx.transactionContext.name.includes('healthz'),
    beforeSend(event) {
      if (!event.request?.cookies) return event;
      const { cookies } = event.request;
      Object.keys(cookies).forEach((key) => {
        if (key.toLowerCase().includes('session')) {
          cookies[key] = '[Redacted]';
        }
      });
      return event;
    },
  });Steps to Reproduce
- conditionally use a require() call
 - start prod or dev server of next in a case where the condition should be false
 
Expected Result
The file should not be required
Actual Result
The file will be required regardless of the surrounding if-statement
Our understanding is that this behavior was introduced within the following PR
#6685
Enabeling transformMixedEsModules
See also rollup/plugins#1177 which indicates that the rollup plugin can't fix this.
This is the recommended way to run MSW in your local env, see example https://github.com/vercel/next.js/blob/canary/examples/with-msw/pages/_app.tsx
joshuajaco
Metadata
Metadata
Assignees
Labels
Package: nextjsIssues related to the Sentry Nextjs SDKIssues related to the Sentry Nextjs SDK