Skip to content

@sentry/nextjs Webpack 5 code duplication bug #3591

@pgrippi

Description

@pgrippi

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other: @sentry/nextjs

Version:

6.4.1

Description

During the process of upgrading one of our next.js applications from webpack 4 to webpack 5 I stumbled upon a bug where using withSentryConfig causes webpack 5 to duplicate dependencies in the final output. Using the webpack bundle analyzer I can see that packages normally bundled in _app also get their own shared bundle

Without withSentryConfig:

Screen Shot 2021-05-24 at 3 31 44 PM

Using withSentryConfig: (Notice that @apollo/client is now included in both _app and the 675- bundle)

Screen Shot 2021-05-24 at 3 32 29 PM

I've created a simple app using the with-apollo template that reproduces the issue: https://github.com/pgrippi/sentry-nextjs-code-duplication-bug.

You can modify next.config.js, swapping the module.exports statements and running yarn build to see the bundle output difference

To clarify the issue not limited to @apollo/client, it looks like most modules imported from npm that appear in both _app and other pages get duplicated, the apollo client is just very noticeable given its large footprint

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions