Add browser polyfills/shims for more node globals #2036
itsMapleLeaf
started this conversation in
Proposals
Replies: 1 comment 1 reply
-
Some Node modules can be polyfilled for the browser, but the filesystem can't be. For security reasons, there's no real way to access files with web apis. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Historically, Remix has had issues with importing files that use node APIs, hence the .server prefix. This issue also applied in the case of remix-electron, and I recommended the same solution.
With the 1.2 update and its addition of polyfilled node globals, I went to see if this allowed importing electron directly, but nah. In the browser I still get
Uncaught ReferenceError: __dirname is not defined
. Even through some tricks to add that global, I still getfs.existsSync is not a function
.Here's the bundled electron module that's trying to run in the browser.
I think this means Remix's node shims aren't extensive enough, and that this issue could come up with other modules that use the same APIs. Maybe the node-globals plugin could be of use here?
I'd also like to know if there's some short-term way to proceed here. That
electron.server.js
proxy file has always irked me 😅Beta Was this translation helpful? Give feedback.
All reactions