The Wayback Machine - https://web.archive.org/web/20210124105409/https://github.com/sql-js/sql.js/issues/284
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support ES module #284

Open
Gladear opened this issue Jul 13, 2019 · 1 comment
Open

Feature request: Support ES module #284

Gladear opened this issue Jul 13, 2019 · 1 comment
Labels

Comments

@Gladear
Copy link

@Gladear Gladear commented Jul 13, 2019

Hi,

It would be nice to add a module target to the project.
This would allow to dynamically import the library with import() function, and would probably work better with some bundlers (thinking about rollup now).
I'm trying to work on it, but I'm not used to work with coffeescript and make, so any help is welcome !

@lovasoa lovasoa added the enhancement label Jul 13, 2019
@m-schuetz
Copy link

@m-schuetz m-schuetz commented Oct 21, 2019

I've had some luck with this adaption: https://pastebin.com/d70TyxZq

const sql = await import("../libs/sql.js/sql-wasm.js");
window.initSqlJs = sql.initSqlJs;

using it together with geopackage.js like this:
...

initSqlJs({ locateFile: filename => "../libs/sql.js/sql-wasm.wasm" })
.then(async (SQL) => {
		const u8 = new Uint8Array(buffer);
		const data = await geopackage.open(u8);
		...

EDIT:
Okay, I'm not actually sure if this really works. It does seem to work but apparently geopackage.js bundles it's own sql.js. I still have to import sql.js or I will get an error. So I'm not sure if geopackage ends up using this ES module adaption, or it's own bundled sql.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants