And I fixed that one by changing the code in <http...
# squarelibraries
n
And I fixed that one by changing the code in https://cashapp.github.io/sqldelight/2.0.0/js_sqlite/#using-a-web-worker from
Copy code
val driver = WebWorkerDriver(
  Worker(
    js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""")
  )
)
to
Copy code
val driver = WebWorkerDriver(
  Worker(
    js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)"""),
    object : WorkerOptions { override var type: WorkerType? = WorkerType.MODULE }
  )
)
but I think this is now causing
SyntaxError: ambiguous indirect export: default
which I assume is because
sqljs.worker.js
isn't a module after all - how is the
import initSqlJs from "sql.js";
at the top of the file suppose to work? Is webpack suppose to make this import go away during bundling? @Derek Ellis
d
I think webpack might treat it differently than vite does.
(assuming you are using vite based on your previous messages?)
m
@Nick Williams Were you able to solve it? I'm in a similar situation with vite. I've modified the Worker instantiation but it's brutally failing and I can't understand why 😓
Copy code
actual suspend fun createDriver(): SqlDriver {
            console.log("before worker instance")

            val driver =  WebWorkerDriver(
//                Worker(
//                    js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""")
//                )
                // TODO: revert back, this is for vite
                Worker(
                    js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)"""),
                    object : WorkerOptions {
                        override var type: WorkerType? = WorkerType.MODULE
                    }
                ).apply {
                    onerror = {
                        console.log("Error in workerr: ", it)
                    }

                    onmessage = {
                        console.log("on message: ", it)
                    }
                }
            )

            console.log("after worker instance")
            console.log("bbhere")

            // Crashing here :(
            try {
                HockeyDb.Schema.awaitCreate(driver)
            } catch (e: Throwable) {
                console.log("Error in awaitCreate: ", e)
            }

            console.log("after driver creation")

            return driver
        }