-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Check globalThis.Deno when setting ENVIRONMENT_IS_NODE #19359
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
Open
rojvv
wants to merge
1
commit into
emscripten-core:main
Choose a base branch
from
rojvv:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -592,3 +592,5 @@ a license to everyone to use it as detailed in LICENSE.) | |
* Alexandra Cherdantseva <[email protected]> | ||
* Michael Schmuki <[email protected]> | ||
* Skye Gibney <[email protected]> | ||
* Roj <[email protected]> | ||
* X. <[email protected]> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the goal here is not to set ENVIRONMENT_IS_NODE when running on deno?
How much will actually work in that case? Do we need
ENVIRONMENT_MAY_BE_DENO
to get things to actually work correctly, or does some stuff just work as long as we don't setENVIRONMENT_IS_NODE
.What
ENVIRONMENT_IS_XXX
variable would be set in that case? I guess none of them? I'd be somewhat surprised if that works.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s currently working fine on Deno most of the times. But sometimes the
process
object is made available in the Deno environment for compatibility with Node.js.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How you would feel about an opt-in
-sENVIRONMENT=deno
flag?Even if we move forward without that, it seems like maybe we should add some basic tests if we are going to claim to run under deno.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’d be cool. It would just need to remove the “is Node.js” checks and think as if it is a browser and everything will work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should set
ENVRIONMENT_IS_WEB
under deno you think? Does that already get set today?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried
ENVIRONMENT=web
and it worked. But I still think this change makes sense if we want to target the three at once. And I want to do that now in a lib of mine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do threads work under Deno via the Web's Worker API? (if not then I don't think we need to modify this version of the ENVIRONMENT_IS_NODE).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, are you saying the deno defines
process.versions.node
? That seems rather odd.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, threads work under Deno via Web Worker API. No, Deno doesn’t define
process.versions.node
, rather as I said sometimes its environment is modified for compatibility with Node.js modules, for example by esm.sh.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think trying to play cat a mouse with folks that are trying to polyfill node by defining
process.versions.node
inside of something that isn't node, might not be the right direction. If esm.sh is trying to claim to be compatible with node by declaringprocess.versions.node
is seems reasonable to take them at their word... otherwise we are basically trying to tell the difference between real node and pollyfilled/fake node.On the other hand I'm not an expert in this realm so maybe this kind of thing is normal? Do you know of the best/recommend way to detect "real" node?