Skip to content

How to use Topdirs.dir_load/Dynlink.loadfile with js files #620

@SanderSpies

Description

@SanderSpies

I'm trying to move from dynamically loading .cma/.cmo files to loading "precompiled" .js files as mentioned here: #480, however I have been unsuccessful so far.

I'm using Topdirs.dir_load Format.std_formatter foo_file to load the files so they can be executed without giving a Error: Reference to undefined global Foo' error.

It's unclear however to me how this should work with JS files.

I did try to use Dynlink.loadfile but that resulted in: The dynlink.cma library cannot be used inside the OCaml toplevel. Note that I used jsoo_mktop -package dynlink ... for this.

This works for me when using Topdirs.dir_load Format.std_formatter foo_file:
js_of_ocaml --file foo.cma --extern-fs -I . --ofs=fs.js

but what I want to get to work is:

js_of_ocaml --pretty foo.cma
cat foo.js >> fs.js

Some guidance would be much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions