jlongster / absurd-sql

sqlite3 in ur indexeddb (hopefully a better backend soon)
MIT License
4.15k stars 101 forks source link

TypeScript support #35

Open jlongster opened 2 years ago

jlongster commented 2 years ago

@quolpr You mentioned that you were interested in helping migrate to TypeScript. Are you still interested in that? I'm familiar with it, but not as familiar with setting it up on a new project.

quolpr commented 2 years ago

@jlongster yep, I can do that. But I am not sure about the deadlines, cause right now I am pretty busy

jlongster commented 2 years ago

No rush! You know me, other things in life are more important :)

I can help a lot with migrating the actual code. I don't know a ton about what's needed in all the tooling to get TS running though.

steida commented 2 years ago

@quolpr Are you working on that? I can do it.

quolpr commented 2 years ago

@steida I am waiting for when https://github.com/jlongster/absurd-sql/pull/36 PR will be merged, then I will open another PR where I will be working on typescript support.

I would be happy to any help 🙂

delaneyj commented 2 years ago

@steida @quolpr ... I have working examples of SQL.js working in a web worker but not having good luck bootstrapping absurd-sql even with blatant use of any. Does any one have example of this working in typescript at any level? Specifically getting CompileError: WebAssembly.instantiate(): BufferSource argument is empty

stereosteve commented 2 years ago

@delaneyj I got this error when sql-wasm.wasm failed to load (404)

The initSqlJs has a locateFile callback to tell where the wasm file should be loaded from. So with vite I used:

  let SQL = await initSqlJs({
    locateFile: (file: string) => {
      const result = `/node_modules/@jlongster/sql.js/dist/${file}`;
      return result;
    },
  });
quolpr commented 2 years ago

For vite it's better to do:

import absurdSqlWasmUrl from "@jlongster/sql.js/dist/sql-wasm.wasm?url";

let SQL = await initSqlJs({
  locateFile: () => absurdSqlWasmUrl,
});

For CRA:

import sqlWasmUrl from "@trong-orm/sql.js/dist/sql-wasm.wasm";

let SQL = await initSqlJs({
  locateFile: () => sqlWasmUrl
});

Some more info could be found here: https://trong-orm.netlify.app/backends/web

TarakKar commented 1 year ago

Any update on this typescript support?