getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
8.02k stars 1.59k forks source link

@sentry/nextjs 8.40.0 Error require() of ES Module #14498

Open Jussinevavuori opened 1 day ago

Jussinevavuori commented 1 day ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.40.0

Framework Version

Next 15.0.4-canary.28

Link to Sentry event

No response

Reproduction Example/SDK Setup

Any Next.js 15 + Sentry 8.40.0 template/basic application deployed to Vercel.

Steps to Reproduce

  1. npx create-next-app --example with-sentry nextjs-sentry-example
  2. Ensure sentry@8.40.0 installed
  3. Build project locally (Build should pass)
  4. Deploy project to Vercel (Build should fail)
  5. Downgrade to sentry@8.39.0
  6. Deploy project to Vercel (Build should pass)

Expected Result

Build should pass in Vercel

Actual Result

unhandledRejection Error: require() of ES Module /vercel/path0/node_modules/chalk/source/index.js from /vercel/path0/node_modules/@sentry/nextjs/build/cjs/config/webpack.js not supported.
Instead change the require of index.js in /vercel/path0/node_modules/@sentry/nextjs/build/cjs/config/webpack.js to a dynamic import() which is available in all CommonJS modules.
    at mod.require (node_modules/next/dist/server/require-hook.js:65:28)
    at Object.<anonymous> (../../node_modules/@sentry/nextjs/build/cjs/config/webpack.js:12:15) {
  type: 'Error',
  code: 'ERR_REQUIRE_ESM'
}
error: script "build" exited with code 1
Error: Command "bun run build" exited with 1
chargome commented 1 day ago

hi @Jussinevavuori , npx create-next-app --example with-sentry creates an outdated setup based on v7, please make sure to either follow our guide for setting up v8 or our migration guide if you're coming from v7.