Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react-component-annotate): Allow skipping annotations on specified components #617

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

0Calories
Copy link
Member

@0Calories 0Calories commented Oct 8, 2024

Some third party libraries involve components that have compatibility issues with the react-component-annotate plugin, and results in errors when the data-sentry properties are added as props. This PR introduces a bit of a bandaid fix by introducing an option to allow users to configure the names of components that should not have any annotations applied.

When using the standalone Babel plugin, you can configure this option like so:

// babel.config.js

{
  // ... other config above ...

  plugins: [
    // Put this plugin before any other plugins you have that transform JSX code
    // The options are set by providing an object as the second element in the array, but not required
    ['@sentry/babel-plugin-component-annotate', {ignoreComponents: ['Foo', 'Bar']}]
  ],
}

When using the Sentry bundler plugins, you can configure this option like so:

sentryVitePlugin({
    // ... other options
    reactComponentAnnotation: {enabled: true, ignoreComponents: ['Foo', 'Bar']},
}),

TODO: Add tests and allow providing a source file location, since it is possible for multiple components to have the same name, but you may not want to skip annotation on all of these.

@0Calories 0Calories self-assigned this Oct 8, 2024
@lforst
Copy link
Member

lforst commented Dec 19, 2024

@0Calories can we expedite this PR?

@0Calories
Copy link
Member Author

@lforst I'll try to finish it on friday, I believe it just needs tests

Also:

allow providing a source file location, since it is possible for multiple components to have the same name, but you may not want to skip annotation on all of these.

This unfortunately will have to be done in a followup PR. For now, I want to at least expose the option to skip specific components by names as that will at least provide an option for users who are struggling with incompatible components

@nathan-gage
Copy link

nathan-gage commented Dec 20, 2024

will it be possible to resolve #611 with this PR -- i.e., not trying to name <React.Fragment/>s used in headless?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants