Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support node native bindary module #236

Open
AngeloCore opened this issue Jul 24, 2023 · 4 comments
Open

Support node native bindary module #236

AngeloCore opened this issue Jul 24, 2023 · 4 comments

Comments

@AngeloCore
Copy link

AngeloCore commented Jul 24, 2023

What happens if I want to bundle my project that uses a native module? What happens to the .node file?

@huozhi
Copy link
Owner

huozhi commented Jul 24, 2023

It think should copy .node to dist and make it as external. Do you have any example that .node is used by .js? Would love to support it

@huozhi huozhi changed the title Question: What about native modules? Support node native bindary module Jul 24, 2023
@AngeloCore
Copy link
Author

AngeloCore commented Sep 17, 2023

It think should copy .node to dist and make it as external. Do you have any example that .node is used by .js? Would love to support it

Well...

index.js

const wsh = require("./lib.node");

console.log(wsh);

Output:

npx bunchee ./index.js -o ./dist/index.js -f cjs --runtime node
1: MZ�♥♦���@�▼��        �!�☺L�!This program cannot be run in DOS mode.
     ^
2: $ȿ��޹��޹��޹���*��޹�ޫ���޹�ޫ���޹�ޫ���޹�ޫ���޹������޹��޸��޹��޹��޹�H����޹�H����޹�Rich�޹�PEd�♣��d...
3: H�D$0H�
 ⨯ RollupError: Unexpected character '' (Note that you need plugins to import files that are not JavaScript)

@huozhi
Copy link
Owner

huozhi commented Sep 18, 2023

c++ native node bindings are currently not supported. currently bunchee only supports javascript.

@AngeloCore
Copy link
Author

AngeloCore commented Sep 18, 2023

c++ native node bindings are currently not supported. currently bunchee only supports javascript.

Sure! In the future, you can adopt an approach similar to Vercel's ncc by providing a list of assets that includes native bindings's path and content.

rollup-plugin-natives is an option too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants