Skip to content

Commit b917d7a

Browse files
committed
fix(packages/node): broken dynamic import for platform specific package in ESM
1 parent d12b5e0 commit b917d7a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/node/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { resolve } from 'node:path';
22
import { existsSync } from 'node:fs';
3+
import { createRequire } from 'node:module';
34
import {
45
getCurrentPlatform,
56
getPlatformPackageName,
67
getBinaryName,
78
type Platform
89
} from './platform.js';
910

11+
// Create a require function that works in both CommonJS and ESM
12+
const require = createRequire(import.meta.url);
13+
1014
/**
1115
* Error thrown when the SQLite Sync extension cannot be found
1216
*/
@@ -25,8 +29,6 @@ function tryLoadPlatformPackage(): string | null {
2529
try {
2630
const packageName = getPlatformPackageName();
2731

28-
// Try to dynamically import the platform package
29-
// This works in both CommonJS and ESM
3032
const platformPackage = require(packageName);
3133

3234
if (platformPackage?.path && typeof platformPackage.path === 'string') {

src/cloudsync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
extern "C" {
2121
#endif
2222

23-
#define CLOUDSYNC_VERSION "0.8.61"
23+
#define CLOUDSYNC_VERSION "0.8.62"
2424

2525
int sqlite3_cloudsync_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
2626

0 commit comments

Comments
 (0)