Skip to content

Remove all leftovers of pinned-dependencies handling #7686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Add rust linting to CI with `clippy`. https://github.com/rescript-lang/rescript/pull/7675
- AST: use `Typ.arrows` for creation, after the refactoring of arrow types. https://github.com/rescript-lang/rescript/pull/7662
- Don't skip Stdlib docstring tests. https://github.com/rescript-lang/rescript/pull/7694
- Remove all leftovers of pinned-dependencies handling. https://github.com/rescript-lang/rescript/pull/7686

#### :bug: Bug fix

Expand Down
1 change: 0 additions & 1 deletion analysis/examples/workspace-project/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"in-source": true
},
"suffix": ".mjs",
"pinned-dependencies": ["common", "myplugin", "app"],
"bs-dependencies": ["common", "myplugin", "app"]
}
1 change: 0 additions & 1 deletion compiler/bsb/bsb_build_schemas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ let ppx_flags = "ppx-flags"
let pp_flags = "pp-flags"
let bs_external_includes = "bs-external-includes"
let bs_dependencies = "bs-dependencies"
let pinned_dependencies = "pinned-dependencies"
let bs_dev_dependencies = "bs-dev-dependencies"
let sources = "sources"
let dir = "dir"
Expand Down
41 changes: 8 additions & 33 deletions compiler/bsb/bsb_build_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ let ( |? ) m (key, cb) = m |> Ext_json.test key cb

type top = Expect_none | Expect_name of string

type package_context = {proj_dir: string; top: top; is_pinned: bool}
type package_context = {proj_dir: string; top: top}

(**
TODO: check duplicate package name
Expand All @@ -148,15 +148,8 @@ type package_context = {proj_dir: string; top: top; is_pinned: bool}
let pp_packages_rev ppf lst =
Ext_list.rev_iter lst (fun s -> Format.fprintf ppf "%s " s)

let extract_pinned_dependencies (map : Ext_json_types.t Map_string.t) :
Set_string.t =
match Map_string.find_opt map Bsb_build_schemas.pinned_dependencies with
| None -> Set_string.empty
| Some (Arr {content}) -> Set_string.of_list (get_list_string content)
| Some config -> Bsb_exception.config_error config "expect an array of string"

let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list)
~(top : top) (dir : string) (queue : _ Queue.t) ~pinned_dependencies =
~(top : top) (dir : string) (queue : _ Queue.t) =
match
Bsb_config_load.load_json ~per_proj_dir:dir ~warn_legacy_config:false
with
Expand All @@ -182,7 +175,7 @@ let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list)
if Hash_string.mem visited cur_package_name then
Bsb_log.info "@{<info>Visited before@} %s@." cur_package_name
else
let explore_deps (deps : string) pinned_dependencies =
let explore_deps (deps : string) =
map
|? ( deps,
`Arr
Expand All @@ -196,38 +189,20 @@ let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list)
in
walk_all_deps_aux visited package_stacks
~top:(Expect_name new_package) package_dir queue
~pinned_dependencies
| _ -> Bsb_exception.errorf ~loc "%s expect an array" deps))
)
|> ignore
in
let is_pinned =
match top with
| Expect_name n when Set_string.mem pinned_dependencies n -> true
| _ -> false
in
let pinned_dependencies =
match is_pinned with
| true ->
let transitive_pinned_dependencies =
extract_pinned_dependencies map
in
Set_string.union transitive_pinned_dependencies pinned_dependencies
| false -> pinned_dependencies
in
explore_deps Bsb_build_schemas.bs_dependencies pinned_dependencies;
explore_deps Bsb_build_schemas.bs_dependencies;
(match top with
| Expect_none ->
explore_deps Bsb_build_schemas.bs_dev_dependencies pinned_dependencies
| Expect_name _ when is_pinned ->
explore_deps Bsb_build_schemas.bs_dev_dependencies pinned_dependencies
| Expect_none -> explore_deps Bsb_build_schemas.bs_dev_dependencies
| Expect_name _ -> ());
Queue.add {top; proj_dir = dir; is_pinned} queue;
Queue.add {top; proj_dir = dir} queue;
Hash_string.add visited cur_package_name dir
| _ -> ()

let walk_all_deps dir ~pinned_dependencies : package_context Queue.t =
let walk_all_deps dir : package_context Queue.t =
let visited = Hash_string.create 0 in
let cb = Queue.create () in
walk_all_deps_aux visited [] ~top:Expect_none dir cb ~pinned_dependencies;
walk_all_deps_aux visited [] ~top:Expect_none dir cb;
cb
9 changes: 3 additions & 6 deletions compiler/bsb/bsb_build_util.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
Expand Down Expand Up @@ -82,9 +82,6 @@ type result = {path: string; checked: bool}
*)
val resolve_bsb_magic_file : cwd:string -> desc:string -> string -> result

type package_context = {proj_dir: string; top: top; is_pinned: bool}

val extract_pinned_dependencies : Ext_json_types.t Map_string.t -> Set_string.t
type package_context = {proj_dir: string; top: top}

val walk_all_deps :
string -> pinned_dependencies:Set_string.t -> package_context Queue.t
val walk_all_deps : string -> package_context Queue.t
4 changes: 2 additions & 2 deletions compiler/bsb/bsb_clean.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ let clean_bs_garbage proj_dir =
Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)

let clean_bs_deps proj_dir =
let _, _, pinned_dependencies = Bsb_config_parse.deps_from_bsconfig () in
let queue = Bsb_build_util.walk_all_deps proj_dir ~pinned_dependencies in
let _, _ = Bsb_config_parse.deps_from_bsconfig () in
let queue = Bsb_build_util.walk_all_deps proj_dir in
Queue.iter
(fun (pkg_cxt : Bsb_build_util.package_context) ->
(* whether top or not always do the cleaning *)
Expand Down
14 changes: 4 additions & 10 deletions compiler/bsb/bsb_config_parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,11 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
in
let bs_dev_dependencies =
match package_kind with
| Toplevel | Pinned_dependency _ ->
| Toplevel ->
extract_dependencies map per_proj_dir
Bsb_build_schemas.bs_dev_dependencies
| Dependency _ -> []
in
let pinned_dependencies = Bsb_build_util.extract_pinned_dependencies map in
match map.?(Bsb_build_schemas.sources) with
| Some sources ->
let cut_generators =
Expand All @@ -263,12 +262,10 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
let jsx = Bsb_jsx.from_map map in
let jsx, bsc_flags =
match package_kind with
| Pinned_dependency x | Dependency x ->
({jsx with version = x.jsx.version}, bsc_flags)
| Dependency x -> ({jsx with version = x.jsx.version}, bsc_flags)
| Toplevel -> (jsx, bsc_flags)
in
{
pinned_dependencies;
gentype_config;
package_name;
namespace;
Expand All @@ -294,7 +291,7 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
package_specs =
(match package_kind with
| Toplevel -> Bsb_package_specs.from_map ~cwd:per_proj_dir map
| Pinned_dependency x | Dependency x -> x.package_specs);
| Dependency x -> x.package_specs);
file_groups = groups;
files_to_install = Queue.create ();
jsx;
Expand All @@ -311,8 +308,5 @@ let deps_from_bsconfig () =
match
Bsb_config_load.load_json ~per_proj_dir:cwd ~warn_legacy_config:false
with
| _, Obj {map} ->
( Bsb_package_specs.from_map ~cwd map,
Bsb_jsx.from_map map,
Bsb_build_util.extract_pinned_dependencies map )
| _, Obj {map} -> (Bsb_package_specs.from_map ~cwd map, Bsb_jsx.from_map map)
| _, _ -> assert false
2 changes: 1 addition & 1 deletion compiler/bsb/bsb_config_parse.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

val deps_from_bsconfig : unit -> Bsb_package_specs.t * Bsb_jsx.t * Set_string.t
val deps_from_bsconfig : unit -> Bsb_package_specs.t * Bsb_jsx.t

val interpret_json :
filename:string ->
Expand Down
1 change: 0 additions & 1 deletion compiler/bsb/bsb_config_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type t = {
pp_file: string option;
bs_dependencies: dependencies;
bs_dev_dependencies: dependencies;
pinned_dependencies: Set_string.t;
warning: Bsb_warning.t;
(*TODO: maybe we should always resolve rescript
so that we can calculate correct relative path in
Expand Down
4 changes: 1 addition & 3 deletions compiler/bsb/bsb_ninja_regen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir
Bsb_watcher_gen.generate_sourcedirs_meta
~name:(lib_bs_dir // Literals.sourcedirs_meta)
config.file_groups
| Pinned_dependency _ (* FIXME: seems need to be watched *) | Dependency _
->
());
| Dependency _ -> ());

Bsb_ninja_gen.output_ninja_and_namespace_map ~per_proj_dir ~package_kind
config;
Expand Down
12 changes: 2 additions & 10 deletions compiler/bsb/bsb_package_kind.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(* Copyright (C) 2020 - Hongbo Zhang, Authors of ReScript
(* Copyright (C) 2020 - Hongbo Zhang, Authors of ReScript
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -24,10 +24,7 @@

type dep_payload = {package_specs: Bsb_package_specs.t; jsx: Bsb_jsx.t}

type t =
| Toplevel
| Dependency of dep_payload
| Pinned_dependency of dep_payload
type t = Toplevel | Dependency of dep_payload
(* This package specs comes from the toplevel to
override the current settings
*)
Expand All @@ -40,8 +37,3 @@ let encode_no_nl (x : t) =
^ Bsb_package_specs.package_flag_of_package_specs x.package_specs
~dirname:"."
^ Bsb_jsx.encode_no_nl x.jsx
| Pinned_dependency x ->
"2"
^ Bsb_package_specs.package_flag_of_package_specs x.package_specs
~dirname:"."
^ Bsb_jsx.encode_no_nl x.jsx
18 changes: 8 additions & 10 deletions compiler/bsb/bsb_parse_sources.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
Expand Down Expand Up @@ -48,7 +48,7 @@ type cxt = {
ignored_dirs: Set_string.t;
}

(** [public] has a list of modules, we do a sanity check to see if all the listed
(** [public] has a list of modules, we do a sanity check to see if all the listed
modules are indeed valid module components
*)
let collect_pub_modules (xs : Ext_json_types.t array) (cache : Bsb_db.map) :
Expand Down Expand Up @@ -156,9 +156,9 @@ let extract_predicate (m : json_map) : string -> bool =
| None, _ -> fun name -> not (Ext_list.mem_string excludes name)

(** [parsing_source_dir_map cxt input]
Major work done in this function,
assume [not toplevel && not (Bsb_dir_index.is_lib_dir dir_index)]
is already checked, so we don't need check it again
Major work done in this function,
assume [not toplevel && not (Bsb_dir_index.is_lib_dir dir_index)]
is already checked, so we don't need check it again
*)

(** This is the only place where we do some removal during scanning,
Expand All @@ -174,9 +174,7 @@ let rec parsing_source_dir_map ({cwd = dir} as cxt)
let cur_globbed_dirs = ref false in
let has_generators =
match cxt with
| {cut_generators = false; package_kind = Toplevel | Pinned_dependency _}
->
true
| {cut_generators = false; package_kind = Toplevel} -> true
| {cut_generators = false; package_kind = Dependency _}
| {cut_generators = true; _} ->
false
Expand Down Expand Up @@ -274,7 +272,7 @@ and parsing_single_source ({package_kind; is_dev; cwd} as cxt)
| Str {str = dir} -> (
match (package_kind, is_dev) with
| Dependency _, true -> Bsb_file_groups.empty
| Dependency _, false | (Toplevel | Pinned_dependency _), _ ->
| Dependency _, false | Toplevel, _ ->
parsing_source_dir_map
{
cxt with
Expand All @@ -293,7 +291,7 @@ and parsing_single_source ({package_kind; is_dev; cwd} as cxt)
in
match (package_kind, current_dir_index) with
| Dependency _, true -> Bsb_file_groups.empty
| Dependency _, false | (Toplevel | Pinned_dependency _), _ ->
| Dependency _, false | Toplevel, _ ->
let dir =
match map.?(Bsb_build_schemas.dir) with
| Some (Str {str}) ->
Expand Down
2 changes: 1 addition & 1 deletion compiler/bsb/bsb_warning.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ let from_map (m : Ext_json_types.t Map_string.t) =

let to_bsb_string ~(package_kind : Bsb_package_kind.t) warning =
match package_kind with
| Toplevel | Pinned_dependency _ -> (
| Toplevel -> (
match warning with
| None -> Ext_string.empty
| Some warning -> (
Expand Down
21 changes: 8 additions & 13 deletions compiler/bsb/bsb_world.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,23 @@ let ( // ) = Ext_path.combine
let vendor_ninja = Bsb_global_paths.vendor_ninja

let make_world_deps cwd (config : Bsb_config_types.t option)
(ninja_args : string array) warn_as_error =
let package_specs, jsx, pinned_dependencies =
(ninja_args : string array) =
let package_specs, jsx =
match config with
| None ->
(* When this running bsb does not read rescript.json,
we will read such json file to know which [package-specs]
it wants
*)
Bsb_config_parse.deps_from_bsconfig ()
| Some config ->
(config.package_specs, config.jsx, config.pinned_dependencies)
| Some config -> (config.package_specs, config.jsx)
in
let args =
if Ext_array.is_empty ninja_args then [|vendor_ninja|]
else Array.append [|vendor_ninja|] ninja_args
in
let lib_artifacts_dir = Bsb_config.lib_bs in
let queue = Bsb_build_util.walk_all_deps cwd ~pinned_dependencies in
let queue = Bsb_build_util.walk_all_deps cwd in
(* let oc = open_out_bin ".deps.log" in
queue |> Queue.iter (fun ({top; proj_dir} : Bsb_build_util.package_context) ->
match top with
Expand All @@ -56,22 +55,18 @@ let make_world_deps cwd (config : Bsb_config_types.t option)
);
close_out oc ; *)
queue
|> Queue.iter
(fun ({top; proj_dir; is_pinned} : Bsb_build_util.package_context) ->
|> Queue.iter (fun ({top; proj_dir} : Bsb_build_util.package_context) ->
match top with
| Expect_none -> ()
| Expect_name s ->
if is_pinned then print_endline ("Dependency pinned on " ^ s)
else print_endline ("Dependency on " ^ s);
print_endline ("Dependency on " ^ s);
let lib_bs_dir = proj_dir // lib_artifacts_dir in
Bsb_build_util.mkp lib_bs_dir;
let _config : _ option =
Bsb_ninja_regen.regenerate_ninja
~package_kind:
(if is_pinned then Pinned_dependency {package_specs; jsx}
else Dependency {package_specs; jsx})
~package_kind:(Dependency {package_specs; jsx})
~per_proj_dir:proj_dir ~forced:false ~warn_legacy_config:false
~warn_as_error:(if is_pinned then warn_as_error else None)
~warn_as_error:None
in
let command =
{Bsb_unix.cmd = vendor_ninja; cwd = lib_bs_dir; args}
Expand Down
2 changes: 1 addition & 1 deletion compiler/bsb/bsb_world.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

val make_world_deps :
string -> Bsb_config_types.t option -> string array -> string option -> unit
string -> Bsb_config_types.t option -> string array -> unit
5 changes: 2 additions & 3 deletions compiler/bsb_exe/rescript_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ let build_subcommand ~start argv argv_len =
~warn_legacy_config:true ~warn_as_error
in
if not !no_deps_mode then
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args
warn_as_error;
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args;
if !do_install then install_target ();
ninja_command_exit ninja_args

Expand Down Expand Up @@ -228,7 +227,7 @@ let () =
~per_proj_dir:Bsb_global_paths.cwd ~forced:false
~warn_legacy_config:true ~warn_as_error:None
in
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||] None;
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||];
ninja_command_exit [||])
else
match argv.(1) with
Expand Down
4 changes: 0 additions & 4 deletions docs/docson/build-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,6 @@
"$ref": "#/definitions/dependencies",
"description": "ReScript dev dependencies of the library, like in package.json. Currently searches in `node_modules`"
},
"pinned-dependencies": {
"$ref": "#/definitions/dependencies",
"description": "Those dependencies are pinned (since version 8.4)"
},
"generators": {
"type": "array",
"items": {
Expand Down
Loading