throwIfNamespace doesn't work
See original GitHub issueBug Report
Current Behavior I’m building a library that need to be able to work with JSX with namespaces. According to Babel documentation this should work by setting the throwIfNamespace option. However this does not seem to work.
Input Code https://github.com/TheKnarf/babel-namespace-test
Expected behavior/code
Running babel src/index.js
should transpile the test code without any errors.
Babel Configuration (.babelrc, package.json, cli command)
{
presets: ['@babel/preset-react'],
plugins: [
['@babel/transform-react-jsx', {
'pragma': 'dom',
'throwIfNamespace': false
}]
]
}
Environment
- Babel version(s): 7.1.2 (@babel/core 7.1.2)
- Node/npm version: v10.12.0
- OS: macOS 10.13.6
- How you are using Babel: cli
Additional context/Screenshots
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to turn on the 'throwIfNamespace' flag in React.js
React's JSX doesn't support namespace tags. ... all the unnecessary namespace in the SVG image and it started working as a react component....
Read more >How to turn on the 'throwIfNamespace' flag in React.js-Reactjs
It works because you dont have defs your might wish to use later (you need them in order to escape code repetition). Emil...
Read more >babel/preset-react
Fragment (only in classic runtime) "throwIfNamespace": false, ... it is disabled by default since React's JSX does not currently have support for it....
Read more >Web Design — Create an SVG Animation React Component ...
React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning. The solution is to turn the native syntax...
Read more >How To Turn On The 'throwifnamespace' Flag In ... - ADocLib
namespace tags are not supported by default. react's jsx doesn't support ... be able to import SVG files that contain tags like <cc:Work>...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you load
'@babel/preset-react'
and'@babel/transform-react-jsx'
at the same time, you’re loading two separate copies of'@babel/transform-react-jsx'
with their own independent sets of options. While one of them hasthrowIfNamespace: false
set, the other one will still do its default behavior of throwing an exception.Thanks, @loganfsmyth! I didn’t realize it would load it twice.
I guess that closes this issue.