Skip to content

Commit

Permalink
Fix emitLegacyCommonJSImports to being passed (#8185)
Browse files Browse the repository at this point in the history
Co-authored-by: Charly POLY <1252066+charlypoly@users.noreply.github.com>
  • Loading branch information
Andrey Osiyuk and charlypoly committed Aug 5, 2022
1 parent cf40886 commit 47d0a57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-islands-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-codegen/visitor-plugin-common": patch
---

Fix emitLegacyCommonJSImports to being passed
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface ParsedConfig {
dedupeFragments: boolean;
allowEnumStringTypes: boolean;
inlineFragmentTypes: InlineFragmentTypeOptions;
emitLegacyCommonJSImports: boolean;
}

export interface RawConfig {
Expand Down Expand Up @@ -212,6 +213,12 @@ export interface RawConfig {
* @default inline
*/
inlineFragmentTypes?: InlineFragmentTypeOptions;
/**
* @default true
* @description Emit legacy common js imports.
* 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).
*/
emitLegacyCommonJSImports?: boolean;
}

export class BaseVisitor<TRawConfig extends RawConfig = RawConfig, TPluginConfig extends ParsedConfig = ParsedConfig> {
Expand All @@ -232,6 +239,8 @@ export class BaseVisitor<TRawConfig extends RawConfig = RawConfig, TPluginConfig
dedupeFragments: !!rawConfig.dedupeFragments,
allowEnumStringTypes: !!rawConfig.allowEnumStringTypes,
inlineFragmentTypes: rawConfig.inlineFragmentTypes ?? 'inline',
emitLegacyCommonJSImports:
rawConfig.emitLegacyCommonJSImports === undefined ? true : !!rawConfig.emitLegacyCommonJSImports,
...((additionalConfig || {}) as any),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ export class ClientSideBaseVisitor<
...fragmentImport.importSource,
identifiers: newIdentifiers,
},
emitLegacyCommonJSImports: this.config.emitLegacyCommonJSImports,
};
})
// remove any imports that now have no identifiers in them
Expand Down

1 comment on commit 47d0a57

@vercel
Copy link

@vercel vercel bot commented on 47d0a57 Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.