Skip to content

add extended Node feature check to fix issue #8816 - #8832

Merged
kripken merged 2 commits into
emscripten-core:incomingfrom
ericmandel:incoming
Jul 8, 2019
Merged

add extended Node feature check to fix issue #8816#8832
kripken merged 2 commits into
emscripten-core:incomingfrom
ericmandel:incoming

Conversation

@ericmandel

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request!

If this is your first PR, make sure to add yourself to AUTHORS.

Comment thread src/shell.js Outdated
// This will allow the former to do things like mount NODEFS.
ENVIRONMENT_HAS_NODE = typeof process === 'object' && typeof require === 'function';
// Extended check using process.versions added to fix issue #8816.
ENVIRONMENT_HAS_NODE = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === "string" && typeof require === 'function';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the check for require? I think given we now check explicitly for node, it is redundant?

@ericmandel

Copy link
Copy Markdown
Contributor Author

It might be redundant, but I left it in to document the fact that the canonical heuristic check for Node (according to The Google) utilizes process and require, and we are simply adding to that canonical check ... might be useful to remember when the next exception case rears its head.

@ericmandel

Copy link
Copy Markdown
Contributor Author

@kripken ummm ... were you actually asking me to remove the check? How can I help move this along?

@kripken

kripken commented Jul 3, 2019

Copy link
Copy Markdown
Member

Sorry for the delay. Overall I think we should remove it if it's unnecessary - can mention in a comment, if you think the information is useful? That way we don't pay for it in code size in minified builds.

@ericmandel

Copy link
Copy Markdown
Contributor Author

I removed the redundant check on 'require', tested on Electron (with and without Node) and on Web, and (I believe) GitHub has merged the new commit, so we should be all set ...

@kripken

kripken commented Jul 8, 2019

Copy link
Copy Markdown
Member

Great, thanks @ericmandel!

@kripken
kripken merged commit e9971d1 into emscripten-core:incoming Jul 8, 2019
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
sbc100 added a commit that referenced this pull request Aug 27, 2021
This matches that updated ENVIRONMENT_IS_NODE check that we
have in preamble.js which was improved in #8832.

Fixes #14960
sbc100 added a commit that referenced this pull request Aug 27, 2021
This matches that updated ENVIRONMENT_IS_NODE check that we
have in preamble.js which was improved in #8832.

Fixes #14960
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