Skip to content

Commit

Permalink
enhance(import): avoid process import (#6796)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored Dec 24, 2024
1 parent 2c70d27 commit ddfef2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/swift-readers-fail.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 1 addition & 2 deletions packages/import/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readFileSync, realpathSync } from 'fs';
import { dirname, isAbsolute, join } from 'path';
import { cwd as cwdFactory } from 'process';
import {
DefinitionNode,
DirectiveDefinitionNode,
Expand Down Expand Up @@ -68,7 +67,7 @@ export type VisitedFilesMap = Map<string, Map<string, Set<DefinitionNode>>>;
*/
export function processImport(
filePath: string,
cwd = cwdFactory(),
cwd = globalThis.process?.cwd(),
predefinedImports: Record<string, string> = {},
visitedFiles: VisitedFilesMap = new Map(),
): DocumentNode {
Expand Down

0 comments on commit ddfef2c

Please sign in to comment.