Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] CLI stops handling local plugins written in TypeScript since v3.2.2 #9979

Open
eddeee888 opened this issue May 23, 2024 · 0 comments
Open

Comments

@eddeee888
Copy link
Collaborator

eddeee888 commented May 23, 2024

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

Versions before v3.2.2 takes plugins written in TypeScript. However, we bumped a few dependencies in v3.2.2 that may have broken this feature.

Although, the examples in the doc are in .js and there's no mention of .ts support so I'm not sure if it was intentional

Steps to Reproduce the Bug or Issue

  1. Install v3.2.1: yarn add -DE @graphql-codegen/cli@3.2.1
  2. Add the following files
// codegen.ts
import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
  schema: "**/schema.graphql",
  generates: {
    "src/test.generated.ts": {
      plugins: ["src/plugin.ts"],
    },
  },
};
export default config;

// src/plugin.ts
export const plugin = () => {
  return "Hi from plugin!";
};
  1. Running graphql-codegen creates src/test.generated.ts with Hi from plugin! as the content.
  2. Change to v3.2.2: yarn add -DE @graphql-codegen/cli@3.2.2
  3. Running graphql-codegen will show errors like this:
Unable to load template plugin matching 'src/plugin.ts'.
Reason:
Unexpected token 'export'

Expected behavior

v3.2.2 and after should still take local TypeScript plugins.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: 20
  • graphql version: 16.8.0
  • @graphql-codegen/cli version(s): 3.2.2

Codegen Config File

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant