absurd-sql icon indicating copy to clipboard operation
absurd-sql copied to clipboard

TypeScript support

Open jlongster opened this issue 2 years ago • 8 comments

@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.

jlongster avatar Oct 13 '21 03:10 jlongster

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

quolpr avatar Oct 13 '21 09:10 quolpr

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.

jlongster avatar Oct 13 '21 16:10 jlongster

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

steida avatar Nov 16 '21 16:11 steida

@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 🙂

quolpr avatar Nov 16 '21 20:11 quolpr

@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

delaneyj avatar Feb 03 '22 21:02 delaneyj

@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;
    },
  });

stereosteve avatar Jul 22 '22 20:07 stereosteve

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

quolpr avatar Jul 23 '22 09:07 quolpr

Any update on this typescript support?

TarakKar avatar Oct 03 '22 16:10 TarakKar