From 13d880d239d9b938c8788ddf675a92778e913549 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 3 Jul 2025 14:32:00 +0200 Subject: [PATCH] Fix issue with preserve mode where `jsx` is declared as an external without a `@module` attribute Fixes https://github.com/rescript-lang/rescript/pull/7577 --- CHANGELOG.md | 1 + compiler/core/js_dump.ml | 11 ++++++----- tests/tests/src/jsx_preserve_test.mjs | 8 ++++++++ tests/tests/src/jsx_preserve_test.res | 13 +++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80d734f216..7d70ae26fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Prop punning when types don't match results in I/O error: _none_: No such file or directory. https://github.com/rescript-lang/rescript/pull/7533 - Pass location to children prop in jsx ppx. https://github.com/rescript-lang/rescript/pull/7540 - Fix crash when `bs-g` is used with untagged variants. https://github.com/rescript-lang/rescript/pull/7575 +- Fix issue with preserve mode where `jsx` is declared as an external without a `@module` attribute. https://github.com/rescript-lang/rescript/pull/7591 #### :nail_care: Polish diff --git a/compiler/core/js_dump.ml b/compiler/core/js_dump.ml index 99bfce9140..1684aa056c 100644 --- a/compiler/core/js_dump.ml +++ b/compiler/core/js_dump.ml @@ -533,12 +533,13 @@ and expression_desc cxt ~(level : int) f x : cxt = ( ({ expression_desc = J.Var - (J.Qualified - ( _, - Some fnName - (* We care about the function name when it is jsxs, + ( Id {name = fnName} + | J.Qualified + ( _, + Some fnName + (* We care about the function name when it is jsxs, If this is the case, we need to unpack an array later on *) - )); + ) ); } as e), el, {call_transformed_jsx = true} ) diff --git a/tests/tests/src/jsx_preserve_test.mjs b/tests/tests/src/jsx_preserve_test.mjs index 3c71b71dc7..9cf576055e 100644 --- a/tests/tests/src/jsx_preserve_test.mjs +++ b/tests/tests/src/jsx_preserve_test.mjs @@ -208,6 +208,12 @@ let _props_with_hyphen =