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

Put dummy.stack into Error object, prevents Webpack removing line. #64

Closed
wants to merge 1 commit into from

Conversation

etylermoss
Copy link

Previously Webpack would minify away the line from apparent lack of side effects. See https://github.com/warpdesign/bindings-webpack for a demo of this.

Solves:
#61
warpdesign/react-explorer#78
#54

@etylermoss etylermoss changed the title Put dummy.stack Error object, prevents Webpack removing line. Put dummy.stack intp Error object, prevents Webpack removing line. Mar 3, 2020
@etylermoss etylermoss changed the title Put dummy.stack intp Error object, prevents Webpack removing line. Put dummy.stack into Error object, prevents Webpack removing line. Mar 3, 2020
@cacampbell
Copy link

pls sir my code is very sick. pls merge.

@etylermoss
Copy link
Author

Ok so very strangely this fix worked on the demo project, but in my real project not so much. With Webpack mode: development it doesn't work, but with Webpack mode: production it does, which makes no kind of sense, perhaps something greater is at play?

@cacampbell
Copy link

Yeah, I am beginning to suspect the supernatural at this point.

Admittedly, my case is kindof ... unsupported?

I am trying to split the configuration of a vue project to build electron specific dependencies only for electron. I ended up adding the library node-hid to dependencies and using externals to get webpack on the front end to ignore it.

This worked! for both web environments and electron. But, netlify was not so forgiving of my crimes, and of course, tried to build node-hid, leading to an error when it fails to find the native usb library.

So, I set about trying to fix netlify for this configuration and moved node-hid from dependencies to optionalDependencies. Now it works on netlify, yay!

But, in electron, I began to run into the indexOf undefined issue. Where'd it come from? why now? what? The above change shouldn't have mattered, I think?

So yeah, something weird happens when you attempt to depend on a transitive native library? Something spooky.

@cacampbell
Copy link

I then tried just adding it to all externals with predictable results:

TypeError: node_hid__WEBPACK_IMPORTED_MODULE_0___default...

@cacampbell
Copy link

@ajmar hey, fyi I worked around this issue using the following method:

https://stackoverflow.com/questions/50547649/using-node-js-addons-in-electrons-renderer-with-webpack

this worked 🤷

@etylermoss etylermoss closed this Mar 16, 2020
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

Successfully merging this pull request may close these issues.

2 participants