vercel / ncc

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.
https://npmjs.com/@vercel/ncc
MIT License
9.27k stars 291 forks source link

ncc vs Serialport Part 2 - missing binaries (assets) #900

Open jeffrson opened 2 years ago

jeffrson commented 2 years ago

For serialport (https://www.npmjs.com/package/serialport) 10, ncc fails with ESM as well (https://github.com/vercel/ncc/issues/899).

Furthermore it fails to copy binary assets (*.node).

  1. yarn init -y
  2. yarn add serialport
  3. file index.cjs
    const SerialPort = require('serialport')
  4. ncc build .\index.cjs -s -C --target es2020
  5. 
    > node .\dist\index.cjs

C:\temp\sp_test\dist\index.cjs:3496 throw new Error('No native build was found for ' + target + '\n loaded from: ' + dir + '\n') ^ Error: No native build was found for platform=win32 arch=x64 runtime=node abi=93 uv=1 libc=glibc node=16.14.2 webpack=true loaded from: C:\temp\sp_test

at Function.load.path (C:\temp\sp_test\dist\index.cjs:3496:9)
at load (C:\temp\sp_test\dist\index.cjs:3458:30)
at Object.296 (C:\temp\sp_test\dist\index.cjs:804:46)

...


ncc 0.33.3
styfle commented 2 years ago

@guybedford Any thoughts would could cause this? Looks like the native addons from node_modules/@serialport/bindings-cpp/build/Release are not relocated to dist.

rprovodenko commented 2 years ago

Any news on this? Copying assets I find is a weak spot for ncc. How about adding the ability to specify hints/directives to ncc to help it with this?