mdxjs-rs icon indicating copy to clipboard operation
mdxjs-rs copied to clipboard

Update `swc_core` to `v0.99.x `

Open kdy1 opened this issue 1 year ago • 4 comments

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.

kdy1 avatar Jul 23 '24 04:07 kdy1

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

wooorm avatar Jul 23 '24 07:07 wooorm

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

kdy1 avatar Jul 23 '24 07:07 kdy1

what is the hack? 🤔

wooorm avatar Jul 23 '24 08:07 wooorm

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

kdy1 avatar Jul 23 '24 09:07 kdy1

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

kdy1 avatar Jul 30 '24 04:07 kdy1

Nevermind, I fixed it

kdy1 avatar Jul 30 '24 04:07 kdy1

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!

wooorm avatar Jul 30 '24 10:07 wooorm

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!

kdy1 avatar Jul 30 '24 10:07 kdy1

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 avatar Jul 30 '24 15:07 wooorm

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 avatar Jul 31 '24 09:07 wooorm

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?

wooorm avatar Jul 31 '24 09:07 wooorm

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

kdy1 avatar Jul 31 '24 12:07 kdy1

Great, thank you! 🙏

wooorm avatar Jul 31 '24 13:07 wooorm

@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.

kdy1 avatar Aug 01 '24 05:08 kdy1

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

wooorm avatar Aug 01 '24 07:08 wooorm

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

wooorm avatar Aug 01 '24 07:08 wooorm

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

wooorm avatar Aug 05 '24 12:08 wooorm

Thank you!

kdy1 avatar Aug 05 '24 12:08 kdy1