question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

throwIfNamespace doesn't work

See original GitHub issue

Bug 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 screen shot 2018-10-29 at 13 07 56

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
loganfsmythcommented, Oct 29, 2018

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 has throwIfNamespace: false set, the other one will still do its default behavior of throwing an exception.

0reactions
TheKnarfcommented, Oct 29, 2018

Thanks, @loganfsmyth! I didn’t realize it would load it twice.

I guess that closes this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found