diff --git a/CHANGELOG.md b/CHANGELOG.md index 86fab3a77e..ec66d3824b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ - Refactor the ast for record expressions and patterns. https://github.com/rescript-lang/rescript/pull/7528 - Editor: add completions from included modules. https://github.com/rescript-lang/rescript/pull/7515 +- Add `-editor-mode` arg to `bsc` for doing special optimizations only relevant to the editor tooling. https://github.com/rescript-lang/rescript/pull/7541 # 12.0.0-alpha.13 diff --git a/compiler/bsc/rescript_compiler_main.ml b/compiler/bsc/rescript_compiler_main.ml index 52f4b85651..3cd66e9e3b 100644 --- a/compiler/bsc/rescript_compiler_main.ml +++ b/compiler/bsc/rescript_compiler_main.ml @@ -392,6 +392,12 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array = print the transformed ReScript code to stdout" ); ("-format", string_call format_file, "*internal* Format as Res syntax"); ("-only-parse", set Clflags.only_parse, "*internal* stop after parsing"); + ( "-editor-mode", + unit_call (fun () -> + Clflags.editor_mode := true; + Clflags.ignore_parse_errors := true; + Js_config.cmi_only := true), + "*internal* Enable editor mode." ); ( "-ignore-parse-errors", set Clflags.ignore_parse_errors, "*internal* continue after parse errors" ); diff --git a/compiler/ml/clflags.ml b/compiler/ml/clflags.ml index 2b663ba24e..f0cd88115e 100644 --- a/compiler/ml/clflags.ml +++ b/compiler/ml/clflags.ml @@ -40,6 +40,8 @@ and dump_lambda = ref false (* -dlambda *) and only_parse = ref false (* -only-parse *) +and editor_mode = ref false (* -editor-mode *) + and ignore_parse_errors = ref false (* -ignore-parse-errors *) let dont_write_files = ref false (* set to true under ocamldoc *) diff --git a/compiler/ml/clflags.mli b/compiler/ml/clflags.mli index c861614928..0cb5f1ea3e 100644 --- a/compiler/ml/clflags.mli +++ b/compiler/ml/clflags.mli @@ -25,6 +25,7 @@ val dont_write_files : bool ref val keep_locs : bool ref val only_parse : bool ref val ignore_parse_errors : bool ref +val editor_mode : bool ref val parse_color_setting : string -> Misc.Color.setting option val color : Misc.Color.setting option ref