Skip to content

Commit b861acf

Browse files
committed
add suffix .js for OCaml generated js files, the external is left as is
1 parent 6fe622e commit b861acf

File tree

377 files changed

+1516
-1504
lines changed

Some content is hidden

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

377 files changed

+1516
-1504
lines changed

jscomp/all.depend

+1-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ core/lam_pass_alpha_conversion.cmx : core/lam_stats_util.cmx \
481481
core/lam_pass_collect.cmx : core/lam_util.cmx core/lam_stats_util.cmx \
482482
core/lam_stats.cmx core/lam.cmx ext/int_hash_set.cmx ext/ident_set.cmx \
483483
ext/ident_hashtbl.cmx core/lam_pass_collect.cmi
484-
core/js_program_loader.cmx : core/lam_module_ident.cmx \
484+
core/js_program_loader.cmx : ext/literals.cmx core/lam_module_ident.cmx \
485485
core/lam_compile_env.cmx core/js_stmt_make.cmx core/js_exp_make.cmx \
486486
common/js_config.cmx core/j.cmx ext/ident_set.cmx ext/ext_sys.cmx \
487487
ext/ext_string.cmx ext/ext_filename.cmx core/config_util.cmx \

jscomp/bin/all_ounit_tests.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10676,7 +10676,7 @@ let node_relative_path node_modules_shorten (file1 : t)
1067610676
| `File x -> `File (absolute_path x)
1067710677
| `Dir x -> `Dir(absolute_path x))
1067810678
^ node_sep ^
10679-
chop_extension_if_any (Filename.basename file2)
10679+
(* chop_extension_if_any *) (Filename.basename file2)
1068010680

1068110681

1068210682

@@ -10847,6 +10847,7 @@ let simple_convert_node_path_to_os_path =
1084710847
else if Sys.win32 || Sys.cygwin then
1084810848
Ext_string.replace_slash_backward
1084910849
else failwith ("Unknown OS : " ^ Sys.os_type)
10850+
1085010851
end
1085110852
module Ounit_path_tests
1085210853
= struct

jscomp/bin/bsb.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ let node_relative_path node_modules_shorten (file1 : t)
15701570
| `File x -> `File (absolute_path x)
15711571
| `Dir x -> `Dir(absolute_path x))
15721572
^ node_sep ^
1573-
chop_extension_if_any (Filename.basename file2)
1573+
(* chop_extension_if_any *) (Filename.basename file2)
15741574

15751575

15761576

@@ -1741,6 +1741,7 @@ let simple_convert_node_path_to_os_path =
17411741
else if Sys.win32 || Sys.cygwin then
17421742
Ext_string.replace_slash_backward
17431743
else failwith ("Unknown OS : " ^ Sys.os_type)
1744+
17441745
end
17451746
module Set_gen
17461747
= struct

jscomp/bin/bsb_helper.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ let node_relative_path node_modules_shorten (file1 : t)
15191519
| `File x -> `File (absolute_path x)
15201520
| `Dir x -> `Dir(absolute_path x))
15211521
^ node_sep ^
1522-
chop_extension_if_any (Filename.basename file2)
1522+
(* chop_extension_if_any *) (Filename.basename file2)
15231523

15241524

15251525

@@ -1690,6 +1690,7 @@ let simple_convert_node_path_to_os_path =
16901690
else if Sys.win32 || Sys.cygwin then
16911691
Ext_string.replace_slash_backward
16921692
else failwith ("Unknown OS : " ^ Sys.os_type)
1693+
16931694
end
16941695
module Map_gen
16951696
= struct

jscomp/bin/bsdep.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25462,7 +25462,7 @@ let node_relative_path node_modules_shorten (file1 : t)
2546225462
| `File x -> `File (absolute_path x)
2546325463
| `Dir x -> `Dir(absolute_path x))
2546425464
^ node_sep ^
25465-
chop_extension_if_any (Filename.basename file2)
25465+
(* chop_extension_if_any *) (Filename.basename file2)
2546625466

2546725467

2546825468

@@ -25633,6 +25633,7 @@ let simple_convert_node_path_to_os_path =
2563325633
else if Sys.win32 || Sys.cygwin then
2563425634
Ext_string.replace_slash_backward
2563525635
else failwith ("Unknown OS : " ^ Sys.os_type)
25636+
2563625637
end
2563725638
module Js_config : sig
2563825639
#1 "js_config.mli"

jscomp/bin/bsppx.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7477,7 +7477,7 @@ let node_relative_path node_modules_shorten (file1 : t)
74777477
| `File x -> `File (absolute_path x)
74787478
| `Dir x -> `Dir(absolute_path x))
74797479
^ node_sep ^
7480-
chop_extension_if_any (Filename.basename file2)
7480+
(* chop_extension_if_any *) (Filename.basename file2)
74817481

74827482

74837483

@@ -7648,6 +7648,7 @@ let simple_convert_node_path_to_os_path =
76487648
else if Sys.win32 || Sys.cygwin then
76497649
Ext_string.replace_slash_backward
76507650
else failwith ("Unknown OS : " ^ Sys.os_type)
7651+
76517652
end
76527653
module Js_config : sig
76537654
#1 "js_config.mli"

jscomp/bin/whole_compiler.ml

+12-8
Original file line numberDiff line numberDiff line change
@@ -21997,7 +21997,7 @@ let node_relative_path node_modules_shorten (file1 : t)
2199721997
| `File x -> `File (absolute_path x)
2199821998
| `Dir x -> `Dir(absolute_path x))
2199921999
^ node_sep ^
22000-
chop_extension_if_any (Filename.basename file2)
22000+
(* chop_extension_if_any *) (Filename.basename file2)
2200122001

2200222002

2200322003

@@ -22168,6 +22168,7 @@ let simple_convert_node_path_to_os_path =
2216822168
else if Sys.win32 || Sys.cygwin then
2216922169
Ext_string.replace_slash_backward
2217022170
else failwith ("Unknown OS : " ^ Sys.os_type)
22171+
2217122172
end
2217222173
module Js_config : sig
2217322174
#1 "js_config.mli"
@@ -83069,7 +83070,7 @@ let string_of_module_id ~output_prefix
8306983070
| Ml ->
8307083071
let id = x.id in
8307183072
let modulename = String.uncapitalize id.name in
83072-
let js_file = Printf.sprintf "%s.js" modulename in
83073+
let js_file = modulename ^ Literals.suffix_js in
8307383074
let rebase different_package package_dir dep =
8307483075
let current_unit_dir =
8307583076
`Dir (Js_config.get_output_dir ~pkg_dir:package_dir module_system output_prefix) in
@@ -83102,11 +83103,11 @@ let string_of_module_id ~output_prefix
8310283103
Found(current_package, path) ->
8310383104
if current_package = package_name then
8310483105
let package_dir = Lazy.force Ext_filename.package_dir in
83105-
rebase false package_dir (`File (package_dir // x // modulename))
83106+
rebase false package_dir (`File (package_dir // x // js_file))
8310683107
else
8310783108
begin match module_system with
8310883109
| AmdJS | NodeJS | Es6 ->
83109-
package_name // x // modulename
83110+
package_name // x // js_file
8311083111
| Goog -> assert false (* see above *)
8311183112
| Es6_global
8311283113
| AmdJS_global ->
@@ -83120,7 +83121,7 @@ let string_of_module_id ~output_prefix
8312083121
(Js_config.get_output_dir ~pkg_dir:(Lazy.force Ext_filename.package_dir)
8312183122
module_system output_prefix)
8312283123
((Filename.dirname
83123-
(Filename.dirname (Filename.dirname cmj_path))) // x // modulename)
83124+
(Filename.dirname (Filename.dirname cmj_path))) // x // js_file)
8312483125
end
8312583126
end
8312683127
| (AmdJS | NodeJS | Es6 | AmdJS_global | Es6_global), Found(package_name, x),
@@ -83129,12 +83130,12 @@ let string_of_module_id ~output_prefix
8312983130
if current_package = package_name then
8313083131
let package_dir = Lazy.force Ext_filename.package_dir in
8313183132
rebase false package_dir (`File (
83132-
package_dir // x // modulename))
83133+
package_dir // x // js_file))
8313383134
else
83134-
package_name // x // modulename
83135+
package_name // x // js_file
8313583136
| (AmdJS | NodeJS | Es6 | AmdJS_global | Es6_global),
8313683137
Found(package_name, x), Empty
83137-
-> package_name // x // modulename
83138+
-> package_name // x // js_file
8313883139
| (AmdJS | NodeJS | Es6 | AmdJS_global | Es6_global),
8313983140
(Empty | Package_script _) ,
8314083141
(Empty | Package_script _)
@@ -83143,6 +83144,9 @@ let string_of_module_id ~output_prefix
8314383144
| Some file ->
8314483145
let package_dir = Lazy.force Ext_filename.package_dir in
8314583146
rebase true package_dir (`File file)
83147+
(* Code path: when dependency is commonjs
83148+
while depedent is Empty or PackageScript
83149+
*)
8314683150
| None ->
8314783151
Bs_exception.error (Js_not_found js_file)
8314883152
end

jscomp/core/js_program_loader.ml

+10-7
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let string_of_module_id ~output_prefix
8484
| Ml ->
8585
let id = x.id in
8686
let modulename = String.uncapitalize id.name in
87-
let js_file = Printf.sprintf "%s.js" modulename in
87+
let js_file = modulename ^ Literals.suffix_js in
8888
let rebase different_package package_dir dep =
8989
let current_unit_dir =
9090
`Dir (Js_config.get_output_dir ~pkg_dir:package_dir module_system output_prefix) in
@@ -117,11 +117,11 @@ let string_of_module_id ~output_prefix
117117
Found(current_package, path) ->
118118
if current_package = package_name then
119119
let package_dir = Lazy.force Ext_filename.package_dir in
120-
rebase false package_dir (`File (package_dir // x // modulename))
120+
rebase false package_dir (`File (package_dir // x // js_file))
121121
else
122122
begin match module_system with
123123
| AmdJS | NodeJS | Es6 ->
124-
package_name // x // modulename
124+
package_name // x // js_file
125125
| Goog -> assert false (* see above *)
126126
| Es6_global
127127
| AmdJS_global ->
@@ -135,7 +135,7 @@ let string_of_module_id ~output_prefix
135135
(Js_config.get_output_dir ~pkg_dir:(Lazy.force Ext_filename.package_dir)
136136
module_system output_prefix)
137137
((Filename.dirname
138-
(Filename.dirname (Filename.dirname cmj_path))) // x // modulename)
138+
(Filename.dirname (Filename.dirname cmj_path))) // x // js_file)
139139
end
140140
end
141141
| (AmdJS | NodeJS | Es6 | AmdJS_global | Es6_global), Found(package_name, x),
@@ -144,12 +144,12 @@ let string_of_module_id ~output_prefix
144144
if current_package = package_name then
145145
let package_dir = Lazy.force Ext_filename.package_dir in
146146
rebase false package_dir (`File (
147-
package_dir // x // modulename))
147+
package_dir // x // js_file))
148148
else
149-
package_name // x // modulename
149+
package_name // x // js_file
150150
| (AmdJS | NodeJS | Es6 | AmdJS_global | Es6_global),
151151
Found(package_name, x), Empty
152-
-> package_name // x // modulename
152+
-> package_name // x // js_file
153153
| (AmdJS | NodeJS | Es6 | AmdJS_global | Es6_global),
154154
(Empty | Package_script _) ,
155155
(Empty | Package_script _)
@@ -158,6 +158,9 @@ let string_of_module_id ~output_prefix
158158
| Some file ->
159159
let package_dir = Lazy.force Ext_filename.package_dir in
160160
rebase true package_dir (`File file)
161+
(* Code path: when dependency is commonjs
162+
while depedent is Empty or PackageScript
163+
*)
161164
| None ->
162165
Bs_exception.error (Js_not_found js_file)
163166
end

jscomp/ext/ext_filename.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ let node_relative_path node_modules_shorten (file1 : t)
189189
| `File x -> `File (absolute_path x)
190190
| `Dir x -> `Dir(absolute_path x))
191191
^ node_sep ^
192-
chop_extension_if_any (Filename.basename file2)
192+
(* chop_extension_if_any *) (Filename.basename file2)
193193

194194

195195

@@ -359,4 +359,4 @@ let simple_convert_node_path_to_os_path =
359359
if Sys.unix then fun x -> x
360360
else if Sys.win32 || Sys.cygwin then
361361
Ext_string.replace_slash_backward
362-
else failwith ("Unknown OS : " ^ Sys.os_type)
362+
else failwith ("Unknown OS : " ^ Sys.os_type)

jscomp/test/a_filename_test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
var Mt = require("./mt");
4-
var $$Array = require("../../lib/js/array");
5-
var Block = require("../../lib/js/block");
6-
var Ext_filename = require("./ext_filename");
3+
var Mt = require("./mt.js");
4+
var $$Array = require("../../lib/js/array.js");
5+
var Block = require("../../lib/js/block.js");
6+
var Ext_filename = require("./ext_filename.js");
77

88
var suites = [/* [] */0];
99

@@ -46,7 +46,7 @@ eq("File \"a_filename_test.ml\", line 22, characters 5-12", test(/* `File */[
4646
], /* `File */[
4747
781515420,
4848
"./a/u/g.c"
49-
]), "./u/g");
49+
]), "./u/g.c");
5050

5151
eq("File \"a_filename_test.ml\", line 27, characters 5-12", test(/* `File */[
5252
781515420,
@@ -86,15 +86,15 @@ eq("File \"a_filename_test.ml\", line 50, characters 5-12", test(/* `File */[
8686
], /* `File */[
8787
781515420,
8888
"./a/b.js"
89-
]), "./b");
89+
]), "./b.js");
9090

9191
eq("File \"a_filename_test.ml\", line 55, characters 5-12", test(/* `Dir */[
9292
3405101,
9393
"./a/"
9494
], /* `File */[
9595
781515420,
9696
"./a/b.js"
97-
]), "./b");
97+
]), "./b.js");
9898

9999
eq("File \"a_filename_test.ml\", line 60, characters 5-12", Ext_filename.get_extension("a.txt"), ".txt");
100100

jscomp/test/a_filename_test.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let () =
2222
eq __LOC__
2323
(test
2424
(`File "./a/b.c")
25-
(`File "./a/u/g.c")) "./u/g";
25+
(`File "./a/u/g.c")) "./u/g.c";
2626

2727
eq __LOC__
2828
(test
@@ -51,12 +51,12 @@ let () =
5151
(test
5252
(`File "./a/c")
5353
(`File "./a/b.js"))
54-
"./b" ;
54+
"./b.js" ;
5555
eq __LOC__
5656
(test
5757
(`Dir "./a/")
5858
(`File "./a/b.js"))
59-
"./b";
59+
"./b.js";
6060
eq __LOC__
6161
(Ext_filename.get_extension "a.txt"
6262
)

jscomp/test/a_list_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
var Mt = require("./mt");
4-
var Block = require("../../lib/js/block");
5-
var Ext_list = require("./ext_list");
3+
var Mt = require("./mt.js");
4+
var Block = require("../../lib/js/block.js");
5+
var Ext_list = require("./ext_list.js");
66

77
var suites_000 = /* tuple */[
88
"drop",

jscomp/test/a_recursive_type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var Curry = require("../../lib/js/curry");
3+
var Curry = require("../../lib/js/curry.js");
44

55
function g(x) {
66
return Curry._1(x[0], x);

jscomp/test/a_scope_bug.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var Caml_int32 = require("../../lib/js/caml_int32");
3+
var Caml_int32 = require("../../lib/js/caml_int32.js");
44

55
function odd(_z) {
66
while(true) {

jscomp/test/a_string_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
var Mt = require("./mt");
4-
var List = require("../../lib/js/list");
5-
var Block = require("../../lib/js/block");
6-
var Ext_string = require("./ext_string");
3+
var Mt = require("./mt.js");
4+
var List = require("../../lib/js/list.js");
5+
var Block = require("../../lib/js/block.js");
6+
var Ext_string = require("./ext_string.js");
77

88
var suites_000 = /* tuple */[
99
"split",

jscomp/test/and_or_tailcall_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
var Mt = require("./mt");
4-
var Block = require("../../lib/js/block");
3+
var Mt = require("./mt.js");
4+
var Block = require("../../lib/js/block.js");
55

66
function f(b, _, _n) {
77
while(true) {

jscomp/test/app_root_finder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var Fs = require("fs");
44
var Path = require("path");
5-
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions");
5+
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
66

77
var package_json = "package.json";
88

jscomp/test/ari_regress_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
var Mt = require("./mt");
4-
var Block = require("../../lib/js/block");
5-
var Curry = require("../../lib/js/curry");
3+
var Mt = require("./mt.js");
4+
var Block = require("../../lib/js/block.js");
5+
var Curry = require("../../lib/js/curry.js");
66

77
var g = 7;
88

jscomp/test/arith_lexer.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3-
var Block = require("../../lib/js/block");
4-
var Curry = require("../../lib/js/curry");
5-
var Lexing = require("../../lib/js/lexing");
6-
var Pervasives = require("../../lib/js/pervasives");
7-
var Caml_format = require("../../lib/js/caml_format");
3+
var Block = require("../../lib/js/block.js");
4+
var Curry = require("../../lib/js/curry.js");
5+
var Lexing = require("../../lib/js/lexing.js");
6+
var Pervasives = require("../../lib/js/pervasives.js");
7+
var Caml_format = require("../../lib/js/caml_format.js");
88

99
var __ocaml_lex_tables = /* record */[
1010
/* lex_base */"\0\0\xf6\xff\xf7\xff\xf8\xff\xf9\xff\xfa\xff\xfb\xff\xfc\xff:\0\x85\0\xff\xff",

0 commit comments

Comments
 (0)