Skip to content

[Feature] Multiple source file/string support for generated Playground compiler #2883

@phated

Description

@phated

Currently, the playground takes a single source string (passed to compile()) and produces JS output. This requires tools that support multiple files (like https://github.com/phated/reasonable and codesandbox/codesandbox-client#850) to guess at the dependency list/order before wrapping each source file in module syntax and concatenating them together, which is then passed to the compile() method. Currently, both tools are using a custom compiled version of BuckleScript by @jaredly and then doing their own module resolution.

If the playground had support for registering multiple source strings (maybe by a module name?) before calling compile(), I think all of that previous dance could be avoided.

Hypothetical API:

window.ocaml.registerModule("Foo", "...");
window.ocaml.registerModule("Bar", "...");
window.ocaml.registerModule("Baz", "..."); // Uses Foo and Bar modules
window.ocaml.compileModules();

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleOld issues that went stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions