Skip to content

Commit 4f1c548

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

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
@@ -17,7 +17,7 @@
1717
extern "C" {
1818
#endif
1919

20-
#define CLOUDSYNC_VERSION "0.9.8"
20+
#define CLOUDSYNC_VERSION "0.9.81"
2121
#define CLOUDSYNC_MAX_TABLENAME_LEN 512
2222

2323
#define CLOUDSYNC_VALUE_NOTSET -1

0 commit comments

Comments
 (0)