Skip to content

feat: add throwIfNamespace option for custom JSX runtime#9571

Merged
aleclarson merged 3 commits intovitejs:mainfrom
iMrDJAi:patch-1
Sep 30, 2022
Merged

feat: add throwIfNamespace option for custom JSX runtime#9571
aleclarson merged 3 commits intovitejs:mainfrom
iMrDJAi:patch-1

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-cat patak-cat 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-cat patak-cat 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-cat
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-cat
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