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..e47c92fbe8 100644 --- a/compiler/jsoo/jsoo_playground_main.ml +++ b/compiler/jsoo/jsoo_playground_main.ml @@ -53,9 +53,8 @@ * 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" +let api_version = "8" module Js = Js_of_ocaml.Js 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");