getsentry / sentry-javascript

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

sentry/nextjs warning on install about missing webpack #4632

Closed belgattitude closed 2 years ago

belgattitude commented 2 years ago

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

6.17.9

Framework Version

Non applicable

Link to Sentry event

Non applicable

Steps to Reproduce

Run an install or @sentry/nextjs with yarn 3 (or 2) - repo link https://github.com/belgattitude/nextjs-sentry-reproduction.

Note that this would theoretically also prevent @sentry/nextjs to work with the pnp/pnpm module linker.

git clone https://github.com/belgattitude/nextjs-sentry-reproduction
cd nextjs-sentry-reproduction
yarn install

Expected Result

No warning about missing peer-dependencies on webpack.

Note: webpack is provided by nextjs as a ncc'ed dep since https://github.com/vercel/next.js/pull/32742

Actual Result

➤ YN0000: ┌ Resolution step
➤ YN0002: │ root-workspace-0b6124@workspace:. doesn't provide webpack (p08419), requested by @sentry/nextjs
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed

Running explain:

yarn explain peer-requirements p08419
➤ YN0000: root-workspace-0b6124@workspace:. doesn't provide webpack, breaking the following requirements:
➤ YN0000: @sentry/nextjs@npm:6.17.9 [dc3fc]         → >= 4.0.0           ✘
➤ YN0000: @sentry/webpack-plugin@npm:1.18.5 [5d4cb] → ^4.41.31 || ^5.0.0 ✘
➤ YN0000: Note: these requirements start with @sentry/nextjs@npm:6.17.9 [dc3fc]

Workaround

It's possible to use the packageExtensions in yarnrc.yml.

packageExtensions:
  '@sentry/nextjs@*':
    peerDependenciesMeta:
      webpack:
        optional: true
belgattitude commented 2 years ago

Opened a P/R here: https://github.com/getsentry/sentry-javascript/pull/4634.