wooorm / mdxjs-rs

Compile MDX to JavaScript in Rust
https://docs.rs/mdxjs/
MIT License
429 stars 14 forks source link

Update `swc_core` to `v0.100.x ` #49

Closed kdy1 closed 3 months ago

kdy1 commented 3 months ago

https://swc.rs/docs/plugin/selecting-swc-core

I found that mdxjs-rs was using a hack based on SyntaxContext, but it's not possible anymore and I'm not sure how should I fix it.

wooorm commented 3 months ago

Hey! Did this work for you locally? Are you still working on making CI green?

kdy1 commented 3 months ago

I'm not sure how I should modify the hack using SyntaxContext, and that's why I filed this PR.

wooorm commented 3 months ago

what is the hack? 🤔

kdy1 commented 3 months ago

I meant https://github.com/wooorm/mdxjs-rs/blob/e07722061f4ac6da3b1c4f09750c05b4d4ef6908/src/hast_util_to_swc.rs#L43

kdy1 commented 3 months ago

Can you help remove the hack? The Span does not have SyntaxContext anymore, and if I ignoring explciit_jsx, the test fails

kdy1 commented 3 months ago

Nevermind, I fixed it

wooorm commented 3 months ago

Nice! Does that mean you changed SWC to allow some magic number marking again? I see this PR is still a draft, do let me know if I can help / if it’s ready!

kdy1 commented 3 months ago

Instead of modifying swc back to allow magic number, I introduced FxHashSet<Span> that holds the spans of explicit JSX inputs. And now it's ready for a review. Thank you!

wooorm commented 3 months ago

ok, I looked into applying the same updates to markdown-rs too, which has some more parsing tests. Something changed in SWC to make a (correct) test fail there. Will have to investigate tomorrow why that is and what’s needed!

wooorm commented 3 months ago

It looks like when I pass " /* " to SWC, it now returns an error for Error { error: (1..1, Eof) }. I need to know that the error is at the end of the input. Seems the positional info of hi is incorrect? Could that be a regression?

wooorm commented 3 months ago

Can confirm that I got Error { error: (2..5#0, UnterminatedBlockComment) } before on 0.94.0. It broke in 0.95.0.

Is this something that can be fixed in SWC, that EOF errors “stick” to the end again?

kdy1 commented 3 months ago

I can fix it in SWC. I'll do it tomorrow

wooorm commented 3 months ago

Great, thank you! 🙏

kdy1 commented 3 months ago

@wooorm Do you have a PR for swc upgrade? I merged/published patch in https://github.com/swc-project/swc/pull/9361 but I'm not sure if it's fixed.

wooorm commented 3 months ago

not seeing a release on https://crates.io/crates/swc_core/versions btw? :eyes:

wooorm commented 3 months ago

PR at https://github.com/wooorm/markdown-rs/pull/120

wooorm commented 3 months ago

Released, thank you! https://github.com/wooorm/mdxjs-rs/releases/tag/0.2.6

kdy1 commented 3 months ago

Thank you!