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.

`jsx: true` output does not handle custom elements correctly

See original GitHub issue

Initial checklist

Affected packages and versions

^2.1.2"

Link to runnable example

https://stackblitz.com/github/bholmesdev/mdx-shiki-compilation?file=test.mjs

Steps to reproduce

  1. Run the MDX compiler with the rehypeRaw plugin applied + some other plugin that inserts a custom element (Shiki twoslash in this case).
  2. Set jsx: true in the compiler config
  3. Note the value contains <_components.custom-element-name> in the output, but dashes (-) are not valid JSX!

Expected behavior

Ideally, the _components statement would serialize dashes to camelCase or some other JSX-compliant string like so:

const _components = Object.assign({
    ...
    "customElementName": "custom-element-name"
  }, props.components);

Actual behavior

Instead, _components uses the element name untouched:

const _components = Object.assign({
   ...
    "custom-element-name": "custom-element-name"
  }, props.components);

Runtime

Node v16

Package manager

pnpm

OS

macOS

Build and bundle tools

Other (please specify in steps to reproduce)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bholmesdevcommented, Aug 12, 2022

@wooorm Addressed in the latest! Should be good for review. #2101

1reaction
bholmesdevcommented, Aug 11, 2022

@wooorm That could work too! So create variables below the _components declaration with an incrementing counter?

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: react custom elements does not account for dist ...
By default, the custom elements bundle will be written to dist/custom-elements/index.js. This directory can be configured using the output target's dir config.
Read more >
JSX In Depth
The first part of a JSX tag determines the type of the React element. Capitalized types indicate that the JSX tag is referring...
Read more >
react: dispatch and listen to custom events
I can dispatch custom events from react components and listen to them on dom elements. But I can't catch these events on other...
Read more >
Handling data with Web Components | by Andreas Remdt
Attributes for custom elements are not different from the attributes we already know and love: class , value , label and many more...
Read more >
How To Create Custom Components in React
In this tutorial, you'll learn to create custom components in React. Components are independent pieces of functionality that you can reuse ...
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