Skip to content

Commit 8335c99

Browse files
authored
[MODULARIZE=instance] Allow Module argument in --pre-js code. (#24328)
Previously we were clobbering any existing Module arguments with the arguments passed to the `init()` function. Also, don't limit INCOMING_MODULE_JS_API in MODULARIZE=instance mode. At least for now I think we should go for compatibility by default. The test I've enabled here sets the `dynamicLibraries` Module property during in a pre-js script.
1 parent 6b9cce3 commit 8335c99

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.circleci/config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,8 @@ jobs:
813813
instance.test_fasta
814814
instance.test_EXPORTED_RUNTIME_METHODS
815815
instance.test_ccall
816+
instance.test_dylink_basics*
817+
instance.test_Module_dynamicLibraries
816818
esm_integration.test_fs_js_api*
817819
esm_integration.test_inlinejs3
818820
esm_integration.test_embind_val_basics

src/postamble.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function preInit() {
303303
// In MODULARIZE=instance mode we delay most of the initialization work until
304304
// the `init` function is called.
305305
export default async function init(moduleArg = {}) {
306-
Module = moduleArg;
306+
Object.assign(Module, moduleArg);
307307
processModuleArgs();
308308
#if WASM_ESM_INTEGRATION
309309
updateMemoryViews();

tools/link.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,10 @@ def limit_incoming_module_api():
813813
diagnostics.warning('experimental', '-sMODULARIZE=instance is still experimental. Many features may not work or will change.')
814814
if options.oformat != OFormat.MJS:
815815
exit_with_error('MODULARIZE instance is only compatible with ES module output format')
816-
limit_incoming_module_api()
817-
for s in ['wasmMemory', 'INITIAL_MEMORY']:
818-
if s in settings.INCOMING_MODULE_JS_API:
819-
exit_with_error(f'{s} cannot be in INCOMING_MODULE_JS_API in MODULARIZE=instance mode')
816+
if 'INCOMING_MODULE_JS_API' in user_settings:
817+
for s in ['wasmMemory', 'INITIAL_MEMORY']:
818+
if s in settings.INCOMING_MODULE_JS_API:
819+
exit_with_error(f'{s} cannot be in INCOMING_MODULE_JS_API in MODULARIZE=instance mode')
820820

821821
if options.oformat in (OFormat.WASM, OFormat.BARE):
822822
if options.emit_tsd:

0 commit comments

Comments
 (0)