If I compile my C++ code with emcc without -s MODULARIZE=1 -s 'EXPORT_NAME="createMyModule"', I can load my WebAssembly and access the File System API like this:
HTML:
<script type="text/javascript">
var Module = {
onRuntimeInitialized: function() {
console.log('Module loaded!');
if (FS.mkdir) {
console.log('File System API available!');
}
}
};
</script>
<script type="text/javascript" src="myWebAssemblyModule.js"></script>
<script type="module" src="my.js"></script>
Log:
Module loaded!
File System API available!
But if I add -s MODULARIZE=1 -s 'EXPORT_NAME="createMyModule"' as compiler options, and try to access the File System API based on a Promise, it doesn't work:
HTML:
<script type="text/javascript" src="myWebAssemblyModule.js"></script>
<script type="module" src="my.js"></script>
my.js:
createMyModule().then(MyModule => {
console.log('Module loaded!');
if (MyModule.FS.mkdir) {
console.log('File System API available!');
}
});
Log:
Module loaded!
So how can I access the File System API with the "MODULARIZED/Promise based" approach?
MyModule.FS is accessible btw., but not MyModule.FS.mkdir.