diff --git a/.changeset/funny-jokes-divide.md b/.changeset/funny-jokes-divide.md new file mode 100644 index 00000000000..83fdef8c738 --- /dev/null +++ b/.changeset/funny-jokes-divide.md @@ -0,0 +1,5 @@ +--- +"graphiql": patch +--- + +remove dependency on `global` for esbuild/etc users! diff --git a/packages/graphiql/src/components/GraphiQL.tsx b/packages/graphiql/src/components/GraphiQL.tsx index 4bbf89be269..d817c5170d6 100644 --- a/packages/graphiql/src/components/GraphiQL.tsx +++ b/packages/graphiql/src/components/GraphiQL.tsx @@ -89,7 +89,7 @@ if (majorVersion < 16) { ); } -declare namespace global { +declare namespace window { export let g: GraphiQL; } @@ -640,8 +640,8 @@ export class GraphiQL extends React.Component { // Utility for keeping CodeMirror correctly sized. this.codeMirrorSizer = new CodeMirrorSizer(); - if (global !== undefined) { - global.g = this; + if (typeof window !== 'undefined') { + window.g = this; } } UNSAFE_componentWillMount() {