dcastil / tailwind-merge

Merge Tailwind CSS classes without style conflicts
https://npmjs.com/package/tailwind-merge
MIT License
4.6k stars 63 forks source link

Build fails while using @sentry/vite-plugin #240

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. Without it the build works fine.

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',
  experimental: {
    hybridOutput: true,
  },
  adapter: cloudflare(),
});

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

 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.

The package versions are

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

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

dcastil commented 1 year ago

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

Closing this, will continue this on the sentry plugin repo 👍🏽