getsentry / sentry-javascript

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

SentryWebpackPlugin.cliBinaryExists is not a function #8770

Closed andirsun closed 1 year ago

andirsun commented 1 year 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

7.62.0

Framework Version

Next 13.2.1

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. I am facing error SentryWebpackPlugin.cliBinaryExists is not a function when running my next js app with nx monorepo

This is my next config

const {withNx} = require('@nrwl/next/plugins/with-nx')
const {withSentryConfig} = require('@sentry/nextjs')
const path = require('path')

const isOnDesktop = process.env['NX_DESKTOP'] === 'true'
const firebaseAuthDomain = process.env['NX_FIREBASE_AUTH_DOMAIN']
const isAnalyzingBundle = process.env['ANALYZE'] === 'true'

/**
 * Stolen from https://stackoverflow.com/questions/10776600/testing-for-equality-of-regular-expressions
 */
const regexEqual = (x, y) => {
  return (
    x instanceof RegExp &&
    y instanceof RegExp &&
    x.source === y.source &&
    x.global === y.global &&
    x.ignoreCase === y.ignoreCase &&
    x.multiline === y.multiline
  )
}

const iconFamiliesBeforeUrlChange = [
  'streamline-bold',
  'streamline-light',
  'streamline-micro-bold',
  'streamline-micro-line',
  'streamline-mini-bold',
  'streamline-mini-line',
  'streamline-regular',
  'streamline-covid',

  // TODO: move these to emojis when they are implemented
  'freebies-freemojis',
  'freebies-elections-old',
  'freebies-stickers',
]
const illustrationFamiliesBeforeUrlChange = [
  'illustrations-duotone',
  'illustrations-brooklyn',
  'illustrations-line',
  'illustrations-multicolor',
]

// Next js Bundle Analyzer https://www.npmjs.com/package/@next/bundle-analyzer
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: true,
})

/**
 * @type {import('next').NextConfig}
 */
let nextConfig = {
  // We should not increase it, otherwise we run out of Vercel's limits.
  staticPageGenerationTimeout: 60,
  swcMinify: true,
  reactStrictMode: true,
  distDir: 'dist',
  images: {
    /**
     * We are deactivating image optimization as they are charging for that
     */
    unoptimized: true,
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'res.cloudinary.com',
      },
      {
        protocol: 'https',
        hostname: 'assets.streamlinehq.com',
      },
    ],
  },
  /*
   Optional build-time configuration options
   https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#extend-nextjs-configuration
  */
  sentry: {
    // This will be true by default on Sentry 8.0 so meanwhile we need to force its usage
    hideSourceMaps: true,
  },
  webpack: (config) => {
    // Adds rule in order to be able to use svgs using import, otherwise we get an error
    config.module.rules.push({
      test: /\.svg$/i,
      issuer: /\.[jt]sx?$/,
      resourceQuery: {not: [/url/]}, // exclude react component if *.svg?url
      use: ['@svgr/webpack'],
    })

    /*
     * Start of CSS modules classes output format configuration
     * This entire section is needed just to change CSS modules
     * classes output format as seen here:
     * https://stackoverflow.com/a/71450423/10504792
     */
    config.resolve.modules.push(path.resolve('./'))
    const oneOf = config.module.rules.find(
      (rule) => typeof rule.oneOf === 'object'
    )

    if (oneOf) {
      // Find the module which targets *.scss|*.sass files
      const moduleSassRule = oneOf.oneOf.find((rule) =>
        regexEqual(rule.test, /\.module\.(scss|sass)$/)
      )

      if (moduleSassRule) {
        // Get the config object for css-loader plugin
        const cssLoader = moduleSassRule.use.find(({loader}) =>
          loader.includes('css-loader')
        )

        if (cssLoader)
          cssLoader.options = {
            ...cssLoader.options,
            modules: {
              ...cssLoader.options.modules,
              localIdentName: '[local]--[hash:base64:5]',
              // You can also add other css-loader options here
            },
          }
      }
    }

    return config
  },
}

/**
 * rewrites, redirects, and headers are not supported on desktop
 * See more info here: https://nextjs.org/docs/messages/export-no-custom-routes
 **/
if (!isOnDesktop) {
  nextConfig = {
    ...nextConfig,
    /*
     * Next export does not support i18n for desktop
     */
    i18n: {
      locales: ['en'],
      defaultLocale: 'en',
    },
    // Redirect needed for redirecting from / for /icons page as /icons is the homepage for the app
    async redirects() {
      const redirects = []
      {
        iconFamiliesBeforeUrlChange.forEach((iconFamily) =>
          redirects.push({
            source: `/${iconFamily}`,
            destination: `/icons/${iconFamily}`,
            permanent: true,
          })
        )
      }
      {
        illustrationFamiliesBeforeUrlChange.forEach((iconFamily) =>
          redirects.push({
            source: `/${iconFamily}`,
            destination: `/illustrations/${iconFamily}`,
            permanent: true,
          })
        )
      }
      return [
        ...redirects,
        {
          source: '/home',
          destination: '/icons',
          permanent: false,
        },
        {
          source: '/profile/licenses',
          destination: '/profile/user',
          permanent: true,
        },
        {
          source: '/profile/plan-and-billing',
          destination: '/profile/user',
          permanent: true,
        },
        {
          source: '/checkout/brooklyn',
          destination: 'https://www.streamlinehq.com/pricing',
          permanent: true,
          basePath: false,
        },
        {
          source: '/upgrade',
          destination: 'https://www.streamlinehq.com/pricing',
          permanent: true,
          basePath: false,
        },
        {
          source: '/icons/freebies-freemojis',
          destination: '/emojis/freebies-freemojis',
          permanent: true,
        },
        {
          source: '/request-password',
          destination: '/icons?auth=request-password',
          permanent: true,
        },
        {
          source: '/login',
          destination: '/signin',
          permanent: true,
        },
        {
          source: '/signin',
          destination: '/icons?auth=sign-in',
          permanent: true,
        },
        {
          source: '/signup',
          destination: '/icons?auth=sign-up',
          permanent: true,
        },
        {
          source: '/signup/confirm/',
          destination: '/icons',
          permanent: true,
        },
        {
          source: '/reset-password',
          destination: '/icons?auth=reset-password',
          permanent: true,
        },
        {
          source: '/create-password',
          destination: '/icons?auth=reset-password',
          permanent: true,
        },
        {
          source: '/tools',
          destination: 'https://www.streamlinehq.com/plugins/figma',
          basePath: false,
          permanent: true,
        },
        {
          source: '/streamline-covid/virus-research',
          destination: '/icons/covid/virus-research',
          permanent: true,
        },
        {
          source: '/illustrations-line/customer-support',
          destination: '/illustrations/illustrations-line/customer-support',
          permanent: true,
        },
        {
          source: '/checkout',
          destination: '/checkout/fullaccess',
          permanent: true,
        },
        {
          source: '/profile/subscriptions', // Old subscriptions page, this is now handled by Stripe Customer Portal
          destination: '/profile/user',
          permanent: false,
        },
        {
          source: '/icons/streamline-covid',
          destination: '/icons/covid',
          permanent: true,
        },
        {
          source: '/freebies-elections',
          destination: '/icons',
          permanent: true,
        },
        {
          source: '/profile/developer',
          destination: '/profile/user',
          permanent: true,
        },
        {
          source: '/freebies-stickers',
          destination: '/emojis',
          permanent: true,
        },
        {
          source: '/attribution',
          destination:
            'https://help.streamlinehq.com/en/articles/5354403-how-to-create-an-attribution-link',
          permanent: true,
          basePath: false,
        },
        {
          source: '/download-mac',
          destination:
            'https://github.com/webalys-hq/streamline-releases/releases/latest/download/Streamline.dmg',
          permanent: true,
          basePath: false,
        },
        {
          source: '/plugins/powerpoint',
          destination: '/',
          permanent: true,
        },
        {
          source: '/plugins/sketch',
          destination: '/',
          permanent: true,
        },
        {
          source: '/plugins/adobe-xd',
          destination: '/',
          permanent: true,
        },
        {
          source: '/free',
          destination: '/freebies',
          permanent: true,
        },
        {
          source: '/dsp',
          destination: '/icons',
          permanent: true,
        },
        {
          source: '/illustrations/brooklyn',
          destination: '/illustrations/illustrations-brooklyn',
          permanent: true,
        },
        {
          source: '/icons/freebies-stickers',
          destination: '/freebies',
          permanent: true,
        },
        {
          source: '/icons/streamline-flat-pro',
          destination: '/icons/plump-flat',
          permanent: true,
        },
        {
          source: '/illustrations/web3.0-monoline',
          destination: '/illustrations/web3.0-illustrations',
          permanent: true,
        },
        {
          source: '/illustrations/miami-monoline',
          destination: '/illustrations/miami',
          permanent: true,
        },
        {
          source: '/icons/streamline-flex---free',
          destination: '/icons/flex-free',
          permanent: true,
        },
        {
          source: '/icons/streamline-flat-free',
          destination: '/icons/plump-free',
          permanent: true,
        },
        {
          source: '/elements/ink-bleed-minimalist',
          destination: '/elements/ink-bleed-shapes',
          permanent: true,
        },
        {
          source: '/elements/adjustable-strokes-arrows',
          destination: '/elements/sketch-annotations',
          permanent: true,
        },
        {
          source: '/elements/adjustable-strokes-annotations',
          destination: '/elements/sketch-annotations',
          permanent: true,
        },
        {
          source: '/elements/adjustable-strokes-bubbles',
          destination: '/elements/sketch-annotations',
          permanent: true,
        },
        {
          source: '/elements/adjustable-strokes-highlight',
          destination: '/elements/sketch-annotations',
          permanent: true,
        },
        {
          source: '/elements/adjustable-strokes-icons',
          destination: '/elements/sketch-annotations',
          permanent: true,
        },
        {
          source: '/elements/adjustable-strokes-illustrations',
          destination: '/elements/sketch-annotations',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-arrows',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-annotations',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-bubbles',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-flag-ribbons',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-highlight',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-icons',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/fixed-strokes-illustrations',
          destination: '/elements/sketch-elements-brushes',
          permanent: true,
        },
        {
          source: '/elements/dimension-shade',
          destination: '/elements/dimension',
          permanent: true,
        },
        {
          source: '/elements/dimension-line-shade',
          destination: '/elements/dimension',
          permanent: true,
        },
        {
          source: '/elements/dimension-wireframe',
          destination: '/elements/dimension',
          permanent: true,
        },
        {
          source: '/elements/dimension-line',
          destination: '/elements/dimension',
          permanent: true,
        },
        {
          source: '/elements/dimension-patterns',
          destination: '/elements/dimension',
          permanent: true,
        },
        {
          source: '/elements/stickers-flat',
          destination: '/elements/stickers',
          permanent: true,
        },
        {
          source: '/elements/stickers-solid',
          destination: '/elements/stickers',
          permanent: true,
        },
        {
          source: '/elements/sticky-notes-flat',
          destination: '/elements/sticky-notes',
          permanent: true,
        },
        {
          source: '/elements/sticky-notes-solid',
          destination: '/elements/sticky-notes',
          permanent: true,
        },
        {
          source: '/elements/washi-tapes-flat',
          destination: '/elements/washi-tapes',
          permanent: true,
        },
        {
          source: '/elements/washi-tapes-solid',
          destination: '/elements/washi-tapes',
          permanent: true,
        },
        {
          source: '/elements/geometric-badges-flat',
          destination: '/elements/geometric-badges',
          permanent: true,
        },
        {
          source: '/elements/geometric-badges-solid',
          destination: '/elements/geometric-badges',
          permanent: true,
        },
        {
          source: '/elements/classic-badges-line',
          destination: '/elements/classic-badges',
          permanent: true,
        },
        {
          source: '/elements/classic-badges-combo',
          destination: '/elements/classic-badges',
          permanent: true,
        },
        {
          source: '/elements/classic-badges-shadow',
          destination: '/elements/classic-badges',
          permanent: true,
        },
        {
          source: '/elements/baskerville-ornaments',
          destination: '/elements/typographic-ornaments',
          permanent: true,
        },
        {
          source: '/students',
          destination: '/icons?auth=sign-up&auth-variant=education',
          permanent: true,
        },
        {
          source: '/icons/material-line',
          destination: '/icons/nova-line',
          permanent: true,
        },
        {
          source: '/icons/material-solid',
          destination: '/icons/nova-solid',
          permanent: true,
        },
        {
          source: '/elements/geometric-badges',
          destination: '/elements/vector-badges',
          permanent: true,
        },
        {
          source: '/elements/classic-badges',
          destination: '/elements/vector-badges',
          permanent: true,
        },
        {
          source: '/icons/ui-line-pro',
          destination: '/icons/core-line',
          permanent: true,
        },
        {
          source: '/icons/streamline-mini-bold',
          destination: '/icons/core-solid',
          permanent: true,
        },
        {
          source: '/icons/core-flat-pro',
          destination: '/icons/core-flat',
          permanent: true,
        },
        {
          source: '/icons/core-duo',
          destination: '/icons/core-duo-color',
          permanent: true,
        },
        {
          source: '/icons/flex-line-pro',
          destination: '/icons/flex-line',
          permanent: true,
        },
        {
          source: '/icons/flex-solid',
          destination: '/icons/flex-solid-style',
          permanent: true,
        },
        {
          source: '/icons/pastel-icons',
          destination: '/icons/flex-duo',
          permanent: true,
        },
        {
          source: '/icons/flex-flat',
          destination: '/icons/flex-flat-style',
          permanent: true,
        },
        {
          source: '/icons/sharp-line',
          destination: '/icons/sharp-line-style',
          permanent: true,
        },
        {
          source: '/icons/sharp-solid',
          destination: '/icons/sharp-solid-style',
          permanent: true,
        },
        {
          source: '/icons/sharp-duo',
          destination: '/icons/sharp-duo-style',
          permanent: true,
        },
        {
          source: '/icons/sharp-flat',
          destination: '/icons/sharp-flat-style',
          permanent: true,
        },
        {
          source: '/icons/plump-line-pro',
          destination: '/icons/plump-line-style',
          permanent: true,
        },
        {
          source: '/icons/plump-solid-pro',
          destination: '/icons/plump-solid-style',
          permanent: true,
        },
        {
          source: '/icons/plump-duo',
          destination: '/icons/plump-duo-style',
          permanent: true,
        },
        {
          source: '/icons/plump-flat',
          destination: '/icons/plump-flat-style',
          permanent: true,
        },
        {
          source: '/icons/streamline-micro-line',
          destination: '/icons/micro-line',
          permanent: true,
        },
        {
          source: '/icons/streamline-micro-bold',
          destination: '/icons/micro-solid',
          permanent: true,
        },
        {
          source: '/icons/core-free',
          destination: '/icons/streamline-mini-line',
          permanent: true,
        },
        {
          source: '/newsletter',
          destination: '/',
          permanent: true,
        },
        {
          source: '/features',
          destination: '/',
          permanent: true,
        },
        // We made a mistake in the past where we used a space(%20) instead of a dash in the URL for tags pages,
        // this fixes it in case users try to access the wrong url again
        {
          source: '/:type/tag/:seg1%20:seg2',
          destination: '/:type/tag/:seg1-:seg2',
          permanent: true,
        },
      ]
    },

    async rewrites() {
      return [
        {
          source: '/',
          destination: 'https://streamlinefree.framer.website/',
        },
        {
          source: '/vector-illustrations',
          destination:
            'https://streamlinefree.framer.website/vector-illustrations',
        },
        {
          source: '/vector-emojis',
          destination: 'https://streamlinefree.framer.website/vector-emojis',
        },
        {
          source: '/vector-elements',
          destination: 'https://streamlinefree.framer.website/vector-elements',
        },
        {
          source: '/vector-freebies',
          destination: 'https://streamlinefree.framer.website/vector-freebies',
        },
        {
          source: '/set/guidance',
          destination: 'https://framer.streamlinehq.com/set/guidance',
        },
        {
          source: '/plugins/figma',
          destination: 'https://streamlinefree.framer.website/figma',
        },
        {
          source: '/wall-of-love',
          destination: 'https://streamlinefree.framer.website/testimonials',
        },
        {
          source: '/testimonials',
          destination: 'https://streamlinefree.framer.website/testimonials',
        },
        {
          source: '/use-case',
          destination: 'https://framer.streamlinehq.com/projects/interface',
        },
        {
          source: '/use-cases',
          destination: 'https://framer.streamlinehq.com/projects/interface',
        },
        {
          source: '/download',
          destination: 'https://streamlinefree.framer.website/download',
        },
        {
          source: '/license-free',
          destination: 'https://streamlinefree.framer.website/license-free',
        },
        {
          source: '/license-premium',
          destination: 'https://streamlinefree.framer.website/license-premium',
        },
        {
          source: '/contact',
          destination: 'https://streamlinefree.framer.website/contact',
        },
        {
          source: '/pricing',
          destination: 'https://streamlinefree.framer.website/pricing',
        },
        {
          source: '/__/auth/:path*',
          destination: `https://${firebaseAuthDomain}/__/auth/:path*`,
        },
        {
          source: '/super',
          destination: 'https://framer.streamlinehq.com/super',
        },
        {
          source: '/free/:path*',
          destination: 'https://framer.streamlinehq.com/free/:path*',
        },
        {
          source: '/lucidchart',
          destination: 'https://framer.streamlinehq.com/lucidchart',
        },
        {
          source: '/lucidspark',
          destination: 'https://framer.streamlinehq.com/lucidspark',
        },
      ]
    },

    async headers() {
      const securityHeaders = [
        {
          key: 'X-Content-Type-Options',
          value: 'nosniff',
        },
        {
          key: 'X-Frame-Options',
          value: 'sameorigin',
        },
      ]

      return [
        {
          source: '/(.*)',
          headers: securityHeaders,
        },
      ]
    },
  }
}

/**
 * @type any
 */
const defaultExport = withSentryConfig(nextConfig)

module.exports = isAnalyzingBundle
  ? withBundleAnalyzer(defaultExport)
  : withNx(defaultExport)
  1. If I remove withSentryConfig(nextConfig) and use directly nextConfig, the project works without sentry.

Expected Result

Works normally with withSentryConfig(nextConfig) support.

Actual Result

❯ npm run start:web

> streamline-mono@5.0.2 start:web
> nx reset && nx run models:check-env-vars && nx run streamline-web:serve --with-deps

 >  NX   Resetting the Nx workspace cache and stopping the Nx Daemon.

   This might take a few minutes.

 >  NX   Daemon Server - Stopped

 >  NX   Successfully reset the Nx workspace.

> nx run models:check-env-vars

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target check-env-vars for project models (1s)

> nx run streamline-web:serve:development --with-deps

 >  NX   SentryWebpackPlugin.cliBinaryExists is not a function

   Pass --verbose to see the stacktrace.

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Running target serve for project streamline-web failed

   Failed tasks:

   - streamline-web:serve:development

   Hint: run the command with --verbose for more details.
lforst commented 1 year ago

Hi, can you check what versions of the @sentry/cli package you have installed in your node_modules after pruning your package manager cache and reinstalling them? Thanks!

andirsun commented 1 year ago

@lforst Thanks for look in to this.

❯ npm ls @sentry/cli
streamline-mono@5.0.2 /Users/andirsun/projects/streamline/streamline-mono
├─┬ @sentry/nextjs@7.62.0
│ └─┬ @sentry/webpack-plugin@1.20.0
│   └── @sentry/cli@1.75.2
└─┬ @sentry/webpack-plugin@2.6.1
  └─┬ @sentry/bundler-plugin-core@2.6.1
    └── @sentry/cli@2.20.4
lforst commented 1 year ago

Ok you can see there is a clash of @sentry/cli versions. Can you try to resolve this? Are you overriding any dependencies?

andirsun commented 1 year ago

I am using a NX mono repo so I need both libraries, btw I am using latest version of sentry/nextjs and sentry/webpack-plugin you think I need to downgrade sentry/webpack-plugin ?

lforst commented 1 year ago

Do you have a reason to be using @sentry/webpack-plugin? If you're not explicitly using it I recommend uninstalling it.

andirsun commented 1 year ago

@lforst Yes I am using it in another project inside the mono repo

/* eslint-disable no-param-reassign */
const {composePlugins, withNx} = require('@nrwl/webpack')
const {withReact} = require('@nrwl/react')
const {merge} = require('webpack-merge')
const {sentryWebpackPlugin} = require('@sentry/webpack-plugin')
const {DeleteSourceMapsPlugin} = require('webpack-delete-sourcemaps-plugin')
const nrwlConfig = require('@nrwl/react/plugins/webpack.js')
const TerserJSPlugin = require('terser-webpack-plugin')

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), withReact(), (config) => {
  // Note: This was added by an Nx migration.
  // You should consider inlining the logic into this file.
  // For more information on webpack config and Nx see:
  // https://nx.dev/packages/webpack/documents/webpack-config-setup
  nrwlConfig(config)
  // These two lines below are needed to fix a nx bug that broke tree shacking, making the bundle size much bigger.
  // https://github.com/nrwl/nx/issues/14483
  config.resolve.mainFields = ['browser', 'module', 'main']
  config.optimization.minimizer.unshift(new TerserJSPlugin())
  return merge(config, {
    output: {
      // Without this the styles won't get properly compiled
      publicPath: '',
    },
    devServer: {
      allowedHosts: ['localhost', '.lucidextensions.app'], // We need to allow .lucidextensions.app, otherwise we get "Invalid Host/Origin header error" error message when running it inside of a lucid extension
    },
    devtool: 'hidden-source-map', // optional, see the #hidden-source-map section for more info: https://github.com/AlexBeauchemin/webpack-delete-sourcemaps-plugin#hidden-source-map
    plugins: [
      sentryWebpackPlugin({
        org: 'webalys',
        project: 'streamline-lucid',
        // Specify the directory containing build artifacts
        include: './build',
        ignore: ['node_modules'],
        // Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
        // and needs the `project:releases` and `org:read` scopes
        authToken: process.env.SENTRY_AUTH_TOKEN,
        // Set it to false if you want to see source maps files uploaded to sentry.
        silent: false,
      }),
      new DeleteSourceMapsPlugin(),
    ],
  })
})
andirsun commented 1 year ago

@lforst I fixed it downgrading @sentry/webpack-plugin from version 2.6.1 to 1.20 to match the version inside @sentry/nextjs Now the project is working.

❯ npm run start:web      

> streamline-mono@5.0.2 start:web
> nx reset && nx run models:check-env-vars && nx run streamline-web:serve --with-deps

 >  NX   Resetting the Nx workspace cache and stopping the Nx Daemon.

   This might take a few minutes.

 >  NX   Daemon Server - Stopped

 >  NX   Successfully reset the Nx workspace.

> nx run models:check-env-vars

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target check-env-vars for project models (1s)

> nx run streamline-web:serve:development --with-deps

event - compiled client and server successfully in 10s (3810 modules)
[ ready ] on http://localhost:4200
lforst commented 1 year ago

Cool. Thanks for the update!

andirsun commented 1 year ago

@lforst Wait a second. but after downgrade the @sentry/webpack-plugin the project that is using that module is no longer working. I think is too old to use that function ?

 NX   sentryWebpackPlugin is not a function

inside https://github.com/getsentry/sentry-javascript/issues/8770#issuecomment-1673003215

lforst commented 1 year ago

I recommend you look at the documentation of the packages for the respective versions you're using. In the case of version 1.20.0 you need to look at https://www.npmjs.com/package/@sentry/webpack-plugin/v/1.20.0.

You must expect things to change when going from one major version to another.

andirsun commented 1 year ago

it worked! thanks @lforst I will let you know if something comes up.

Btw the old version to use webpack plugin was

const SentryCliPlugin = require('@sentry/webpack-plugin');

const config = {
  plugins: [
    new SentryCliPlugin({
      include: '.',
      ignoreFile: '.sentrycliignore',
      ignore: ['node_modules', 'webpack.config.js'],
      configFile: 'sentry.properties',
    }),
  ],
};
CaptainStiggz commented 1 year ago

I ran into the same issue - using yarn workspaces with @sentry/nextjs in one package and another @sentry/node + @sentry/webpack-plugin in another package. Is there any plan to resolve this such that the more recent version of webpack-plugin can be used?

lforst commented 1 year ago

@CaptainStiggz there are no plans. I think this is an issue with people's setups for their package managers and not the SDK. There is nothing we can do to actually fix this.

rdsedmundo commented 1 year ago

@lforst the fix would be you upgrading @sentry/nextjs to use the latest @sentry/webpack-plugin? https://github.com/getsentry/sentry-javascript/blob/develop/packages/nextjs/package.json#L35

Is there a reason why it's still in 1.x after almost 6 months of 2.x having been released?

lforst commented 1 year ago

Is there a reason why it's still in 1.x after almost 6 months of 2.x having been released?

@rdsedmundo Yes. Upgrading it would be a breaking change.

chngl commented 1 year ago

it worked! thanks @lforst I will let you know if something comes up.

Btw the old version to use webpack plugin was

const SentryCliPlugin = require('@sentry/webpack-plugin');

const config = {
  plugins: [
    new SentryCliPlugin({
      include: '.',
      ignoreFile: '.sentrycliignore',
      ignore: ['node_modules', 'webpack.config.js'],
      configFile: 'sentry.properties',
    }),
  ],
};

I think you can use alias when installing the sentry webpack plugin to avoid the version conflict instead of downgrading and using the old plugin. e.g.

yarn add your-alias@npm:@sentry/webpack-plugin --dev

const {
    sentryWebpackPlugin,
} = require('your-alias');

@andirsun