From 40b2568aba2cc445573532958eecd8d678a3d7c1 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Tue, 8 Oct 2024 12:49:45 -0700 Subject: [PATCH] 3.2.4 `createRequire` to allow copy loader from esbuild to work in SEA (#48) The JS Bindings that NAPI-RS produces use raw require calls for local files. With esbuild, this is normally fine as you can use the copy loader to just move the .node addon to the right place but SEAs dont allow requiring from the fs: [nodejs.org/docs/latest-v20.x/api/single-executable-applications.html#requireid-in-the-injected-main-script-is-not-file-based](https://nodejs.org/docs/latest-v20.x/api/single-executable-applications.html#requireid-in-the-injected-main-script-is-not-file-based) They recommend using createRequire instead This change should allow native addons created by NAPI-RS to be used in SEAs --- index.js | 2 ++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-x64-gnu/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 43de6ae..0714276 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,8 @@ const { existsSync, readFileSync } = require('fs') const { join } = require('path') +const { createRequire } = require('node:module') +require = createRequire(__filename) const { platform, arch } = process diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index db1a876..beb8b37 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@replit/ruspty-darwin-arm64", - "version": "3.2.3", + "version": "3.2.4", "os": [ "darwin" ], diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 4331798..efc1f2a 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@replit/ruspty-darwin-x64", - "version": "3.2.3", + "version": "3.2.4", "os": [ "darwin" ], diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index 79ebfb6..025e961 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@replit/ruspty-linux-x64-gnu", - "version": "3.2.3", + "version": "3.2.4", "os": [ "linux" ], diff --git a/package-lock.json b/package-lock.json index 0e92464..a9bee1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@replit/ruspty", - "version": "3.2.3", + "version": "3.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@replit/ruspty", - "version": "3.2.3", + "version": "3.2.4", "license": "MIT", "devDependencies": { "@napi-rs/cli": "^2.18.2", diff --git a/package.json b/package.json index b371f04..ce44739 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@replit/ruspty", - "version": "3.2.3", + "version": "3.2.4", "main": "dist/wrapper.js", "types": "dist/wrapper.d.ts", "author": "Szymon Kaliski ",