Mix escript.build incompatible with "-mode embedded"?

My application uses the :escript option in mix.exs to generate a single file for delivery.

Now, for performance reasons, I need to add the “-mode embedded” option for the Erlang interpreter so that it preloads all code before starting the app.

Inside the escript it originally looked as follows:

#! /usr/bin/env escript
%%
%%! -escript main nil_escript

This worked. As soon as I add ‘emu_args: “-mode embedded”’ to my escript options, it changes to this:

#! /usr/bin/env escript
%%
%%! -escript main nil_escript -mode embedded

Which then complains that nil_escript:main cannot be found. (It found it before.)

If I understand the code to the Mix task right, this utility module for calling the actual main is generated by a macro. I guess in embedded mode this generated code is not available? How can I solve this?