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

process.arch and process.platform are missing from polyfill #58

Closed
devzzzero opened this issue Nov 17, 2024 · 7 comments
Closed

process.arch and process.platform are missing from polyfill #58

devzzzero opened this issue Nov 17, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@devzzzero
Copy link

Hi. Please take a look at zeromq/zeromq.js#676

So the proximate cause is that the polyfill is not providing process.arch and process.platform which is causing zeromq to barf when packed with webpack.

The process/browser package has not been updated since 2016 or so.

What do you think should be done in this case?

Thank you.

@Richienb
Copy link
Owner

What do you think should be done in this case?

I think we should maintain our own fork of the process polyfill that adds these features.

@devzzzero
Copy link
Author

I know it's not "secure" but it really would simplify things If I am able to inject 'fs' and 'process' directly into the renderer process on electron-forge+webpack.

This horrendous going back and forth via ipcMain and ipcRenderer is so fragile and difficult to get right...
Even worse, None of the examples on https://www.electronjs.org/docs/latest/tutorial/ipc actually work out of the box. :-(

Do you have any advice on how I might go about writing such a polyfill? (please mind I am n00b w.r.t. webpack)

@devzzzero
Copy link
Author

@Richienb
Copy link
Owner

I know it's not "secure" but it really would simplify things If I am able to inject 'fs' and 'process' directly into the renderer process on electron-forge+webpack.

@devzzzero In an Electron app, you can just call the Node.js APIs directly, no polyfill needed.

@devzzzero
Copy link
Author

I know it's not "secure" but it really would simplify things If I am able to inject 'fs' and 'process' directly into the renderer process on electron-forge+webpack.

@devzzzero In an Electron app, you can just call the Node.js APIs directly, no polyfill needed.

Yes. Thank you. I tried setting contextIsolation:false It doesn't seem to work any more. :-( At least, not on the renderer side...

@Richienb
Copy link
Owner

I tried setting contextIsolation:false It doesn't seem to work any more.

Did you also try set nodeIntegration: true?

If it doesn't work, try using a preload script, which can even make functions calling Node.js APIs available in the renderer.

@devzzzero
Copy link
Author

Did you also try set nodeIntegration: true?

I tried all of the following at once. but I had no luck trying to get zmq to load up on the renderer side.

  const mainWindow = new BrowserWindow({
    height: 1200,
    width: 1600,
    backgroundColor: "#202020",
    webPreferences: {
      sandbox: false,
      contextIsolation:false,
      nodeIntegration: true, // <--- flag
      nodeIntegrationInWorker: true, // <---  for web workers
      preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
    },
  });

I think this is a combination of electron documentation bit rot combined with the fact that the last version of electron I worked with was 8.5! It was an entirely different particle way back then. :-)

If it doesn't work, try using a preload script, which can even make functions calling Node.js APIs available in the renderer.

Interesting! I'll take a look . Thank you! @Richienb !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants