FS_createPreloadedFile not supported in MEMFS under node.js, but could easily be
#16,742 建立於 2022年4月16日
描述
I have code that runs in the browser using lazily loaded files, and I would very much like to be able to test it on the command-line using node.js without having to recompile it. As noted in https://github.com/emscripten-core/emscripten/issues/16740, lazy loading is broken under node.js because it corrupts binary files. So the alternative is to pre-load these files in a preRun() callback.
Unfortunately this doesn't work either, because createPreloadedFile() calls Browser.handledByPreloadPlugin(), but since this is node.js, there is no Browser:
Well, that's fine, this is JavaScript after all, I can just make a dummy Browser object in my test code, and now it works:
Browser = {
handledByPreloadPlugin() {
return false;
}
};
But really I shouldn't have to do this :) Am I missing something in the documentation, is there a better way to do this (yes, I know that I can just use NODEFS or NODERAWFS, but as mentioned above, I don't want to recompile just to run a test).
My emscripten version:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.8 (3ff7eff373d31d8c0179895165462019221f192e)
clang version 15.0.0 (https://github.com/llvm/llvm-project 80ec0ebfdc5692a58e0832125f2c6a991df9d63f)