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

Webpack plugin causes Typescript build errors when React component annotation is enabled #515

Open willgardner9 opened 7 months ago

willgardner9 commented 7 months ago

Environment

Steps to Reproduce

I have created a minimal reproduction of the issue here.

To reproduce:

  1. Use a Typescript generic within your React project (e.g. line 11 of src/app.tsx of the minimal reproduction)
  2. Attempt to build your project using a webpack config that uses the Sentry webpack plugin with react component annotation enabled
  3. The build errors

The build succeeds if you either:

Expected Result

Webpack build succeeds, with React component annotation enabled. This is observable through the data-sentry-component data attributes being present in the bundle.

Actual Result

The build fails, here is an example log (with some unnecessary logs removed/truncated) from the minimal reproduction:

npm run build

> sentry-webpack-react-component-annotation-minimal-repro@1.0.0 build
> webpack --output-path dist

assets by status 139 KiB [cached] 2 assets
modules by path ./node_modules/ 141 KiB
  modules by path ./node_modules/react-dom/ 130 KiB
    ./node_modules/react-dom/index.js 1.33 KiB [built] [code generated]
    ./node_modules/react-dom/cjs/react-dom.production.min.js 129 KiB [built] [code generated]
  modules by path ./node_modules/react/ 6.94 KiB
    ./node_modules/react/index.js 190 bytes [built] [code generated]
    ./node_modules/react/cjs/react.production.min.js 6.75 KiB [built] [code generated]
  modules by path ./node_modules/scheduler/ 4.33 KiB
    ./node_modules/scheduler/index.js 198 bytes [built] [code generated]
    ./node_modules/scheduler/cjs/scheduler.production.min.js 4.14 KiB [built] [code generated]
modules by path ./src/*.tsx 3.38 KiB
  ./src/index.tsx 371 bytes [built] [code generated]
  ./src/app.tsx 3.02 KiB [built] [code generated] [1 error]

ERROR in /[redacted]/sentry-webpack-react-component-annotation-minimal-repro/src/app.tsx
./src/app.tsx 35:18-50
[tsl] ERROR in /[redacted]/sentry-webpack-react-component-annotation-minimal-repro/src/app.tsx(35,19)
      TS2347: Untyped function calls may not accept type arguments.
ts-loader-default_e3b0c44298fc1c14
 @ ./src/index.tsx 3:34-50

webpack 5.91.0 compiled with 1 error in 3386 ms
lforst commented 7 months ago

@0Calories mind taking a look?