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.

Self closing can parse

> require('meriyah').parse('var  a = <div/>', {jsx: true}).body[0].declarations[0].init
{
  type: 'JSXElement',
  children: [],
  openingElement: {
    type: 'JSXOpeningElement',
    name: { type: 'JSXIdentifier', name: 'div' },
    attributes: [],
    selfClosing: true
  },
  closingElement: null
}

but

require('meriyah').parse('var  a = <div></div>', {jsx: true}).body[0].declarations[0].init
Uncaught [ParseError [SyntaxError]: [1:20]: Unexpected token
] {
  index: 20,
  line: 1,
  column: 20,
  description: '[1:20]: Unexpected token',
  loc: { line: 1, column: 20 }
}

Did I do something wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
agilgur5commented, Sep 12, 2022
1reaction
agilgur5commented, Jun 8, 2022

Hi 👋 . I help maintain rollup-plugin-typescript2 nowadays and was looking into old issues and saw this was referenced from https://github.com/ezolenko/rollup-plugin-typescript2/issues/262 .

I haven’t been able to reproduce that specific issue and don’t think it’s related to this problem. If you believe this has to do with type-only files per your previous comment

I think rollup-plugin-typescript2 has some bug on invalidating cache. One ts file may be affected by multiple ts files (especially those only provide typing, but yield no js file).

then it could very well be due to https://github.com/ezolenko/rollup-plugin-typescript2/issues/7 instead, which indeed points out that the cache’s module graph may not correctly set dependencies (“One ts file may be affected by multiple ts files”) between modules when it comes to type-only files

Just thought I’d correct that for posterity and future reference, as well as give a possible root cause based on the comments here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest cannot parse JSX because "support is not enabled", but ...
When I run a custom test, it fails and Jest throws a SyntaxError saying Support for the experimental syntax 'jsx' isn't currently enabled...
Read more >
Seems can't parse JSX syntax · Issue #1 · seek-oss/playroom
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...
Read more >
JSX In Depth - React
Fundamentally, JSX just provides syntactic sugar for the React.createElement(component, props ... JSX type can't be an expression. return <components[props.
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 >
babel/preset-react
@babel/preset-react. This preset always includes the following plugins: @babel/plugin-syntax-jsx · @babel/plugin- ...
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