Most modules are imported dynamically (const m = await import('./someMod.js') instead of statically import m from './someMod.js'.
Actual behavior
Everything is imported statically.
The Tauri rewrite is incoming, and one of the points of it is reduced memory usage.
I am wondering if dynamic imports can be of performance benefit to the project. Or do they all still get cached in the browser engine and take up RAM still?
Dynamic imports are usually good for loading websites over network, where loading the whole site takes time, but in our case they’re all already on the disk, and it’s not often you restart Delta Chat anyway.
I did a surface-level search, and could not find confirmation of this being good in Electron.
I doubt this is a factor for us, most use this pattern to decrease network traffic - we have everything local already.
And the biggest files we load are probably not code, but fonts, images and source maps.
I have worked with dynamic imports and had no significant problems with typing. It’s basically the same as with static imports.
About bundling: point taken. Though it sounds like it should be just a one-time setup.
For example, as long as the settings dialog is not open, its code doesn’t have to be in memory.
Also Gallery view, Chat audit log, and all other dialogs, with all their dependencies.
OK, we took a closer look, and it appears there is not that much code anyway, ~2.5 MB, so it’s probably not worth putting effort into, unless I’m missing something.
2.5 MB is both plaintext and from the “Memory” tab in Chromium dev tools.