Fix bug in Electron environment. - #17684
Conversation
mokeyish
commented
Aug 19, 2022

|
Is seems like you don't want the If you want to disable node support you can also just specify |
|
@sbc100 Hi, It's not a problem in build time. I fix it temporay in pyodide.asm.js by adding |
I was trying to say that if you set Are you saying that |
|
@sbc100 Both node and browser are supported by pyodide. It can't just set Electron also has |
And |
|
@sbc100 Yes, it will thow error. electron is browser environment. |
But I thought one of the main points of electron was that you did have access to things like local files via node APIs? I must be mis-remembering? |
You can access local files via node APIs. But when |
| if options.support_node: | ||
| node_support_code = ''' | ||
| if (typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string') { | ||
| if (typeof process === 'object' && typeof process.browser === 'undefined' && typeof process.versions === 'object' && typeof process.versions.node === 'string') { |
There was a problem hiding this comment.
Can we simplify this to just if (typeof process === 'object' && !process.browser && process.versions && process.versions.node).. just to save a few bytes? (i.e. the typeof is only needed for the first clause I think).
We have what a basically duplicates of this code in src/shell.js and src/worker.js. I guess they both should be updated and kept in sync with this one?
There was a problem hiding this comment.
@sbc100 I have already updated src/shell.js andsrc/worker.js.
|
It would be nice to add a least some testing for the electron environment at some point. If you are using electric with emscripten perhaps you would be interesting in adding this? I'll open a bug. |
|
I can't see anything in the Electron docs about a |
It used here. |
I don't know how to make a testing for it. |
|
It would be better not to use undocumented APIs. |
@curiousdannii It's just to judge whether to use Node APIs. @hoodmane hello, what do you think. I see the code below was commited by you. |
Its not really an API, more of a way of detecting the environment in which the code is running. Do you know of an better or more official way to detect this mode of electron? |
|
@sbc100 As I suggested, |
If use |
So we can check for |
|
|
My apologies .. I missed that reply somehow. |
|
It will need proper testing (which I haven't done any of.) If The code could also check for |
Then, In order to use pyodide in electron, I defind |
|
@mokeyish So you mean |
Yes, the way to check if IN_NODE is basically the same as |
|
We should probably add an option in |
|
Can't your |
This comment was marked as resolved.
This comment was marked as resolved.
Seems like we want to be checking process.type



