diff --git a/Makefile.emscripten b/Makefile.emscripten index fb77ee3839..b1dd96469a 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -22,6 +22,7 @@ # # FHEROES2_STRICT_COMPILATION: build in strict compilation mode (turns warnings into errors) # FHEROES2_WITH_DEBUG: build in debug mode +# FHEROES2_WITH_MODULARIZE: wrap the emitted JS code in a function that returns a promise # FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2) .PHONY: all clean translations diff --git a/src/dist/Makefile.emscripten b/src/dist/Makefile.emscripten index 8010a5fbab..c5aac50d11 100644 --- a/src/dist/Makefile.emscripten +++ b/src/dist/Makefile.emscripten @@ -43,3 +43,10 @@ ifdef FHEROES2_WITH_DEBUG CCFLAGS := $(CCFLAGS) -gsource-map LDFLAGS := $(LDFLAGS) -gsource-map endif + +ifdef FHEROES2_WITH_MODULARIZE +LDFLAGS := $(LDFLAGS) \ + -sMODULARIZE \ + -sEXPORTED_RUNTIME_METHODS=FS,ENV,noExitRuntime,addOnExit,run \ + -sEXPORT_NAME=fheroes2 +endif