Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that various filesystem libraries (FetchFS, IcaseFS, IDBFS, JSFileFS, NodeFS, OPFS, ProxyFS, and WorkerFS) are explicitly exported by adding the corresponding __export: true property to their library definitions. It also updates existing tests and adds a new parameterized test test_fs_js_exports in test/test_jslib.py to verify that these filesystem objects are correctly exported and accessible under different compilation settings (such as with closure compiler, modularization, and WasmFS). I have no additional feedback to provide.
59eef46 to
487fbe7
Compare
After `FS.filesystems` was removed in emscripten-core#27940 and `toplevel: true` was enabled for Terser in emscripten-core#27987, optional filesystem backends linked in via `-lidbfs.js`, `-lworkerfs.js`, `-lproxyfs.js`, `-lopfs.js`, etc. had no remaining references in the generated JS and were eliminated in `-O2` and `-O3` builds when referenced only from external JS (such as `Module.preRun` in HTML). Mark these optional filesystem backend objects with `__export: true` so that when `$FS` pulls them in, they are exported and preserved across JS optimizations (including `--closure=1`, `-sMODULARIZE`, and `-sMODULARIZE=instance`), without adding any code size when `$FS` is not used or under default settings. Fixes: emscripten-core#28072
487fbe7 to
b80d487
Compare
| addToLibrary({ | ||
| #if !LibraryManager.has('libnoderawfs.js') | ||
| $NODEFS__export: true, | ||
| #endif |
There was a problem hiding this comment.
Why does this depend on noderawfs?
|
Another option could be to require the user to export them manually, what do you think about the tradeoffs? |
I guess that is the status quo. It seems like if you include one of the filesystems you probably want use it though? I guess you could just use it on the inside of the module only. |
But this change does specifically fix the breaking in #28072 |
|
Hmm, but there, the code is var Module = {
preRun: [function() {
addRunDependency('syncfs')
FS.mkdir('/preferences')
FS.mount(IDBFS, {}, '/preferences');Exporting won't help this, I think? It would need to be |
Ah yes. I does solve their problem, since exporting I could focus on just including it, and not also exporting it? |
|
How would including it but not export it work? JSDCE would remove it without an export, I think. At least I don't see a non-hackish way, off the top of my head. The other option is to just document this. When you do |
Oh I see.. because JSDCE has no access the Previously it was being kept alive by the
|
After
FS.filesystemswas removed in #27940 andtoplevel: truewas enabled for Terser in #27987, optional filesystem backends linked in via-lidbfs.js,-lworkerfs.js,-lproxyfs.js,-lopfs.js, etc. had no remaining references in the generated JS and were eliminated in-O2and-O3builds when referenced only from external JS (such asModule.preRunin HTML).Mark these optional filesystem backend objects with
__export: trueso that when$FSpulls them in, they are exported and preserved across JS optimizations (including--closure=1,-sMODULARIZE, and-sMODULARIZE=instance), without adding any code size when$FSis not used or under default settings.Fixes: #28072