diff --git a/compiler/bin-js_of_ocaml/build_fs.ml b/compiler/bin-js_of_ocaml/build_fs.ml index 16ac22a23d..3d20db9454 100644 --- a/compiler/bin-js_of_ocaml/build_fs.ml +++ b/compiler/bin-js_of_ocaml/build_fs.ml @@ -61,6 +61,7 @@ function jsoo_create_file_extern(name,content){ } |} in + Config.set_target `JavaScript; let fragments = Linker.Fragment.parse_string code in Linker.load_fragments ~target_env:Isomorphic ~filename:"" fragments; Linker.check_deps (); diff --git a/compiler/bin-js_of_ocaml/js_of_ocaml.ml b/compiler/bin-js_of_ocaml/js_of_ocaml.ml index 144543663c..a80b6ce41d 100644 --- a/compiler/bin-js_of_ocaml/js_of_ocaml.ml +++ b/compiler/bin-js_of_ocaml/js_of_ocaml.ml @@ -109,7 +109,9 @@ let () = comp; exit 1 | Failure s -> + let backtrace = Printexc.get_backtrace () in Format.eprintf "%s: Error: %s@." Sys.argv.(0) s; + prerr_string backtrace; exit 1 | exc -> let backtrace = Printexc.get_backtrace () in diff --git a/compiler/tests-full/dune b/compiler/tests-full/dune index 802b8da1db..5effacad3b 100644 --- a/compiler/tests-full/dune +++ b/compiler/tests-full/dune @@ -26,3 +26,20 @@ (= %{ocaml_version} "5.2.0")) (action (diff stdlib.cma.expected.js stdlib.cma.output.js))) + +(rule + (targets fs.output.js) + (deps file1 file2) + (action + (run + %{bin:js_of_ocaml} + build-fs + -o + %{targets} + file1:/static/file1 + file2:/static/dir/file2))) + +(rule + (alias runtest) + (action + (diff fs.expected.js fs.output.js))) diff --git a/compiler/tests-full/file1 b/compiler/tests-full/file1 new file mode 100644 index 0000000000..28bf5b1fb9 --- /dev/null +++ b/compiler/tests-full/file1 @@ -0,0 +1 @@ +This is file 1 \ No newline at end of file diff --git a/compiler/tests-full/file2 b/compiler/tests-full/file2 new file mode 100644 index 0000000000..4419d52b7a --- /dev/null +++ b/compiler/tests-full/file2 @@ -0,0 +1 @@ +This is file 2 \ No newline at end of file diff --git a/compiler/tests-full/fs.expected.js b/compiler/tests-full/fs.expected.js new file mode 100644 index 0000000000..82bf5656ea --- /dev/null +++ b/compiler/tests-full/fs.expected.js @@ -0,0 +1,31 @@ +(function(a){ + typeof globalThis !== "object" + && + (this + ? b() + : (a.defineProperty + (a.prototype, "_T_", {configurable: true, get: b}), + _T_)); + function b(){ + var b = this || self; + b.globalThis = b; + delete a.prototype._T_; + } + } + (Object)); +(function(c){ + "use strict"; + function a(a, b){ + if(c.jsoo_create_file) + c.jsoo_create_file(a, b); + else{ + if(! c.caml_fs_tmp) c.caml_fs_tmp = []; + c.caml_fs_tmp.push({name: a, content: b}); + } + return 0; + } + a("/static/file1", "This is file 1"); + a("/static/dir/file2", "This is file 2"); + return; + } + (globalThis));