getsentry / sentry-javascript-bundler-plugins

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

esbuild-plugin is missing a name #483

Closed LukasKlement closed 6 months ago

LukasKlement commented 9 months ago

Trying to use the vite-plugin in an Angular application with angular-builders/custom-esbuild (https://github.com/just-jeb/angular-builders/tree/master/packages/custom-esbuild) produces the error on build: throw new Error(Plugin at index ${i} is missing a name);

In angular.json I use the builder: "builder": "@angular-builders/custom-esbuild:application" and in options "plugins": ["./vite.config.ts"],

The plugin is from the documentation - manual setup: https://docs.sentry.io/platforms/node/guides/connect/sourcemaps/uploading/vite/

Environment:

lforst commented 9 months ago

Hi, would you mind console logging your plugins on build and sharing them here? I cannot immediately spot where we would be missing a plugin name. Maybe the logs help us find the culprit.

LukasKlement commented 9 months ago

These are the plugins being loaded (console logging node_modules/esbuild/lib/main.js):

[
  { name: 'angular-sourcemap-ignorelist', setup: [Function: setup] },
  { name: 'angular-compiler', setup: [AsyncFunction: setup] },
  { build: { sourcemap: true }, plugins: [ [Object] ] }
]

These are the items I get when logging the let item of plugins iterator:

{ name: 'angular-sourcemap-ignorelist', setup: [Function: setup] }
{ name: 'angular-compiler', setup: [AsyncFunction: setup] }
plugins:  [
  { name: 'angular-sourcemap-ignorelist', setup: [Function: setup] },
  { name: 'angular-polyfills', setup: [Function: setup] }
]
{ name: 'angular-sourcemap-ignorelist', setup: [Function: setup] }
{ name: 'angular-polyfills', setup: [Function: setup] }
plugins:  [
  { name: 'angular-styles-global', setup: [Function: setup] },
  { name: 'angular-sass', setup: [AsyncFunction: setup] },
  { name: 'angular-less', setup: [AsyncFunction: setup] },
  { name: 'angular-css', setup: [Function: setup] },
  { name: 'angular-css-resource', setup: [Function: setup] },
  { name: 'angular-css-inline-fonts-plugin', setup: [Function: setup] }
]
{ name: 'angular-styles-global', setup: [Function: setup] }
{ name: 'angular-sass', setup: [AsyncFunction: setup] }
{ name: 'angular-less', setup: [AsyncFunction: setup] }
{
  build: { sourcemap: true },
  plugins: [
    {
      '0': [Object],
      '1': [Object],
      '2': [Object],
      enforce: 'post',
      name: 'sentry'
    }
  ]
}
{ name: 'angular-css', setup: [Function: setup] }
{ name: 'angular-css-resource', setup: [Function: setup] }

The vite.config.ts is the one from your docs:

import { defineConfig } from "vite";
import { sentryVitePlugin } from "@sentry/vite-plugin";

export default defineConfig({
  build: {
    sourcemap: true,
  },
  plugins: [
    sentryVitePlugin({
      org: "my-org",
      project: "my-project",
      authToken: process.env.SENTRY_TOKEN,
    }),
  ],
});
lforst commented 9 months ago

Can you elaborate why you are using the vite plugin while using the esbuild Angular builder? Can you try using the @sentry/esbuild plugin instead?

LukasKlement commented 9 months ago

Thanks for the note, apologies posted on the wrong plugin. The error is the same though, this is the config:

angular.json: "builder": "@angular-builders/custom-esbuild:application",

esbuild.config.ts:

import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
import esbuild from "esbuild";

esbuild.build({
  sourcemap: true, // Source map generation must be turned on
  plugins: [
    // Put the Sentry esbuild plugin after all other plugins
    sentryEsbuildPlugin({
      org: "org",
      project: "project",
      authToken: process.env.SENTRY_AUTH_TOKEN,
    }),
  ],
});
lforst commented 9 months ago

I cannot reproduce this with the latest version of esbuild and the esbuild plugin. Would you mind sharing a small reproduction example? Thanks!

LukasKlement commented 9 months ago

Hi, thanks - here's an example: https://stackblitz.com/edit/stackblitz-starters-ddzaip?file=src%2Fmain.ts Indeed, I get the following error now: "Add only entry points to the 'files' or 'include' properties in your tsconfig."

lforst commented 9 months ago

@LukasKlement the stackblitz you shared doesn't contain any Sentry plugins 🤔 did you press save?

getsantry[bot] commented 6 months ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀