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

instructions for using rollup with node native modules #3504

Open
2 of 4 tasks
pjebs opened this issue Apr 18, 2020 · 1 comment
Open
2 of 4 tasks

instructions for using rollup with node native modules #3504

pjebs opened this issue Apr 18, 2020 · 1 comment

Comments

@pjebs
Copy link

pjebs commented Apr 18, 2020

Documentation Is:

  • Missing
  • Needed
  • Confusing
  • Not Sure?

Please Explain in Detail...

I am building an electron application.

I usually bundle (using rollup) all my javascript into 1 file, and package the 1 javascript file (rather than the usual practice of copying the entire node_modules directory without bundling).

This worked well for me until I introduced node-keytar dependency which is a node native module.

Obviously this can't get bundled so I set it as external in the rollup.config.js file.

I did not manage to get further that this. For non electron applications, standard practice is to use the bindings npm package and copy the build version of keytar.node file. bindings doesn't work with electron applications that choose to bundle the javascript.

I tried various techniques found on the internet but rollup kept complaining that it doesn't support dynamic requires.

How do I proceed from here? I think rollup documentation should provide guidance.

@pjebs
Copy link
Author

pjebs commented Apr 18, 2020

My current workaround is to bundle as explained above. Then delete everything in node_modules directory (for packaging purposes) except for keytar directory (In fact I keep only keytar/build, keytar/lib and keytar/package.json).

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

No branches or pull requests

1 participant