-
Notifications
You must be signed in to change notification settings - Fork 1
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
Nodejs support #1
Comments
Hey, thanks for your interest in this package! I was wondering, have you tried the instructions for patching fetch in node found here https://github.com/node-fetch/node-fetch#loading-and-configuring-the-module? I haven't tried it myself but in theory it should work out. |
This would also need to be patched onto |
I need to try that. I guess it is a good idea to fix this in a pull request. |
It really depends, there's an open question here: If the user is using a browser should I force them to download packages to support node? If the user is using node, but is using other fetch packages, should I also force them to download the fetch packages that I'm using here? Or would it be better to add instructions for using the packages of their choice to patch |
It is better to write a code that supports multiple platforms than saving 100KB of bandwidth. The library itself is 0.4KB which is nothing. If dynamic loading is used, that will not be loaded by the browser. Take a look at this too: https://github.com/wasm-tool/rollup-plugin-rust/blob/6138501796e8d67ef21365f280c88bf60a8b512e/index.js#L275 |
Alright I'll give this some thought. Out of curiosity, what context are you trying to use this in? (SSR, statically rendered?) |
Inside Electron (Atom specifically) |
I'll work on this. In the meantime if this is urgent, could you try patching |
@aminya do you have a repo/branch I could take a look at? I'd like to see specifically how React is being used here. I suspect it might be more complex than adding node-fetch. Are you rendering your React components inside node? (I guess you must be) and are they being hydrated in the browser? |
Electron uses Chrome for rendering, but some of the API is not available there such as There are many https://github.com/diego3g/electron-typescript-react I can set up a branch for Atom if you want to try that instead. |
So, I made this earlier today to test with: https://github.com/tylervipond/use-as-bind-electron-example, it's built on https://github.com/electron-react-boilerplate/electron-react-boilerplate and fetch appears to be working without any additional work, perhaps it's being added somewhere. I'll try it out with https://github.com/diego3g/electron-typescript-react |
@aminya I was able to get the hook working in both of the boilerplate projects listed, without the the need to add node-fetch. So I'm thinking there must be something different in the way that React is being used in your situation, would you be able to send me that branch so I can take a look? |
@tylervipond Yes. I will set up a branch and will let you know once it is ready. |
I'm quite busy this week. I can make the branch in the coming weekend. |
@aminya hate to bug, any luck on this? |
Sorry about this. I'll do it this weekend! |
No worries 👍 and thanks! |
I have made a real-world feature that uses React inside Atom. I still need to add a React hook for use-as-bind. https://github.com/atom-ide-community/atom-ide-base/blob/float-pane/src-commons-ui/float-pane/ViewContainer.tsx Testing it is not that straight forward though (sorry about it)! You need to have Atom, pnpm, and some deps installed.
Then:
Now, link this to atom-ide-datatip
For testing:
Reload Atom (Ctrl+Shift+F5), and hover on some word in a JavaScript file. The datatip is made from ViewContainer! I use two terminals to build projects:
I use two instances of Atom for developing and testing. I edit in one and use the other one for seeing the result (by reloading) |
Thanks so much @aminya! I'll dig into this this weekend |
Got a bit busy and this got put on the back-burner for a bit. I came back to it today. Using the installation instructions above, I'm not able to run |
It would be nice to have Nodejs support. fetch is not supported in Nodejs. You can use something like https://github.com/node-fetch/node-fetch.
The text was updated successfully, but these errors were encountered: