Skip to content

Remove internal/unused -bs-v flag #7627

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 2 commits into from
Jul 11, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

# 12.0.0-beta.2 (Unreleased)

#### :house: Internal

- Remove internal/unused `-bs-v` flag. https://github.com/rescript-lang/rescript/pull/7627

# 12.0.0-beta.1

#### :rocket: New Feature
Expand Down
3 changes: 1 addition & 2 deletions cli/rescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ try {
if (
subcommand === "build" ||
subcommand === "watch" ||
subcommand === "clean" ||
subcommand === "compiler-args"
subcommand === "clean"
) {
child_process.execFileSync(
rescript_exe,
Expand Down
4 changes: 2 additions & 2 deletions compiler/bsb/bsb_ninja_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let output_static_resources (static_resources : string list) copy_rule oc =

(*
FIXME: check if the trick still works
phony build.ninja : | resources
phony build.ninja : | resources
*)
let mark_rescript oc = output_string oc "rescript = 1\n"

Expand Down Expand Up @@ -197,7 +197,7 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
~dpkg_incls (* dev dependencies *)
~lib_incls (* its own libs *)
~dev_incls (* its own devs *)
~bs_dependencies ~bs_dev_dependencies generators
generators
in

let oc = open_out_bin (cwd_lib_bs // Literals.build_ninja) in
Expand Down
11 changes: 2 additions & 9 deletions compiler/bsb/bsb_ninja_rule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
~(jsx : Bsb_jsx.t) ~(digest : string) ~(package_specs : Bsb_package_specs.t)
~(namespace : string option) ~package_name ~warnings
~(ppx_files : Bsb_config_types.ppx list) ~bsc_flags ~(dpkg_incls : string)
~(lib_incls : string) ~(dev_incls : string) ~bs_dependencies
~bs_dev_dependencies (custom_rules : command Map_string.t) : builtin =
~(lib_incls : string) ~(dev_incls : string)
(custom_rules : command Map_string.t) : builtin =
let bs_dep = Ext_filename.maybe_quote Bsb_global_paths.vendor_bsdep in
let bsc = Ext_filename.maybe_quote Bsb_global_paths.vendor_bsc in
(* FIXME: We don't need set [-o ${out}] when building ast
Expand Down Expand Up @@ -127,11 +127,6 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
Ext_buffer.add_string buf
(Bsb_package_specs.package_flag_of_package_specs package_specs
~dirname:"$in_d"));
(match (bs_dependencies, bs_dev_dependencies) with
| [], [] -> ()
| _, _ ->
Ext_buffer.add_string buf " -bs-v";
Ext_buffer.add_ninja_prefix_var buf Bsb_ninja_global_vars.g_finger);
Ext_buffer.add_string buf " $i";
(match postbuild with
| None -> ()
Expand All @@ -145,8 +140,6 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
Ext_buffer.clear buf;
Ext_buffer.add_string buf bsc;
Ext_buffer.add_char_string buf ' ' warnings;
Ext_buffer.add_string buf " -bs-v ";
Ext_buffer.add_string buf Bs_version.version;
(match ppx_files with
| [] -> ()
| _ ->
Expand Down
4 changes: 1 addition & 3 deletions compiler/bsb/bsb_ninja_rule.mli
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type builtin = {
(***********************************************************)

(** rules are generally composed of built-in rules and customized rules, there are two design choices:
1. respect custom rules with the same name, then we need adjust our built-in
1. respect custom rules with the same name, then we need adjust our built-in
rules dynamically in case the conflict.
2. respect our built-in rules, then we only need re-load custom rules for each rescript.json
*)
Expand All @@ -79,7 +79,5 @@ val make_custom_rules :
dpkg_incls:string ->
lib_incls:string ->
dev_incls:string ->
bs_dependencies:Bsb_config_types.dependencies ->
bs_dev_dependencies:Bsb_config_types.dependencies ->
command Map_string.t ->
builtin
1 change: 0 additions & 1 deletion compiler/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
Js_config.debug := true;
Pp.replace_directive_bool "DEBUG" true),
"Debug mode" );
("-bs-v", string_call ignore, "*internal* version check to force a rebuild");
( "-bs-package-name",
string_call Js_packages_state.set_package_name,
"*internal* Set package name, useful when you want to produce npm \
Expand Down
15 changes: 0 additions & 15 deletions rewatch/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ pub struct CompilerArgs {

pub fn get_compiler_args(
path: &Path,
rescript_version: Option<String>,
bsc_path: Option<PathBuf>,
build_dev_deps: bool,
) -> Result<String> {
let filename = &helpers::get_abs_path(path);
Expand All @@ -69,15 +67,6 @@ pub fn get_compiler_args(
let root_rescript_config =
packages::read_config(&workspace_root.to_owned().unwrap_or(package_root.to_owned()))?;
let rescript_config = packages::read_config(&package_root)?;
let rescript_version = if let Some(rescript_version) = rescript_version {
rescript_version
} else {
let bsc_path = match bsc_path {
Some(bsc_path) => helpers::get_abs_path(&bsc_path),
None => helpers::get_bsc(&package_root, &workspace_root),
};
helpers::get_rescript_version(&bsc_path)
};

// make PathBuf from package root and get the relative path for filename
let relative_filename = filename.strip_prefix(PathBuf::from(&package_root)).unwrap();
Expand All @@ -89,7 +78,6 @@ pub fn get_compiler_args(
&rescript_config,
&root_rescript_config,
&relative_filename,
&rescript_version,
&workspace_root,
workspace_root.as_ref().unwrap_or(&package_root),
&contents,
Expand All @@ -106,7 +94,6 @@ pub fn get_compiler_args(
&rescript_config,
&root_rescript_config,
&ast_path,
&rescript_version,
&relative_filename,
is_interface,
has_interface,
Expand Down Expand Up @@ -141,7 +128,6 @@ pub fn initialize_build(
None => helpers::get_bsc(&project_root, &workspace_root),
};
let root_config_name = packages::read_package_name(&project_root)?;
let rescript_version = helpers::get_rescript_version(&bsc_path);

if !snapshot_output && show_progress {
print!("{} {}Building package tree...", style("[1/7]").bold().dim(), TREE);
Expand Down Expand Up @@ -190,7 +176,6 @@ pub fn initialize_build(
root_config_name,
packages,
workspace_root,
rescript_version,
bsc_path,
);
packages::parse_packages(&mut build_state);
Expand Down
3 changes: 0 additions & 3 deletions rewatch/src/build/build_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ pub struct BuildState {
pub project_root: PathBuf,
pub root_config_name: String,
pub deleted_modules: AHashSet<String>,
pub rescript_version: String,
pub bsc_path: PathBuf,
pub workspace_root: Option<PathBuf>,
pub deps_initialized: bool,
Expand All @@ -113,7 +112,6 @@ impl BuildState {
root_config_name: String,
packages: AHashMap<String, Package>,
workspace_root: Option<PathBuf>,
rescript_version: String,
bsc_path: PathBuf,
) -> Self {
Self {
Expand All @@ -124,7 +122,6 @@ impl BuildState {
root_config_name,
deleted_modules: AHashSet::new(),
workspace_root,
rescript_version,
bsc_path,
deps_initialized: false,
}
Expand Down
2 changes: 0 additions & 2 deletions rewatch/src/build/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ pub fn clean(
None => helpers::get_bsc(&project_root, &workspace_root),
};

let rescript_version = helpers::get_rescript_version(&bsc_path);

let timing_clean_compiler_assets = Instant::now();
if !snapshot_output && show_progress {
Expand Down Expand Up @@ -412,7 +411,6 @@ pub fn clean(
root_config_name,
packages,
workspace_root,
rescript_version,
bsc_path,
);
packages::parse_packages(&mut build_state);
Expand Down
6 changes: 0 additions & 6 deletions rewatch/src/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ pub fn compile(
root_package,
&helpers::get_ast_path(&path),
module,
&build_state.rescript_version,
true,
&build_state.bsc_path,
&build_state.packages,
Expand All @@ -182,7 +181,6 @@ pub fn compile(
root_package,
&helpers::get_ast_path(&source_file.implementation.path),
module,
&build_state.rescript_version,
false,
&build_state.bsc_path,
&build_state.packages,
Expand Down Expand Up @@ -354,7 +352,6 @@ pub fn compiler_args(
config: &config::Config,
root_config: &config::Config,
ast_path: &Path,
version: &str,
file_path: &Path,
is_interface: bool,
has_interface: bool,
Expand Down Expand Up @@ -475,7 +472,6 @@ pub fn compiler_args(
// "-I".to_string(),
// abs_node_modules_path.to_string() + "/rescript/ocaml",
// ],
vec!["-bs-v".to_string(), format!("{}", version)],
vec![ast_path.to_string_lossy().to_string()],
]
.concat()
Expand Down Expand Up @@ -568,7 +564,6 @@ fn compile_file(
root_package: &packages::Package,
ast_path: &Path,
module: &Module,
version: &str,
is_interface: bool,
bsc_path: &Path,
packages: &AHashMap<String, packages::Package>,
Expand All @@ -592,7 +587,6 @@ fn compile_file(
&package.config,
&root_package.config,
ast_path,
version,
implementation_file_path,
is_interface,
has_interface,
Expand Down
6 changes: 0 additions & 6 deletions rewatch/src/build/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub fn generate_asts(
package.to_owned(),
root_package.to_owned(),
&source_file.implementation.path.to_owned(),
&build_state.rescript_version,
&build_state.bsc_path,
&build_state.workspace_root,
);
Expand All @@ -62,7 +61,6 @@ pub fn generate_asts(
package.to_owned(),
root_package.to_owned(),
&interface_file_path.to_owned(),
&build_state.rescript_version,
&build_state.bsc_path,
&build_state.workspace_root,
)
Expand Down Expand Up @@ -249,7 +247,6 @@ pub fn parser_args(
config: &config::Config,
root_config: &config::Config,
filename: &Path,
version: &str,
workspace_root: &Option<PathBuf>,
root_path: &Path,
contents: &str,
Expand All @@ -276,7 +273,6 @@ pub fn parser_args(
(
ast_path.to_owned(),
[
vec!["-bs-v".to_string(), format!("{}", version)],
ppx_flags,
jsx_args,
jsx_module_args,
Expand All @@ -299,7 +295,6 @@ fn generate_ast(
package: packages::Package,
root_package: packages::Package,
filename: &Path,
version: &str,
bsc_path: &PathBuf,
workspace_root: &Option<PathBuf>,
) -> Result<(PathBuf, Option<helpers::StdErr>), String> {
Expand All @@ -311,7 +306,6 @@ fn generate_ast(
&package.config,
&root_package.config,
filename,
version,
workspace_root,
&root_package.path,
&contents,
Expand Down
7 changes: 0 additions & 7 deletions rewatch/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,6 @@ pub enum Command {

#[command(flatten)]
dev: DevArg,

/// To be used in conjunction with compiler_args
#[arg(long)]
rescript_version: Option<String>,

#[command(flatten)]
bsc_path: BscPathArg,
},
/// Use the legacy build system.
///
Expand Down
13 changes: 0 additions & 13 deletions rewatch/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::fs::File;
use std::io::Read;
use std::io::{self, BufRead};
use std::path::{Component, Path, PathBuf};
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};

pub type StdErr = String;
Expand Down Expand Up @@ -408,18 +407,6 @@ pub fn get_nearest_config(path_buf: &Path) -> Option<PathBuf> {
}
}

pub fn get_rescript_version(bsc_path: &Path) -> String {
let version_cmd = Command::new(bsc_path)
.args(["-v"])
.output()
.expect("failed to find version");

std::str::from_utf8(&version_cmd.stdout)
.expect("Could not read version from rescript")
.replace('\n', "")
.replace("ReScript ", "")
}

pub fn read_file(path: &Path) -> Result<String, std::io::Error> {
let mut file = File::open(path).expect("file not found");
let mut contents = String::new();
Expand Down
4 changes: 0 additions & 4 deletions rewatch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ fn main() -> Result<()> {
cli::Command::CompilerArgs {
path,
dev,
rescript_version,
bsc_path,
} => {
println!(
"{}",
build::get_compiler_args(
Path::new(&path),
rescript_version,
bsc_path.as_ref().map(PathBuf::from),
*dev
)?
);
Expand Down