Skip to content

Commit 7e2e81f

Browse files
DZakhcknitt
andauthored
ReScript cli clean up + watcher fix (rescript-lang#6404)
* Watch mode clean up * Update clean command help * Update changelog * Update CHANGELOG.md Co-authored-by: Christoph Knittel <christoph@knittel.cc> --------- Co-authored-by: Christoph Knittel <christoph@knittel.cc>
1 parent 843e2fc commit 7e2e81f

File tree

3 files changed

+399
-385
lines changed

3 files changed

+399
-385
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
#### :bug: Bug Fix
1616

17-
- Fix issue with GenType and labelled arguments https://github.com/rescript-lang/rescript-compiler/pull/6406
17+
- Fix issue with GenType and labelled arguments. https://github.com/rescript-lang/rescript-compiler/pull/6406
18+
- Fix dependencies reinitialization on every change in watch mode. Leads to faster rebuilds and cleaner terminal. https://github.com/rescript-lang/rescript-compiler/pull/6404
1819

1920
#### :rocket: New Feature
2021

@@ -29,6 +30,9 @@
2930
- The error message for "toplevel expressions should evaluate to unit" has been revamped and improved. https://github.com/rescript-lang/rescript-compiler/pull/6407
3031
- Improve "Somewhere wanted" error messages by changing wording and adding more context + suggested solutions to the error messages where appropriate. https://github.com/rescript-lang/rescript-compiler/pull/6410
3132
- Add smart printer for pipe-chains. https://github.com/rescript-lang/rescript-compiler/pull/6411
33+
- Display the compile time for `rescript build` command. https://github.com/rescript-lang/rescript-compiler/pull/6404
34+
- Improve help message for `build` and `clean` commands. https://github.com/rescript-lang/rescript-compiler/pull/6404
35+
- Pass through the `-verbose` flag to builds in watch mode. https://github.com/rescript-lang/rescript-compiler/pull/6404
3236

3337
# 11.0.0-rc.3
3438

jscomp/bsb_exe/rescript_main.ml

+15-15
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let () = Bsb_log.setup ()
2626

2727
let separator = "--"
2828

29-
let watch_mode = ref false
29+
let no_deps_mode = ref false
3030

3131
let do_install = ref false
3232

@@ -84,13 +84,13 @@ let ninja_command_exit (type t) (ninja_args : string array) : t =
8484
ninja -C _build
8585
*)
8686
let clean_usage =
87-
"Usage: rescript.exe clean <options>\n\n\
88-
`rescript clean` only cleans the current project\n"
87+
"Usage: rescript clean <options>\n\n\
88+
`rescript clean` cleans build artifacts\n"
8989

9090
let build_usage =
91-
"Usage: rescript.exe build <options> -- <ninja_options>\n\n\
92-
`rescript build` implicitly builds dependencies if they aren't built\n\n\
93-
`rescript.exe -- -h` for Ninja options (internal usage only; unstable)\n"
91+
"Usage: rescript build <options> -- <ninja_options>\n\n\
92+
`rescript build` builds the project with dependencies\n\n\
93+
`rescript -- -h` for Ninja options (internal usage only; unstable)\n"
9494

9595
let install_target () =
9696
let ( // ) = Filename.concat in
@@ -114,23 +114,24 @@ let build_subcommand ~start argv argv_len =
114114
?finish:(if i < 0 then None else Some i)
115115
~argv
116116
[|
117-
("-w", unit_set_spec watch_mode, "Watch mode");
117+
("-w", unit_set_spec (ref false), "Watch mode");
118+
( "-ws",
119+
string_set_spec (ref ""),
120+
"[host]:port set up host & port for WebSocket build notifications" );
121+
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
118122
("-with-deps", unit_set_spec (ref true), "*deprecated* This is the default behavior now. This option will be removed in a future release");
119123
( "-install",
120124
unit_set_spec do_install,
121125
"*internal* Install public interface files for dependencies" );
122126
(* This should be put in a subcommand
123127
previously it works with the implication `bsb && bsb -install`
124128
*)
125-
( "-ws",
126-
string_set_spec (ref ""),
127-
"[host]:port set up host & port for WebSocket build notifications" );
128129
( "-regen",
129130
unit_set_spec force_regenerate,
130131
"*internal* \n\
131132
Always regenerate build.ninja no matter bsconfig.json is changed or \
132133
not" );
133-
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
134+
("-no-deps", unit_set_spec no_deps_mode, "*internal* Needed for watcher to build without dependencies on file change");
134135
|]
135136
failed_annon;
136137

@@ -143,18 +144,17 @@ let build_subcommand ~start argv argv_len =
143144
let config_opt =
144145
Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel
145146
~per_proj_dir:Bsb_global_paths.cwd ~forced:!force_regenerate in
146-
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args;
147+
if not !no_deps_mode then Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args;
147148
if !do_install then install_target ();
148-
if !watch_mode then exit 0 (* let the watcher do the build*)
149-
else ninja_command_exit ninja_args
149+
ninja_command_exit ninja_args
150150

151151
let clean_subcommand ~start argv =
152152
Bsb_arg.parse_exn ~usage:clean_usage ~start ~argv
153153
[|
154+
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
154155
( "-with-deps",
155156
unit_set_spec (ref true),
156157
"*deprecated* This is the default behavior now. This option will be removed in a future release" );
157-
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
158158
|]
159159
failed_annon;
160160
Bsb_clean.clean_bs_deps Bsb_global_paths.cwd;

0 commit comments

Comments
 (0)