I believe this is from 1.39.16, the changelog entry (
https://github.com/emscripten-core/emscripten/blob/master/ChangeLog.md#13916-05152020)
says

====
Change the factory function created by using the MODULARIZE build option to
return a Promise instead of the module instance. That is, beforehand

  Module()

would return an instance (which was perhaps not ready yet if startup was
async). In the new model, that returns a Promise which you can do .then or
await on to get notified when the instance is ready, and the callback
receives the instance. Note that both before and after this change doing
Module() creates and runs an instance, so the only change is the return
value from that call. This fixes some long-standing bugs with that option
which have been reported multiple times, but is a breaking change - sorry
about that. To reduce the risk of confusing breakage, in a build with
ASSERTIONS we will show a clear warning on common errors. For more, see
detailed examples for the current usage in src/settings.js on MODULARIZE.
(#10697)
====

Thanks Shlomi, good to mention this here as it might help others (I don't
think we mentioned it in the mailing list before).

- Alon


On Fri, Aug 21, 2020 at 5:24 AM Shlomi Fish <shlo...@shlomifish.org> wrote:

> Hi all!
>
> I'm documenting a recent change in the semantics of Emscripten and emcc
> (starting from 1.39.x and also seems to affect 2.0.x): Module() now
> returns a
> promise and one should for example do:
>
> Module().then((result) => {
>         real_module = result;
> })
>
> E.g like in
>
> https://github.com/shlomif/fc-solve/commit/dcdb924262860eb8d023402400fa1e8cd9dce6c2
> :
>
> diff --git a/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts
> b/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts index f3082e52f..d510bc4fa
> 100644 --- a/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts
> +++ b/fc-solve/site/wml/src/ts/web-fc-solve-tests.ts
> @@ -494,7 +494,12 @@ export function test_js_fc_solve_class(qunit: QUnit,
> my_callback: () => void) { // var _my_mod = Module({});
>      const _my_mod = [null];
>      _my_mod[0] = Module()({
> -        onRuntimeInitialized: my_func(qunit, _my_mod, my_callback),
> +        onRuntimeInitialized: () => {
> +            _my_mod[0].then((result) => {
> +                _my_mod[0] = result;
> +                return my_func(qunit, _my_mod, my_callback)();
> +            });
> +        },
>      });
>      return;
>  }
>
> (my code has a little weirdness of using "Module()()" instead of
> "Module()" -
> you can ignore that).
>
> For more about js promises, see:
>
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
>
> --
>
> Shlomi Fish       https://www.shlomifish.org/
> Perl Elems to Avoid - https://perl-begin.org/tutorials/bad-elements/
>
> There was one Napoleon, one George Washington, and one me!
>     — Big Boy Caprice in
>        https://en.wikiquote.org/wiki/Dick_Tracy_%281990_film%29
>
> Please reply to list if it's a mailing list post - https://shlom.in/reply
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/20200821152439.0cb14ca2%40telaviv1.shlomifish.org
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpQmF-%2Bjc-6ihfJGgesRHg6mF7mP1zyqp-z1M44YeNa0gg%40mail.gmail.com.

Reply via email to