diff --git a/.changeset/swift-readers-fail.md b/.changeset/swift-readers-fail.md new file mode 100644 index 00000000000..461cee646ba --- /dev/null +++ b/.changeset/swift-readers-fail.md @@ -0,0 +1,6 @@ +--- +'@graphql-tools/import': patch +--- + +Avoid importing `process` and use it from `globalThis`. +In some cases, `cwd` is not exported with this name in the environment in ESM scope. diff --git a/packages/import/src/index.ts b/packages/import/src/index.ts index a3fd2b5fd0f..eabc98dea96 100644 --- a/packages/import/src/index.ts +++ b/packages/import/src/index.ts @@ -1,6 +1,5 @@ import { readFileSync, realpathSync } from 'fs'; import { dirname, isAbsolute, join } from 'path'; -import { cwd as cwdFactory } from 'process'; import { DefinitionNode, DirectiveDefinitionNode, @@ -68,7 +67,7 @@ export type VisitedFilesMap = Map>>; */ export function processImport( filePath: string, - cwd = cwdFactory(), + cwd = globalThis.process?.cwd(), predefinedImports: Record = {}, visitedFiles: VisitedFilesMap = new Map(), ): DocumentNode {