diff --git a/changelog.md b/changelog.md index 1438c9d..384719b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-02-10 - 1.1.2 - fix(rust-binary-locator) +use import.meta.resolve and url.fileURLToPath to locate bundled Rust binary in ESM environments + +- Replace require.resolve with import.meta.resolve to support ESM module resolution +- Convert resolved file URL to a filesystem path using url.fileURLToPath +- Export the url module from ts/plugins to provide fileURLToPath + ## 2026-02-10 - 1.1.1 - fix(readme) update README with comprehensive documentation, usage examples, API reference, installation instructions, and legal/company information diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index c5793b6..9340a86 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartrust', - version: '1.1.1', + version: '1.1.2', description: 'a bridge between JS engines and rust' } diff --git a/ts/classes.rustbinarylocator.ts b/ts/classes.rustbinarylocator.ts index 8229998..d7c199c 100644 --- a/ts/classes.rustbinarylocator.ts +++ b/ts/classes.rustbinarylocator.ts @@ -108,7 +108,8 @@ export class RustBinaryLocator { const packageName = `${platformPackagePrefix}-${platform}-${arch}`; try { - const packagePath = require.resolve(`${packageName}/${binaryName}`); + const resolved = import.meta.resolve(`${packageName}/${binaryName}`); + const packagePath = plugins.url.fileURLToPath(resolved); if (await this.isExecutable(packagePath)) { return packagePath; } diff --git a/ts/plugins.ts b/ts/plugins.ts index b0c7538..8f7a422 100644 --- a/ts/plugins.ts +++ b/ts/plugins.ts @@ -4,8 +4,9 @@ import * as fs from 'fs'; import * as childProcess from 'child_process'; import * as readline from 'readline'; import * as events from 'events'; +import * as url from 'url'; -export { path, fs, childProcess, readline, events }; +export { path, fs, childProcess, readline, events, url }; // @push.rocks scope import * as smartpath from '@push.rocks/smartpath';