UNPKG

1.57 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8/**
9 * A replacement for instanceof which includes an error warning when multi-realm
10 * constructors are detected.
11 */
12// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
13// See: https://webpack.js.org/guides/production/
14var _default = process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow
15function instanceOf(value, constructor) {
16 return value instanceof constructor;
17} : // eslint-disable-next-line no-shadow
18function instanceOf(value, constructor) {
19 if (value instanceof constructor) {
20 return true;
21 }
22
23 if (value) {
24 var valueClass = value.constructor;
25 var className = constructor.name;
26
27 if (className && valueClass && valueClass.name === className) {
28 throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
29 }
30 }
31
32 return false;
33};
34
35exports.default = _default;