Skip to content

Possible improvements to env detection? #6889

Description

@paulshapiro

I'm unable to say whether this should be a PR at the present time but would like to ask whether the following contains any improvements (by way of generalizations) to the current env detection implementation. Specifically I think the following catches Electron.

var ENVIRONMENT_IS_WEB=typeof window==="object";

var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";

var ENVIRONMENT_IS_NODE=typeof process==="object"&&process.browser !== true&&typeof require==="function" && ENVIRONMENT_IS_WORKER == false; // we want this to be true for Electron but not for a WebView nor e.g. Cordova (latter not checked here)

var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions