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: add throwIfNamespace option for custom JSX runtime #9571

Merged
merged 3 commits into from
Sep 30, 2022

Conversation

iMrDJAi
Copy link
Contributor

@iMrDJAi iMrDJAi commented Aug 7, 2022

Description

This change allows passing throwIfNamespace to babel-plugin-transform-react-jsx through @vitejs/plugin-react options.

Fixes #6554.

Additional context

This option is enabled by default, causing the following error when using xml namespace prefixes: Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set throwIfNamespace: false to bypass this warning.

Currently there is no way to set throwIfNamespace to false without that change.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).

@iMrDJAi iMrDJAi changed the title Allow specifying throwIfNamespace option for custom JSX runtimes feat: Allow specifying throwIfNamespace option for custom JSX runtimes Aug 7, 2022
@patak-dev patak-dev added enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority) plugin: react labels Aug 8, 2022
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could merge this option. For a future version, we may want to directly let the use pass a jsxOptions object. For the moment, this looks better as there aren't many other options to configure and we may want to migrate to something different than babel later on. https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#options

@iMrDJAi
Copy link
Contributor Author

iMrDJAi commented Sep 20, 2022

@patak-dev When will you merge this?

@patak-dev
Copy link
Member

@aleclarson @frandiox could you check if this looks good to you so we can merge it?

@frandiox
Copy link
Contributor

@patak-dev LGTM, we haven't had any issue with prefixes in JSX so far but I guess it's good to have an option to disable it👍

@iMrDJAi
Copy link
Contributor Author

iMrDJAi commented Sep 25, 2022

@patak-dev Go ahead :)

@iMrDJAi
Copy link
Contributor Author

iMrDJAi commented Sep 30, 2022

@patak-dev Can you merge it now?

@aleclarson aleclarson changed the title feat: Allow specifying throwIfNamespace option for custom JSX runtimes feat: add throwIfNamespace option for custom JSX runtime Sep 30, 2022
@aleclarson aleclarson merged commit f842f74 into vitejs:main Sep 30, 2022
@iMrDJAi
Copy link
Contributor Author

iMrDJAi commented Sep 30, 2022

@aleclarson Thank you! Is there any ETA on when this change will get released on NPM?

@patak-dev
Copy link
Member

@iMrDJAi it is going to be released in tandem with Vite 3.2. We should get a beta for plugin-react out next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants