Skip to content

Adjust to bs-* deprecations #7692

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
21 changes: 13 additions & 8 deletions analysis/src/FindFiles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,21 @@ let findProjectFiles ~public ~namespace ~path ~sourceDirectories ~libBs =

let findDependencyFiles base config =
let deps =
config |> Json.get "bs-dependencies" |> bind Json.array
|> Option.value ~default:[]
|> List.filter_map Json.string
match
( config |> Json.get "dependencies" |> bind Json.array,
config |> Json.get "bs-dependencies" |> bind Json.array )
with
| None, None -> []
| Some deps, None | _, Some deps -> deps |> List.filter_map Json.string
in
let devDeps =
config
|> Json.get "bs-dev-dependencies"
|> bind Json.array
|> Option.map (List.filter_map Json.string)
|> Option.value ~default:[]
match
( config |> Json.get "dev-dependencies" |> bind Json.array,
config |> Json.get "bs-dev-dependencies" |> bind Json.array )
with
| None, None -> []
| Some devDeps, None | _, Some devDeps ->
devDeps |> List.filter_map Json.string
in
let deps = deps @ devDeps in
Log.log ("Dependencies: " ^ String.concat " " deps);
Expand Down
19 changes: 12 additions & 7 deletions analysis/src/Packages.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,20 @@ let newBsPackage ~rootPath =
[path]
in
let bind f x = Option.bind x f in
let bsc_flags =
Json.get "bsc-flags" config
|> bind Json.array |> Option.value ~default:[]
let compiler_flags =
match
( Json.get "compiler-flags" config |> bind Json.array,
Json.get "bsc-flags" config |> bind Json.array )
with
| Some compiler_flags, None | _, Some compiler_flags ->
compiler_flags
| None, None -> []
in
let no_pervasives =
bsc_flags
compiler_flags
|> List.exists (fun s -> Json.string s = Some "-nopervasives")
in
let opens_from_bsc_flags =
let opens_from_compiler_flags =
List.fold_left
(fun opens item ->
match item |> Json.string with
Expand All @@ -158,15 +163,15 @@ let newBsPackage ~rootPath =
let path = name |> String.split_on_char '.' in
path :: opens
| _ -> opens))
[] bsc_flags
[] compiler_flags
in
let opens_from_pervasives =
if no_pervasives then []
else [["Stdlib"]; ["Pervasives"; "JsxModules"]]
in
let opens =
opens_from_pervasives @ opens_from_namespace
|> List.rev_append opens_from_bsc_flags
|> List.rev_append opens_from_compiler_flags
|> List.map (fun path -> path @ ["place holder"])
in
{
Expand Down
6 changes: 4 additions & 2 deletions compiler/gentype/GenTypeConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ let read_config ~get_config_file ~namespace =
| _ -> default.suffix
in
let bs_dependencies =
match bsconf |> get_opt "bs-dependencies" with
| Some (Arr {content}) ->
match
(bsconf |> get_opt "dependencies", bsconf |> get_opt "bs-dependencies")
with
| Some (Arr {content}), None | None, Some (Arr {content}) ->
let strings = ref [] in
content
|> Array.iter (fun x ->
Expand Down
4 changes: 2 additions & 2 deletions compiler/ml/typetexp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,8 @@ let report_error env ppf = function
Format.fprintf ppf
"@[<v>@{<info>The module or file %a can't be found.@}@,\
@[<v 2>- If it's a third-party dependency:@,\
- Did you add it to the \"bs-dependencies\" or \
\"bs-dev-dependencies\" in rescript.json?@]@,\
- Did you add it to the \"dependencies\" or \"dev-dependencies\" in \
rescript.json?@]@,\
- Did you include the file's directory to the \"sources\" in \
rescript.json?@,"
Printtyp.longident lid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use 'compiler-flags' instead.

The module or file WebAPI can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json?
- Did you add it to the "dependencies" or "dev-dependencies" in rescript.json?
- Did you include the file's directory to the "sources" in rescript.json?


Expand Down
2 changes: 1 addition & 1 deletion rewatch/tests/snapshots/remove-file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Use 'compiler-flags' instead.

The module or file Dep02 can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json?
- Did you add it to the "dependencies" or "dev-dependencies" in rescript.json?
- Did you include the file's directory to the "sources" in rescript.json?


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use 'compiler-flags' instead.

The module or file Other_module can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json?
- Did you add it to the "dependencies" or "dev-dependencies" in rescript.json?
- Did you include the file's directory to the "sources" in rescript.json?


Expand Down
2 changes: 1 addition & 1 deletion rewatch/tests/snapshots/rename-file-internal-dep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Use 'compiler-flags' instead.

The module or file InternalDep can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json?
- Did you add it to the "dependencies" or "dev-dependencies" in rescript.json?
- Did you include the file's directory to the "sources" in rescript.json?


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

The module or file Foo can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json?
- Did you add it to the "dependencies" or "dev-dependencies" in rescript.json?
- Did you include the file's directory to the "sources" in rescript.json?