sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

[WIP]Add support for NODEFS

Open fanthos opened this issue 4 years ago • 6 comments

Export FS to outer module to allow custom mount filesystem. Link and export NODEFS to allow mount NODEFS on emscripten virtual fs.

fanthos avatar Mar 01 '21 05:03 fanthos

May I ask what exactly is your use case for sql.js on node.js ? sql.js is slower, more limited, and uses more memory than a native sqlite. If you are working on both node and the browser, I would suggest writing a small abstraction layer that can talk to either native SQLite or sql.js depending on the platform. There isn't really any point in running sql.js on node.

lovasoa avatar Mar 01 '21 07:03 lovasoa

I have a project running nodejs on different processor and operating system, including MIPS and x86, so making code portable might be helpful for this. Currently the tests passed on debug mode.

fanthos avatar Mar 01 '21 07:03 fanthos

SQLite is an extremely portable piece of software. It should work without issue on almost any architecture. Especially if you plan to run on less powerful hardware, I would encourage you to use a native solution.

lovasoa avatar Mar 01 '21 08:03 lovasoa

The code works good without Closure Compiler, but I have no idea how Closure Compiler breaks it.

fanthos avatar Mar 01 '21 10:03 fanthos

Compressing sql-asm-debug.js with uglify-js -m option result a 2,493kb file and all tests passed.

fanthos avatar Mar 02 '21 01:03 fanthos

Please consider this change again! One benefit of this capability is that if you're on a shared host your host can upgrade the underlying NodeJS version without you having to recompile SQLite bindings. Right now I need to re-build my SQLite packages when NearlyFreeSpeech.NET moves to the next NodeJS LTS version. If I'm not on my toes, my site could be down for some time (obviously, this is not mission critical for me, but could be for others).

davidvedvick avatar Jan 14 '24 19:01 davidvedvick