sql-js / sql.js

A javascript library to run SQLite on the web.
http://sql.js.org
Other
12.59k stars 1.06k forks source link

Consider removing manual modularization #438

Open shamrin opened 3 years ago

shamrin commented 3 years ago

The generated code in sql-wasm.js mentions Emscripten issue: emscripten-core/emscripten#5820.

This issue was fixed in PR emscripten-core/emscripten#10697 and released as version 13.9.16 in May 2020.

I think removing manual modularization will simplify sql.js build process.

lovasoa commented 3 years ago

Yes, this could be nice, and simplify our old build process. Are you interested in making a PR ?

Taytay commented 3 years ago

I'm thrilled to hear that this was fixed in Emscripten directly. I've been out of this project for a while, but am dipping my toes back in and can take a look if no one beats me to it.

rhashimoto commented 3 years ago

I don't know how the bug was originally triggered, but I tried adding -s MODULARIZE=1 to the emcc flags, changed the output filename to end with .mjs (to output an ES6 module which I prefer), and removed the custom bundling.

Then to load the module in my page I did:

import initSqlJs from '../dist/sql-idb-wasm.mjs';
initSqlJs().then(async SQL => {
  ...

It seems to work. I'm using emsdk 2.0.16. Again, I don't know if I'm exercising the problem path.