https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
t

Trevor Stone

04/11/2022, 1:55 AM
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

Derek Ellis

04/11/2022, 10:28 PM
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

Trevor Stone

04/11/2022, 11:29 PM
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

Derek Ellis

04/12/2022, 3:56 AM
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

Trevor Stone

04/12/2022, 1:06 PM
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

Derek Ellis

04/12/2022, 1:07 PM
Yep! That goes in the karma config, and webpack stays the same
t

Trevor Stone

04/12/2022, 1:11 PM
Would this work for 1.5.3 as well?
d

Derek Ellis

04/12/2022, 1:17 PM
It should, yes
t

Trevor Stone

04/12/2022, 2:02 PM
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
39 Views