Skip to content

@node-rs/helper incompatible with asset relocation #316

@timfish

Description

@timfish

Both ncc and electron-forge rely on @vercel/webpack-asset-relocator-loader to locate and copy native node assets.

@vercel/webpack-asset-relocator-loader supports many conventions, works with wildcards, __dirname and has special cases for historic ways to load a native binary (ie. require('bindings')(...), nbind.init(..), etc). However, it's analysis fails to make sense of the binding loading code in @node-rs/helper because it's too complex.

To reproduce:

package.json

{
  "name": "ncc-test",
  "version": "1.0.0",
  "main": "dist/index.js",
  "license": "MIT",
  "scripts": {
    "start": "node ./dist/index.js -v",
    "build": "ncc build index.js -o dist"
  },
  "devDependencies": {
    "@vercel/ncc": "^0.27.0"
  },
  "dependencies": {
    "@node-rs/crc32": "^1.0.0"
  }
}

index.js

const crc = require("@node-rs/crc32");
const out = crc.crc32(Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]));
console.log("out", out);

Run

yarn && yarn build && yarn run

Result:
Can not find node binding files from @node-rs/crc32-darwin-x64 and /Users/timfish/Documents/Repositories/ncc-test/dist/crc32.darwin-x64.node

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions