node-serialport-bindings-cpp/lib/serialport-bindings.ts
Krzysztof Rosiński 730bc61942
extract bindings (#128)
Hello,

I have a use case where size of an application is important, I'd like to
webpack as much as possible. The problematic part is related *.node
files, I found a potential solution, example with sqlite:

```
externals: {
    './sqlite3-binding.js':       'commonjs ./node_sqlite3.node',
}
```

I can replace sqlite3-binding.js [1] with *.node, then I copy
node_sqlite3.node to the main application folder. I'd like to try
something similar with the serialport. However, it is slightly more
complicated since serialport doesn't have single import file. This PR is
an attempt to fix the problem.

[1]
https://github.com/TryGhost/node-sqlite3/blob/master/lib/sqlite3-binding.js

---------

Co-authored-by: Krzysztof Rosiński <krzysiek@jrdltd.co.uk>
2024-12-23 15:12:57 -05:00

5 lines
201 B
TypeScript

import { join } from 'path'
import nodeGypBuild from 'node-gyp-build'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const binding = nodeGypBuild(join(__dirname, '../')) as any