getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
136 stars 35 forks source link

Build failure for using tailwind-merge package with @sentry/vite-plugin #308

Closed AkashRajpurohit closed 1 year ago

AkashRajpurohit commented 1 year ago

I am trying to setup sentry vite plugin for release tracking and sourcemaps data, but the build fails when I add config for it.

Environment

What version are you running?

"@sentry/vite-plugin": "^2.2.0",
"vite": "^4.3.9"
"tailwind-merge": "^1.12.0",

Steps to Reproduce

Using it in Astro project which uses vite. Setup is like this -

import { loadEnv } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';

const env = loadEnv('production', process.cwd());

export default defineConfig({
  ...
  vite: {
    plugins: [
      sentryVitePlugin({
        org: 'org-name',
        project: 'project-name',
        authToken: env.SENTRY_AUTH_TOKEN,
        telemetry: false,
      }),
    ],
    build: {
      sourcemap: true,
    },
  },
  output: 'hybrid',
  adapter: cloudflare(),
});

The build failure happens after the sourcemaps are uploaded and client build starts.

Expected Result

Build should succeed.

Actual Result

Error while building client.

 building client 
rendering chunks (4)...[vite:esbuild-transpile] Transform failed with 1 error:
_astro/tw-merge.!~{00a}~.js:2515:27: ERROR: Unexpected ";"

Unexpected ";"
2513|  }
2514|  
2515|  var twMerge = /*#__PURE__*/;!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c9ff831-910b-4bcd-ae80-dc76a3e35d59",e._sentryDebugIdIdentifier="sentry-dbid-3c9ff831-910b-4bcd-ae80-dc76a3e35d59")}catch(e){}}();createTailwindMerge(getDefaultConfig);
   |                             ^
2516|  
2517|  export { twMerge as t };

rendering chunks (9)... error   Unexpected ";"
  File:
    _astro/tw-merge.!~{00a}~.js:2515:27
 ELIFECYCLE  Command failed with exit code 1.

I have confirmed that it only fails when tailwind-merge is present as deps and used, when I remove it then the build succeeds

The corresponding issue opened on tailwind-merge package and response from the author is here

Hey @AkashRajpurohit! 👋

tailwind-merge only outputs this code (source here)

var twMerge = createTailwindMerge(getDefaultConfig)

which should be correct.

The part in the middle

/*#__PURE__*/;!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c9ff831-910b-4bcd-ae80-dc76a3e35d59",e._sentryDebugIdIdentifier="sentry-dbid-3c9ff831-910b-4bcd-ae80-dc76a3e35d59")}catch(e){}}();

seems to be injected by Sentry (you see Sentry-related variable names in it, like _sentryDebugIds).

This is probably an issue with @sentry/vite-plugin, I'd suggest to open an issue in that repo instead to fix it.

AkashRajpurohit commented 1 year ago

Looks like duplicate of #298 Feel free to close it if it's being tracked there.

lforst commented 1 year ago

Fixed via https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/309

AkashRajpurohit commented 1 year ago

Awesome, can we get it released as well, will try it once and verify it.

lforst commented 1 year ago

Release will probably happen tomorrow or on monday.

lforst commented 1 year ago

Please check out version 2.2.2 of the package which should have the fix for this issue!