Has anyone gotten sqldelight to be accessible for ...
# squarelibraries
t
Has anyone gotten sqldelight to be accessible for jsBrowserTest? I have been messing with karma.config files and haven't been able to crack it. I can see the wasm file in the correct tmp folder but it isn't able to be accessed by the tests
d
I think it should just work out of the box, e.g. see the tests for the driver https://github.com/cashapp/sqldelight/tree/master/drivers/sqljs-driver If it helps: sql.js tries to load the wasm file from the root of the server, but you can also override the location it searches for when you init sql.js
Actually, looking more closely at the way those tests are set up, something looks off since it doesn't copy the wasm file at all... so those tests might be failing silently. I'll look more into this in a couple of days
t
Thanks, I had tried updating to the 2.0.0 alpha for sqldelight and it did copy the wasm file to what appears to be the correct place a bit easier, but the test code couldn't access
let me know if there is any information I can provide to help
d
It looks like this will do the trick:
Copy code
config.basePath = "../.."
config.files.push({
    pattern: "node_modules/sql.js/dist/sql-wasm.wasm", served: true, watched: false, included: false, nocache: false
});

config.proxies["/sql-wasm.wasm"] = "/base/node_modules/sql.js/dist/sql-wasm.wasm"
although messing with the
basePath
like that is a bit sketchy
Actually this is better and doesn't require touching the
basePath
Copy code
const path = require("path");
const abs = path.resolve("../../node_modules/sql.js/dist/sql-wasm.wasm")

config.files.push({
    pattern: abs,
    served: true,
    watched: false,
    included: false,
    nocache: false,
});

config.proxies["/sql-wasm.wasm"] = `/absolute${abs}`
t
And that would go in the karma config and keep the webpack config the same as recommended?
also thank you so much for looking into this!
d
Yep! That goes in the karma config, and webpack stays the same
t
Would this work for 1.5.3 as well?
d
It should, yes
t
This worked on 2.0.0 for me! Thank you. I'll revert to stable in a bit and check there, but this was amazingly helpful.
👍 1