Skip to content

Support js-sources for the mhs backend - #40

Merged
augustss merged 1 commit into
augustss:mainfrom
haskell-miso:mhs-js-sources
Oct 3, 2026
Merged

augustss merged 1 commit into
augustss:mainfrom
haskell-miso:mhs-js-sources

Conversation

@dmjio

@dmjio dmjio commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

This adds js-sources support to the mhs backend, matching GHC's JavaScript backend. miso needs it to embed miso.js when built with mcabal.

This depends on augustss/MicroHs#529, which adds the -js flag and jsbits support to mhs. Without it, an executable with js-sources fails with mhs's "Unknown flag" error. Packages without js-sources are not affected.

Changes

  • The js-sources of a library are installed in the jsbits directory of the package. mhs embeds the .js files there when linking a program that uses the package.
  • For executables, js-sources are passed to mhs with -js.

mhs embeds the files for targets that support it, such as emscripten, with --pre-js. Other targets ignore them.

Testing

With the mhs from augustss/MicroHs#529, I installed a small package that declares js-sources with this mcabal. Its JavaScript file was installed in jsbits. A program using the package, built for emscripten, embedded the file and called a function from it through foreign import javascript.

The js-sources of a library are installed in the jsbits directory of
the package, and for executables they are passed to mhs with -js.
mhs embeds them in the output for targets that support it (e.g., the
emscripten targets, with --pre-js).

This needs the -js flag and jsbits support in mhs, from
augustss/MicroHs#529. Packages without js-sources are not affected.
@augustss
augustss merged commit 33c5677 into augustss:main Oct 3, 2026
@dmjio
dmjio deleted the mhs-js-sources branch October 3, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants