From ac42462e7dba39ba722f49d440c6f9bb0d615aee Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Tue, 20 Oct 2026 15:31:34 +0200 Subject: [PATCH 1/2] Keep optimized Lambda output compatible with playground API v8 Why: lambda_optimized is an optional compileWithDebug field. Existing compiler calls remain compatible, so advertising API v9 needlessly makes clients with an explicit version allowlist reject the bundle. Restore API v8 and keep optimized Lambda output intact. Consumers detect the field's presence. Remove the v9 requirement from the availability notice, contributor guide, and original changelog entry. Review: The bundle test requires API v8 and optimized output together, and continues to verify that regular compilation does not capture that output. The older-bundle UI test rejects the obsolete API-v9 guidance. Validation: Native and browser compiler builds, the compiler suites, playground bundle tests, all 37 developer playground tests under Node 22 with locked rescript-signals 3.1.1, the production Vite build, and format checks pass. Signed-off-by: Florian Hammerschmidt --- CONTRIBUTING.md | 6 +++--- changes/developer-playground-lambda-diff.internal.md | 2 +- changes/playground-api-v8-compatibility.fix.md | 1 + compiler/jsoo/jsoo_playground_main.ml | 4 ++-- packages/dev-playground/scripts/lambda-diff.test.mjs | 1 + packages/dev-playground/src/LambdaView.res | 2 +- packages/playground/playground_test.cjs | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 changes/playground-api-v8-compatibility.fix.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8963c65153..fde0d4343a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -428,7 +428,7 @@ $ node > eval(result.js_code); ``` -### Lambda debug outputs (API v9) +### Lambda debug outputs `comp.rescript.compileWithDebug(source)` returns `lambda` before the backend's Lambda optimization passes and `lambda_optimized` after the whole-term passes, @@ -437,8 +437,8 @@ so their text can be compared directly. JavaScript lowering performs further transformations; this snapshot is not the final JavaScript IR. Regular `comp.rescript.compile(source)` does not capture these debug outputs. -Older bundles do not provide `lambda_optimized`; consumers should treat it as -optional when supporting multiple API versions. +Older bundles do not provide `lambda_optimized`; detect this optional field's +presence rather than inferring support from the API version. ### Testing the Playground bundle diff --git a/changes/developer-playground-lambda-diff.internal.md b/changes/developer-playground-lambda-diff.internal.md index e20c50b6b7..c8d02b90b0 100644 --- a/changes/developer-playground-lambda-diff.internal.md +++ b/changes/developer-playground-lambda-diff.internal.md @@ -1 +1 @@ -- Add before/after optimization views and inline diffs to the developer playground's Lambda tab, with optimized Lambda output in playground API v9, deferred hidden-panel updates, and debounced comparisons while editing. https://github.com/rescript-lang/rescript/pull/8636 +- Add before/after optimization views and inline diffs to the developer playground's Lambda tab, with optional optimized Lambda output, deferred hidden-panel updates, and debounced comparisons while editing. https://github.com/rescript-lang/rescript/pull/8636 diff --git a/changes/playground-api-v8-compatibility.fix.md b/changes/playground-api-v8-compatibility.fix.md new file mode 100644 index 0000000000..27506114df --- /dev/null +++ b/changes/playground-api-v8-compatibility.fix.md @@ -0,0 +1 @@ +- Keep playground compiler API v8 when adding optional optimized Lambda output, preserving compatibility with existing playground clients. https://github.com/rescript-lang/rescript/pull/8930 diff --git a/compiler/jsoo/jsoo_playground_main.ml b/compiler/jsoo/jsoo_playground_main.ml index b66c568ffb..c0d929677a 100644 --- a/compiler/jsoo/jsoo_playground_main.ml +++ b/compiler/jsoo/jsoo_playground_main.ml @@ -53,9 +53,9 @@ * v6: Added `config.experimental_features` and `config.jsx_preserve_mode` to the BundleConfig. * v7: Added debug dump output APIs for developer playground tooling. * v8: Added genType and source map configuration and compilation outputs. - * v9: Added optimized Lambda output to debug compilation. * *) -let api_version = "9" +(* Optional debug-output fields are detected by presence, without an API bump. *) +let api_version = "8" module Js = Js_of_ocaml.Js diff --git a/packages/dev-playground/scripts/lambda-diff.test.mjs b/packages/dev-playground/scripts/lambda-diff.test.mjs index f8f7df53d8..fa96d60861 100644 --- a/packages/dev-playground/scripts/lambda-diff.test.mjs +++ b/packages/dev-playground/scripts/lambda-diff.test.mjs @@ -444,5 +444,6 @@ test("older bundles retain the optimized Lambda availability notice", () => { Signal.set(input, { ...Signal.peek(input), after: undefined }); Signal.set(mode, "Diff"); assert.match(html(), /does not provide optimized Lambda/); + assert.doesNotMatch(html(), /API v9/); assert.doesNotMatch(html(), /class="lambda-diff"/); }); diff --git a/packages/dev-playground/src/LambdaView.res b/packages/dev-playground/src/LambdaView.res index 4f67e6dc77..67701b4742 100644 --- a/packages/dev-playground/src/LambdaView.res +++ b/packages/dev-playground/src/LambdaView.res @@ -112,7 +112,7 @@ let make = (~input: unit => option, ~visible, ~mode: Signal.t) => { let unavailable = () =>

{View.text( - "This compiler bundle does not provide optimized Lambda. Select a compiler with playground API v9 or newer.", + "This compiler bundle does not provide optimized Lambda. Select a newer compiler bundle.", )}

let panelInput = Signal.make(None) diff --git a/packages/playground/playground_test.cjs b/packages/playground/playground_test.cjs index 82dd9dcd9a..2fa5fbd25d 100644 --- a/packages/playground/playground_test.cjs +++ b/packages/playground/playground_test.cjs @@ -174,7 +174,7 @@ const syntaxErrorResult = compiler.rescript.compile("let = 1"); assert.equal(syntaxErrorResult.type, "syntax_error"); assert.match(syntaxErrorResult.errors[0].fullMsg, /\u001b\[/); -assert.equal(rescript_compiler.api_version, "9"); +assert.equal(rescript_compiler.api_version, "8"); const lambdaSource = "let compute = x => { let unused = x + 1; x }"; const lambdaResult = compiler.rescript.compileWithDebug(lambdaSource); assert.equal(lambdaResult.type, "success"); From c4593252ba0834643cc8d46583532e32013f4b41 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Tue, 20 Oct 2026 15:40:57 +0200 Subject: [PATCH 2/2] Remove redundant API compatibility commentary Remove the added API-v9 text assertion and the optional debug-output comment as requested in review. The API-v8 bundle regression remains in place. Validation: make compiler and all 26 Lambda diff tests pass. Signed-off-by: Florian Hammerschmidt --- compiler/jsoo/jsoo_playground_main.ml | 1 - packages/dev-playground/scripts/lambda-diff.test.mjs | 1 - 2 files changed, 2 deletions(-) diff --git a/compiler/jsoo/jsoo_playground_main.ml b/compiler/jsoo/jsoo_playground_main.ml index c0d929677a..e47c92fbe8 100644 --- a/compiler/jsoo/jsoo_playground_main.ml +++ b/compiler/jsoo/jsoo_playground_main.ml @@ -54,7 +54,6 @@ * v7: Added debug dump output APIs for developer playground tooling. * v8: Added genType and source map configuration and compilation outputs. * *) -(* Optional debug-output fields are detected by presence, without an API bump. *) let api_version = "8" module Js = Js_of_ocaml.Js diff --git a/packages/dev-playground/scripts/lambda-diff.test.mjs b/packages/dev-playground/scripts/lambda-diff.test.mjs index fa96d60861..f8f7df53d8 100644 --- a/packages/dev-playground/scripts/lambda-diff.test.mjs +++ b/packages/dev-playground/scripts/lambda-diff.test.mjs @@ -444,6 +444,5 @@ test("older bundles retain the optimized Lambda availability notice", () => { Signal.set(input, { ...Signal.peek(input), after: undefined }); Signal.set(mode, "Diff"); assert.match(html(), /does not provide optimized Lambda/); - assert.doesNotMatch(html(), /API v9/); assert.doesNotMatch(html(), /class="lambda-diff"/); });