Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useable with mdx-bundler #432

Open
gurkerl83 opened this issue Aug 26, 2024 · 3 comments
Open

Useable with mdx-bundler #432

gurkerl83 opened this issue Aug 26, 2024 · 3 comments

Comments

@gurkerl83
Copy link

Hi. Congratulations on the release! I'm really excited to start using this new version of CodeHike.

I have a quick question regarding compatibility. It seems that CodeHike v1 is not fully compatible with mdx-bundler, particularly since mdx-bundler doesn’t support specifying recmaPlugins. Is that correct, or is there a workaround for this?

Thx!

@pomber
Copy link
Contributor

pomber commented Aug 26, 2024

thanks!

haven't tried it yet. adding recmaPlugins to mdx-bundler, if it's not supported yet, shouldn't be too hard

if you want you can start by opening an issue there, here are some similar issues for reference:

@gurkerl83
Copy link
Author

gurkerl83 commented Aug 27, 2024

Hi,

I managed to get it working by creating my own version of mdx-bundler. However, I noticed something that might be worth mentioning in the README. When using tools like this, having jsx: true in the config section can lead to a general error, which many users may not immediately understand. It could be helpful to include a note in the documentation about this. The process works fine without setting jsx: true.

const mdxOptions = {
  remarkPlugins: [[remarkCodeHike, chConfig]],
  recmaPlugins: [[recmaCodeHike, chConfig]],
  jsx: true,
}

According to the documentation, jsx: true determines whether JSX is kept uncompiled:

jsx (boolean, default: false) — whether to keep JSX; the default is to compile JSX away so that the resulting file is immediately runnable.

What is the intended use case for keeping JSX uncompiled in CodeHike? Understanding the reasoning behind this option would be helpful.

@pomber is the jsx: true required for code blocks?

Thx!

@gurkerl83 gurkerl83 reopened this Aug 27, 2024
@pomber
Copy link
Contributor

pomber commented Aug 28, 2024

I managed to get it working by creating my own version of mdx-bundler.

Nice, was it hard? do you think you can send a PR to the mdx-bundler repo?

What is the intended use case for keeping JSX uncompiled in CodeHike? is the jsx: true required for code blocks?

It's not required. jsx: false wasn't supported by Code Hike before, but now it should work the same as jsx: true.

Internally, the recmaCodeHike plugin works differently depending on that flag, and jsx: false is harder to transform. If you have a minimal example that works differently depending on the flag, please send it my way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants