vercel / nft

Node.js dependency tracing utility
https://npmjs.com/@vercel/nft
MIT License
1.31k stars 136 forks source link

Serialport prebuilds removed by NFT - PR coming soon #413

Closed RogerHardiman closed 4 months ago

RogerHardiman commented 5 months ago

Hi The nodeJS SerialPort module comes with a prebuilds folder with .node files for Windows, Mac, Linux (32 and 64 bit variants, and glibc and musl variants) Because it uses a runtime generated path to select which .node file to load, NFT will remove these files.

I've used the special-cases code to add in a rule for @serialport/bindings-cpp.

It is working great so I'll fork and do a Pull Request for you.

I noticed you had code to detect .node files from bind.js, but the paths that parses does not include a prebuilds, with sub folders for each OS, Arch and C Library, so think special-cases is the place to fix this.

RogerHardiman commented 5 months ago

For info, my patch on the installed nft (ie in Javascript) is

    '@serialport/bindings-cpp'({ id, emitAssetDirectory }) {
        if (id.endsWith('@serialport/bindings-cpp/dist/index.js')) {
            // SerialPort ships with prebuilt .node files for multiple OS and Arch types
            emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'prebuilds'));
        }
    },

I'm off to add this at the Typescript level next

RogerHardiman commented 5 months ago

Pull Request #415 submitted to fix this issue

RogerHardiman commented 4 months ago

many thanks for merging in the PR. Also thanks for PKG and for NCC, both of which I've used in the past, so glad I could contribute something back.