-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to build this as a wasm extension #89
Comments
Thanks, this does makes sense, I will need to come back on writing this properly, expecially on the testing part. Part of the problem is that extension-template depends on VCPKG being properly set-up. An easier to start point can be something like vss, you can try:
And see where this goes. I would expect this should work if you have emscripten on a recent enough version. |
Yes, this built correctly for me, with no errors. It seems like my system is set up correctly |
For testing I'm tying something like this, but I cant quite seem to get it working: const duckdb = require("@duckdb/duckdb-wasm");
const path = require("path");
const Worker = require("web-worker");
const DUCKDB_DIST = path.dirname(require.resolve("@duckdb/duckdb-wasm"));
(async () => {
try {
const DUCKDB_CONFIG = await duckdb.selectBundle({
mvp: {
mainModule: path.resolve(DUCKDB_DIST, "./duckdb-mvp.wasm"),
mainWorker: path.resolve(DUCKDB_DIST, "./duckdb-node-mvp.worker.cjs"),
},
eh: {
mainModule: path.resolve(DUCKDB_DIST, "./duckdb-eh.wasm"),
mainWorker: path.resolve(DUCKDB_DIST, "./duckdb-node-eh.worker.cjs"),
},
});
const logger = new duckdb.ConsoleLogger();
const worker = new Worker(DUCKDB_CONFIG.mainWorker);
const db = new duckdb.AsyncDuckDB(logger, worker);
await db.instantiate(DUCKDB_CONFIG.mainModule, DUCKDB_CONFIG.pthreadWorker);
const conn = await db.connect();
await conn.query(
`
INSTALL './build/wasm_mvp/extension/quack/quack.duckdb_extension';
INSTALL './build/wasm_eh/extension/quack/quack.duckdb_extension';
`
);
console.log("installed");
await conn.query("LOAD 'quack'; ");
console.log("loaded");
const result = await conn.query(`select quack('Jane') as result;`);
await conn.close();
await db.terminate();
await worker.terminate();
console.log(
"result:",
result.toArray().map((row) => row.toJSON())
);
} catch (e) {
console.error(e);
}
})(); The above code will just hang at When I do should I be setting my |
Hi @carlopi, I tabled this for a while, but do you have an example or doc on how to do the above? |
I see that there are wasm_mvp, wasm_threads and wasm_eh targets being built in CI however I get a number of errors trying to build locally
Are there instructions on how to build and test a wasm extension locally?
The text was updated successfully, but these errors were encountered: