Skip to content
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
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/*.cm[ioxatj]
/*.cmx[as]
/*.cmti
/*.annot
/*.annot
jscomp/build_tests
44 changes: 36 additions & 8 deletions jscomp/bin/bsb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9848,7 +9848,8 @@ let (|?) m (key, cb) =
m |> Ext_json.test key cb


let warning_unused_file : _ format = "@{<warning>IGNORED@}: file %s under %s is ignored because it can't be turned into a valid module name. The build system transforms a file name into a module name by upper-casing the first letter@."
let warning_unused_file : _ format =
"@{<warning>IGNORED@}: file %s under %s is ignored because it can't be turned into a valid module name. The build system transforms a file name into a module name by upper-casing the first letter@."

type cxt = {
no_dev : bool ;
Expand All @@ -9858,6 +9859,31 @@ type cxt = {
cut_generators : bool
}

let collect_pub_modules
(xs : Ext_json_types.t array)
(cache : Bsb_build_cache.t) : String_set.t =
let set = ref String_set.empty in
for i = 0 to Array.length xs - 1 do
let v = Array.unsafe_get xs i in
match v with
| Str { str ; loc }
->
if String_map.mem str cache then
set := String_set.add str !set
else
begin
Format.fprintf Format.err_formatter
"@{<warning>IGNORED@} %S in public is ignored since it is not\
an existing module@." str
end
| _ ->
Bsb_exception.failf
~loc:(Ext_json.loc_of v)
"public excpect a list of strings"
done ;
!set
(* String_set.of_list (Bsb_build_util.get_list_string xs) *)

let handle_list_files acc
({ cwd = dir ; root} : cxt)
loc_start loc_end
Expand Down Expand Up @@ -10047,8 +10073,8 @@ and parsing_source_dir_map
| Some (Arr {loc_start;loc_end; content = [||] }) ->
(* [ ] populatd by scanning the dir (just once) *)
let tasks, files =
handle_list_files !cur_sources cxt
loc_start loc_end (is_input_or_output generators) in
handle_list_files !cur_sources cxt
loc_start loc_end (is_input_or_output generators) in
cur_update_queue := tasks ;
cur_sources := files

Expand Down Expand Up @@ -10091,6 +10117,7 @@ and parsing_source_dir_map
| Some x -> Bsb_exception.failwith_config x "files field expect array or object "

end;
let cur_sources = !cur_sources in
x
|? (Bsb_build_schemas.resources ,
`Arr (fun s ->
Expand All @@ -10102,12 +10129,12 @@ and parsing_source_dir_map
Bsb_exception.failf ~loc "invalid str for %s " s
))
|? (Bsb_build_schemas.public, `Arr (fun s ->
public := Export_set (String_set.of_list (Bsb_build_util.get_list_string s ) )
public := Export_set (collect_pub_modules s cur_sources)
) )
|> ignore ;
let cur_file =
{dir = dir;
sources = !cur_sources;
sources = cur_sources;
resources = !resources;
public = !public;
dir_index = cxt.dir_index ;
Expand Down Expand Up @@ -12150,7 +12177,7 @@ let emit_impl_build
| None ->
filename_sans_extension
| Some pkg ->
Ext_package_name.make ~pkg filename_sans_extension
Ext_package_name.make ~pkg filename_sans_extension
in
let file_cmi = output_filename_sans_extension ^ Literals.suffix_cmi in
let output_cmj = output_filename_sans_extension ^ Literals.suffix_cmj in
Expand Down Expand Up @@ -12222,7 +12249,7 @@ let emit_intf_build
| None ->
filename_sans_extension
| Some pkg ->
Ext_package_name.make ~pkg filename_sans_extension
Ext_package_name.make ~pkg filename_sans_extension
in
let output_cmi = output_filename_sans_extension ^ Literals.suffix_cmi in
let common_shadows =
Expand Down Expand Up @@ -12318,7 +12345,8 @@ let handle_file_group
match group.public with
| Export_all -> true
| Export_none -> false
| Export_set set -> String_set.mem module_name set in
| Export_set set ->
String_set.mem module_name set in
if installable then
String_hash_set.add files_to_install (Bsb_build_cache.filename_sans_suffix_of_module_info module_info);
(handle_module_info group.dir_index
Expand Down
7 changes: 4 additions & 3 deletions jscomp/bsb/bsb_ninja_file_groups.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ let emit_impl_build
| None ->
filename_sans_extension
| Some pkg ->
Ext_package_name.make ~pkg filename_sans_extension
Ext_package_name.make ~pkg filename_sans_extension
in
let file_cmi = output_filename_sans_extension ^ Literals.suffix_cmi in
let output_cmj = output_filename_sans_extension ^ Literals.suffix_cmj in
Expand Down Expand Up @@ -178,7 +178,7 @@ let emit_intf_build
| None ->
filename_sans_extension
| Some pkg ->
Ext_package_name.make ~pkg filename_sans_extension
Ext_package_name.make ~pkg filename_sans_extension
in
let output_cmi = output_filename_sans_extension ^ Literals.suffix_cmi in
let common_shadows =
Expand Down Expand Up @@ -274,7 +274,8 @@ let handle_file_group
match group.public with
| Export_all -> true
| Export_none -> false
| Export_set set -> String_set.mem module_name set in
| Export_set set ->
String_set.mem module_name set in
if installable then
String_hash_set.add files_to_install (Bsb_build_cache.filename_sans_suffix_of_module_info module_info);
(handle_module_info group.dir_index
Expand Down
37 changes: 32 additions & 5 deletions jscomp/bsb/bsb_parse_sources.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ let (|?) m (key, cb) =
m |> Ext_json.test key cb


let warning_unused_file : _ format = "@{<warning>IGNORED@}: file %s under %s is ignored because it can't be turned into a valid module name. The build system transforms a file name into a module name by upper-casing the first letter@."
let warning_unused_file : _ format =
"@{<warning>IGNORED@}: file %s under %s is ignored because it can't be turned into a valid module name. The build system transforms a file name into a module name by upper-casing the first letter@."

type cxt = {
no_dev : bool ;
Expand All @@ -86,6 +87,31 @@ type cxt = {
cut_generators : bool
}

let collect_pub_modules
(xs : Ext_json_types.t array)
(cache : Bsb_build_cache.t) : String_set.t =
let set = ref String_set.empty in
for i = 0 to Array.length xs - 1 do
let v = Array.unsafe_get xs i in
match v with
| Str { str ; loc }
->
if String_map.mem str cache then
set := String_set.add str !set
else
begin
Format.fprintf Format.err_formatter
"@{<warning>IGNORED@} %S in public is ignored since it is not\
an existing module@." str
end
| _ ->
Bsb_exception.failf
~loc:(Ext_json.loc_of v)
"public excpect a list of strings"
done ;
!set
(* String_set.of_list (Bsb_build_util.get_list_string xs) *)

let handle_list_files acc
({ cwd = dir ; root} : cxt)
loc_start loc_end
Expand Down Expand Up @@ -275,8 +301,8 @@ and parsing_source_dir_map
| Some (Arr {loc_start;loc_end; content = [||] }) ->
(* [ ] populatd by scanning the dir (just once) *)
let tasks, files =
handle_list_files !cur_sources cxt
loc_start loc_end (is_input_or_output generators) in
handle_list_files !cur_sources cxt
loc_start loc_end (is_input_or_output generators) in
cur_update_queue := tasks ;
cur_sources := files

Expand Down Expand Up @@ -319,6 +345,7 @@ and parsing_source_dir_map
| Some x -> Bsb_exception.failwith_config x "files field expect array or object "

end;
let cur_sources = !cur_sources in
x
|? (Bsb_build_schemas.resources ,
`Arr (fun s ->
Expand All @@ -330,12 +357,12 @@ and parsing_source_dir_map
Bsb_exception.failf ~loc "invalid str for %s " s
))
|? (Bsb_build_schemas.public, `Arr (fun s ->
public := Export_set (String_set.of_list (Bsb_build_util.get_list_string s ) )
public := Export_set (collect_pub_modules s cur_sources)
) )
|> ignore ;
let cur_file =
{dir = dir;
sources = !cur_sources;
sources = cur_sources;
resources = !resources;
public = !public;
dir_index = cxt.dir_index ;
Expand Down
9 changes: 8 additions & 1 deletion jscomp/build_tests/priv/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

var child_process = require('child_process')

child_process.execSync(`bsb -clean-world && bsb -make-world`, {cwd:__dirname, stdio:[0,1,2]})
var output = child_process.spawnSync(
`bsb -clean-world && bsb -make-world`,
{cwd:__dirname, shell: true, encoding : 'utf8'})


var assert = require('assert')
assert.ok(output.stderr.match(/IGNORED/))


2 changes: 1 addition & 1 deletion jscomp/build_tests/priv/node_modules/liba/bsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions jscomp/build_tests/priv/src/demo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions jscomp/build_tests/priv/src/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.