Support bundling `.node` modules
Environment
Nodejs: 16.20.0 Nitropack: 2.5.2 rosu-pp: 0.9.4
Reproduction
- npx giget@latest nitro oops
- npm i rosu-pp
- import module somewhere in project
- npm run dev
Describe the bug
Look like this import cause this issue:
Additional context
No response
Logs
No response
Hello, any updates on this one? maybe there a work around
@pi0 Hello, it's been over a 7 months, any news regarding this one?
Hi dear @cyperdark. Bundling .node dependencies is not supported yet. You are welcome to contribute and add support (it should be via rollup plugins)
sorry, i can't contribute, repo is difficult to understand for me. And i got issues running it locally, even tho i did all steps from here: https://github.com/unjs/nitro?tab=readme-ov-file#contribution
found a way to bundle the package by adding this plugin i found in internet
import path from 'path';
export default defineNitroConfig({
rollupConfig: {
plugins: [
{
name: '.node',
resolveId(source: string) {
return source.endsWith('.node') ? path.resolve(source) : null;
},
load(id: string) {
return id.endsWith('.node') ? `module.exports = require(${JSON.stringify(id)});` : null;
},
}
],
},
});