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.

Seems can't parse JSX syntax

See original GitHub issue

Seems the webpack can’t parse JSX syntax. On a minimalist example I get following error in JS console:

index.js:1 Uncaught Error: Module parse failed: Unexpected token (45:2)
You may need an appropriate loader to handle this file type.
| 
| render(
>   <Playroom
|     themes={themes}
|     components={components}
    at eval (index.js:1)
    at Object../node_modules/playroom/src/index.js (main.js:96)
    at __webpack_require__ (main.js:20)
    at main.js:84
    at main.js:87

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
markdalgleishcommented, Nov 28, 2018

FYI, as of v0.5.0, you no longer need to apply webpack config like @pascalduez’s example. If custom webpack config isn’t provided, your project code is now run through Babel + preset-env + preset-react.

2reactions
pascalduezcommented, Nov 14, 2018

@dburles Something in this vein should do it.

webpackConfig: () => ({
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: [
                ['@babel/preset-env', { modules: false }],
                '@babel/preset-react'
              ],
            },
          },
        ],
      },
    ],
  },
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack won't parse JSX no matter what I try - Stack Overflow
duplicating the .babelrc file into the main directory and entry point directory, not sure which is necessary. registering babel-register: in app ...
Read more >
Why can't browsers read JSX ? - GeeksforGeeks
Browsers can't read JSX because there is no inherent implementation for the browser engines to read and understand them. JSX is not intended...
Read more >
html-react-parser - npm
The parser converts an HTML string to one or more React elements. To replace an element with another element, check out the replace...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
The JavaScript exceptions thrown by JSON.parse() occur when string failed to be parsed as JSON. Message. SyntaxError: JSON.parse: unterminated string literal ...
Read more >
React Without JSX
Each JSX element is just syntactic sugar for calling React.createElement(component, props, ...children) . So, anything you can do with JSX can also be...
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