Skip to content

Commit 4780d57

Browse files
authored
Fix CJS/ESM issue (#10614)
1 parent 7b3bac9 commit 4780d57

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/long-emus-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/testing': patch
3+
---
4+
5+
Fix usage issue due to ESM/CJS incompatibility

packages/utils/graphql-codegen-testing/src/typescript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { dirname, join, resolve } from 'path';
22
import { Types } from '@graphql-codegen/plugin-helpers';
3-
import { compressToEncodedURIComponent } from 'lz-string';
3+
import * as LZString from 'lz-string'; // lz-string is a package which has CJS/ESM issues. So, we cannot do `import { something } from 'lz-string'`
44
import {
55
CompilerOptions,
66
createCompilerHost,
@@ -239,7 +239,7 @@ export function compileTs(
239239
}
240240
} catch (e) {
241241
if (openPlayground) {
242-
const compressedCode = compressToEncodedURIComponent(contents);
242+
const compressedCode = LZString.compressToEncodedURIComponent(contents);
243243
open('http://www.typescriptlang.org/play/#code/' + compressedCode);
244244
}
245245

0 commit comments

Comments
 (0)