Skip to content

Commit

Permalink
Slightly less of a mess
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Oct 15, 2024
1 parent 261a898 commit ab676ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
24 changes: 7 additions & 17 deletions extensions/positron-duckdb/src/duckdb-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,16 @@
import { resolve, dirname } from 'path';

export function getDuckDBNodeBundles() {
// const modPath = require.resolve('@duckdb/duckdb-wasm');
// const dist_path = dirname(modPath);
// return {
// mvp: {
// mainModule: resolve(dist_path, './duckdb-mvp.wasm'),
// mainWorker: resolve(dist_path, './duckdb-node-mvp.worker.cjs')
// },
// eh: {
// mainModule: resolve(dist_path, './duckdb-eh.wasm'),
// mainWorker: resolve(dist_path, './duckdb-node-eh.worker.cjs')
// }
// };
const modPath = require.resolve('@duckdb/duckdb-wasm');
const dist_path = dirname(modPath);
return {
mvp: {
mainModule: 'foo',
mainWorker: 'bar'
mainModule: resolve(dist_path, './duckdb-mvp.wasm'),
mainWorker: resolve(dist_path, './duckdb-node-mvp.worker.cjs')
},
eh: {
mainModule: 'foo',
mainWorker: 'bar'
mainModule: resolve(dist_path, './duckdb-eh.wasm'),
mainWorker: resolve(dist_path, './duckdb-node-eh.worker.cjs')
}
}
};
}
2 changes: 1 addition & 1 deletion extensions/positron-duckdb/src/duckdb-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import duckdb_worker_mvp from '@duckdb/duckdb-wasm/dist/duckdb-browser-mvp.worke
import duckdb_wasm_eh from '@duckdb/duckdb-wasm/dist/duckdb-eh.wasm';
import duckdb_worker_eh from '@duckdb/duckdb-wasm/dist/duckdb-browser-eh.worker.js';

function getDuckDBWebpackBundles() {
export function getDuckDBWebpackBundles() {
return {
mvp: {
mainModule: duckdb_wasm_mvp,
Expand Down
6 changes: 3 additions & 3 deletions extensions/positron-duckdb/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DuckDBInstance {
const worker = new Worker(bundle.mainWorker);

const db = new duckdb.AsyncDuckDB(logger, worker);
await db.instantiate(bundle.mainModule);
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);

const con = await db.connect();
await con.query('LOAD icu; SET TIMEZONE=\'UTC\';');
Expand All @@ -54,10 +54,10 @@ class DuckDBInstance {
// Method to dynamically load the bundles based on environment
private static async getBundles(): Promise<duckdb.DuckDBBundles> {
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
const duckdb_node = require('./duckdb-node');
const duckdb_node = await import('./duckdb-node');
return duckdb_node.getDuckDBNodeBundles();
} else {
const duckdb_webpack = require('./duckdb-webpack');
const duckdb_webpack = await import('./duckdb-webpack');
return duckdb_webpack.getDuckDBWebpackBundles();
}
}
Expand Down
1 change: 0 additions & 1 deletion extensions/positron-duckdb/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"typeRoots": [
"./node_modules/@types"
],
Expand Down

0 comments on commit ab676ef

Please sign in to comment.