You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/typescript-esm/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ yarn start
13
13
14
14
## Explanation
15
15
16
-
In ESM the file extension `.js`must be appended to named imports.
17
-
This can be achieved by setting the codegen config `emitLegacyCommonJSImports` to `false` (see `codegen.yml`).
16
+
In ESM the file extension must be appended to named imports.
17
+
This can be achieved by setting the codegen config `importExtension` to `'.js'` or `'.ts'` (see `codegen.yml`).
18
18
19
19
TypeScript introduced a new module resolution algorithm for ESM in version 4.7. We set the `moduleResolution` to `node16` and the (output) module type to `node16` (see `tsconfig.json`).
20
20
Additionally, within the `package.json` we specify the `type` property with the value `module` in order to instruct Node.js, bundlers and other tools that all `.js` files within this folder should be treated as ESM modules.
* @deprecated Please use `importExtension` instead.
363
366
* @default true
364
367
* @description Emit legacy common js imports.
365
368
* Default it will be `true` this way it ensure that generated code works with [non-compliant bundlers](https://github.com/dotansimha/graphql-code-generator/issues/8065).
366
369
*/
367
370
emitLegacyCommonJSImports?: boolean;
371
+
/**
372
+
* @description Append this extension to all imports.
373
+
* Useful for ESM environments that require file extensions in import statements.
0 commit comments