Skip to content

Commit cc410f2

Browse files
authored
Make build -with-deps a default behaviour (#6350)
* Make build -with-deps a default behaviour * Clean up -with-deps from the codebase * Fix build tests * Update changelog * Update args parse message * Fix error * Uncomment ciTest code * Update module not found error. * Clean up build_tests package jsons
1 parent 98717b1 commit cc410f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+224
-183
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 11.0.0-rc.2 (Unreleased)
1414

15+
#### :rocket: New Feature
16+
17+
- `rescript build` will always build its dependency by default. The argument `-with-deps` is not needed anymore. https://github.com/rescript-lang/rescript-compiler/pull/6350
18+
1519
#### :bug: Bug Fix
1620

1721
- Fixed outcome printer resolution of uncurried config. https://github.com/rescript-lang/rescript-compiler/pull/6353

jscomp/bsb/bsb_exception.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ let print (fmt : Format.formatter) (x : error) =
6666
Format.fprintf fmt
6767
"File \"bsconfig.json\", line 1\n\
6868
@{<error>Error:@} package @{<error>%s@} not found or built %s\n\
69-
- Did you install it?\n\
70-
- If you did, did you run `rescript build -with-deps`?" name in_json
69+
- Did you install it?" name in_json
7170
| Json_config (pos, s) ->
7271
Format.fprintf fmt
7372
"File %S, line %d:\n\

jscomp/bsb_exe/rescript_main.ml

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ let separator = "--"
2828

2929
let watch_mode = ref false
3030

31-
let make_world = ref false
32-
3331
let do_install = ref false
3432

3533
let force_regenerate = ref false
@@ -109,24 +107,6 @@ let install_target () =
109107
let eid = Bsb_unix.run_command_execv install_command in
110108
if eid <> 0 then Bsb_unix.command_fatal_error install_command eid
111109

112-
(** check if every dependency installation dierctory is there
113-
This is in hot path, so we want it to be fast.
114-
The heuristics is that if the installation directory is not there,
115-
we definitely need build the world.
116-
If it is there, we do not check if it is up-to-date, since that's
117-
going be slow, user can use `-with-deps` to enforce such check
118-
*)
119-
let check_deps_installation_directory (config_opt : Bsb_config_types.t option) :
120-
bool =
121-
match config_opt with
122-
| Some { bs_dependencies; bs_dev_dependencies } ->
123-
not
124-
(Ext_list.for_all bs_dependencies (fun x ->
125-
Ext_sys.is_directory_no_exn x.package_install_path)
126-
&& Ext_list.for_all bs_dev_dependencies (fun x ->
127-
Ext_sys.is_directory_no_exn x.package_install_path))
128-
| None -> false
129-
130110
let build_subcommand ~start argv argv_len =
131111
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in
132112

@@ -135,10 +115,10 @@ let build_subcommand ~start argv argv_len =
135115
~argv
136116
[|
137117
("-w", unit_set_spec watch_mode, "Watch mode");
138-
("-with-deps", unit_set_spec make_world, "Build dependencies explicitly");
118+
("-with-deps", unit_set_spec (ref true), "*deprecated* This is the default behavior now. This option will be removed in a future release");
139119
( "-install",
140120
unit_set_spec do_install,
141-
"*internal* Install public interface files for dependencies " );
121+
"*internal* Install public interface files for dependencies" );
142122
(* This should be put in a subcommand
143123
previously it works with the implication `bsb && bsb -install`
144124
*)
@@ -162,15 +142,8 @@ let build_subcommand ~start argv argv_len =
162142
| _ ->
163143
let config_opt =
164144
Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel
165-
~per_proj_dir:Bsb_global_paths.cwd ~forced:!force_regenerate
166-
in
167-
let implict_build = check_deps_installation_directory config_opt in
168-
(match (!make_world, implict_build) with
169-
| true, _ ->
170-
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args
171-
| false, true ->
172-
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||]
173-
| false, false -> ());
145+
~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;
174147
if !do_install then install_target ();
175148
if !watch_mode then exit 0 (* let the watcher do the build*)
176149
else ninja_command_exit ninja_args
@@ -179,8 +152,8 @@ let clean_subcommand ~start argv =
179152
Bsb_arg.parse_exn ~usage:clean_usage ~start ~argv
180153
[|
181154
( "-with-deps",
182-
unit_set_spec make_world,
183-
"*internal* Clean dependencies too" );
155+
unit_set_spec (ref true),
156+
"*deprecated* This is the default behavior now. This option will be removed in a future release" );
184157
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
185158
|]
186159
failed_annon;
@@ -226,10 +199,8 @@ let () =
226199
(* specialize this path which is used in watcher *)
227200
let config_opt =
228201
Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel ~forced:false
229-
~per_proj_dir:Bsb_global_paths.cwd
230-
in
231-
if !make_world || check_deps_installation_directory config_opt then
232-
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||];
202+
~per_proj_dir:Bsb_global_paths.cwd in
203+
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||];
233204
ninja_command_exit [||])
234205
else
235206
match argv.(1) with

jscomp/build_tests/case/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "case",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/case2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "case2",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/case3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "case3",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/custom_namespace/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var path = require("path");
44
var assert = require("assert");
55
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
66

7-
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
7+
child_process.execSync(`${rescript_exe} clean && ${rescript_exe} build`, {
88
cwd: __dirname,
99
});
1010

jscomp/build_tests/custom_namespace/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "namespace",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/cycle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cycle",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/cycle1/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const fs = require('fs')
55
const path = require('path')
66
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
77

8-
cp.execSync(`${rescript_exe} clean -with-deps`, { cwd: __dirname, });
8+
cp.execSync(`${rescript_exe} clean`, { cwd: __dirname, });
99

1010
var output = cp.spawnSync(rescript_exe, { encoding: "utf8", shell: true });
1111

jscomp/build_tests/devdeps/input.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

jscomp/build_tests/devdeps/node_modules/weird/bsconfig.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

jscomp/build_tests/devdeps/node_modules/weird/package.json

Whitespace-only changes.

jscomp/build_tests/devdeps/package-lock.json

Lines changed: 0 additions & 64 deletions
This file was deleted.

jscomp/build_tests/devonly/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "devonly",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/duplicated_symlinked_packages/a/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"build": "rescript build",
66
"start": "rescript build -w",
7-
"clean": "rescript clean -with-deps"
7+
"clean": "rescript clean"
88
},
99
"keywords": [
1010
"BuckleScript"

jscomp/build_tests/duplicated_symlinked_packages/b/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"build": "rescript build",
66
"start": "rescript build -w",
7-
"clean": "rescript clean -with-deps"
7+
"clean": "rescript clean"
88
},
99
"keywords": [
1010
"BuckleScript"

jscomp/build_tests/duplicated_symlinked_packages/c/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scripts": {
55
"build": "rescript build",
66
"start": "rescript build -w",
7-
"clean": "rescript clean -with-deps"
7+
"clean": "rescript clean"
88
},
99
"keywords": [
1010
"BuckleScript"

jscomp/build_tests/duplicated_symlinked_packages/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function postProcessErrorOutput (output) {
1212
output = output.replace(new RegExp(__dirname, 'gi'), '.')
1313
return output
1414
}
15-
child_process.execSync(`${rescript_exe} clean -with-deps`,{cwd:__dirname})
15+
child_process.execSync(`${rescript_exe} clean`,{cwd:__dirname})
1616
child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => {
1717
const actualErrorOutput = postProcessErrorOutput(stderr.toString())
1818
if (updateTests) {

jscomp/build_tests/duplicated_symlinked_packages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "duplicated-symlinked-packages",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/exports/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "exports",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/hyphen2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "hyphen2",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/install/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "install",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"install": "rescript build -install",
88
"watch": "rescript build -w"

jscomp/build_tests/nested/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nested",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/nnest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nested",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/ns/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ns",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

jscomp/build_tests/post-build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "post-build",
33
"version": "0.1.0",
44
"scripts": {
5-
"clean": "rescript clean -with-deps",
5+
"clean": "rescript clean",
66
"build": "rescript build",
77
"watch": "rescript build -w"
88
},

0 commit comments

Comments
 (0)