Skip to content

Commit

Permalink
3.2.4 createRequire to allow copy loader from esbuild to work in SEA (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
jackyzha0 authored Oct 8, 2024
1 parent 3cfb095 commit 40b2568
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-darwin-arm64",
"version": "3.2.3",
"version": "3.2.4",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-darwin-x64",
"version": "3.2.3",
"version": "3.2.4",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-linux-x64-gnu",
"version": "3.2.3",
"version": "3.2.4",
"os": [
"linux"
],
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down

0 comments on commit 40b2568

Please sign in to comment.