Skip to content

Commit e1feb10

Browse files
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 <florianh89@gmail.com>
1 parent 39bd7be commit e1feb10

7 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ $ node
428428
> eval(result.js_code);
429429
```
430430

431-
### Lambda debug outputs (API v9)
431+
### Lambda debug outputs
432432

433433
`comp.rescript.compileWithDebug(source)` returns `lambda` before the backend's
434434
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
437437
transformations; this snapshot is not the final JavaScript IR.
438438

439439
Regular `comp.rescript.compile(source)` does not capture these debug outputs.
440-
Older bundles do not provide `lambda_optimized`; consumers should treat it as
441-
optional when supporting multiple API versions.
440+
Older bundles do not provide `lambda_optimized`; detect this optional field's
441+
presence rather than inferring support from the API version.
442442

443443
### Testing the Playground bundle
444444

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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
1+
- 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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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/XXXX

‎compiler/jsoo/jsoo_playground_main.ml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
* v6: Added `config.experimental_features` and `config.jsx_preserve_mode` to the BundleConfig.
5454
* v7: Added debug dump output APIs for developer playground tooling.
5555
* v8: Added genType and source map configuration and compilation outputs.
56-
* v9: Added optimized Lambda output to debug compilation.
5756
* *)
58-
let api_version = "9"
57+
(* Optional debug-output fields are detected by presence, without an API bump. *)
58+
let api_version = "8"
5959

6060
module Js = Js_of_ocaml.Js
6161

‎packages/dev-playground/scripts/lambda-diff.test.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,5 +444,6 @@ test("older bundles retain the optimized Lambda availability notice", () => {
444444
Signal.set(input, { ...Signal.peek(input), after: undefined });
445445
Signal.set(mode, "Diff");
446446
assert.match(html(), /does not provide optimized Lambda/);
447+
assert.doesNotMatch(html(), /API v9/);
447448
assert.doesNotMatch(html(), /class="lambda-diff"/);
448449
});

‎packages/dev-playground/src/LambdaView.res‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ let make = (~input: unit => option<input>, ~visible, ~mode: Signal.t<mode>) => {
112112
let unavailable = () =>
113113
<p class="lambda-notice">
114114
{View.text(
115-
"This compiler bundle does not provide optimized Lambda. Select a compiler with playground API v9 or newer.",
115+
"This compiler bundle does not provide optimized Lambda. Select a newer compiler bundle.",
116116
)}
117117
</p>
118118
let panelInput = Signal.make(None)

‎packages/playground/playground_test.cjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const syntaxErrorResult = compiler.rescript.compile("let = 1");
174174
assert.equal(syntaxErrorResult.type, "syntax_error");
175175
assert.match(syntaxErrorResult.errors[0].fullMsg, /\u001b\[/);
176176

177-
assert.equal(rescript_compiler.api_version, "9");
177+
assert.equal(rescript_compiler.api_version, "8");
178178
const lambdaSource = "let compute = x => { let unused = x + 1; x }";
179179
const lambdaResult = compiler.rescript.compileWithDebug(lambdaSource);
180180
assert.equal(lambdaResult.type, "success");

0 commit comments

Comments
 (0)